Archive

Posts Tagged ‘how-to’

Karl’s Home Automation Project – Part 4: MQTT Bridge Updated to Use YS-IRTM IR Receiver & Transmitter with NodeMCU

April 20th, 2017 1 comment

In a previous article, I wrote about an MQTT bridge by 1technophile. I added a DHT temperature and humidity sensor as well as a light sensor. Previously it included a software decoder to decode the IR signal. I never did test the IR transmitter on the gateway, as I didn’t have the parts. But thanks to IC Station, who sent me over a small YS-IRTM hardware based decoder and NodeMCU that I am writing about today. I have replaced the software based version with the YS-IRTM module in the latest update.

Click to Enlarge

Click to Enlarge

I found this project challenging. I admit I am a little weak in my programming skills. It was difficult to find documentation but I found a forum talking about this device and basics of how it works. When an IR code is recognized it sends 3 hex codes via serial connection on the transmit pin. To transmit, it expects 5 hex codes: A1,F1,xx,xx,xx. A1,F1 tells it to send the following codes. You can also set the baud rate but I left default 9600.

It is simple wiring wise. It only takes 4 dupont wires. It took a bit of coding to get it working but I finally got it to communicate via software serial. I started on a Arduino Uno with the code and then migrated it over to the ESP8266 board. I did have a little trouble when I first moved to the ESP board. I initially thought I might need a level shifter but that didn’t help. I am a little surprised I didn’t need a level shifter because the ESP needs only 3.3 volts. I was getting some weird responses and finally figured out I had to put in a slight delay. Maybe the ESP’s speed comes into play.

The way to use this is fill out your SSID and password and your MQTT server with credentials. Flash the device. You will need to add the necessary libraries. 1technophile has good documentation in his wiki.

Once flashed and ready to find your IR codes you will need to subscribe to the topics with the Windows command below. Give the gateway a moment to connect and point your IR remote at the sensor and press a button to find out code.

In your window, you will get something like this “home/sensors/ir 4,fb,8,” which is my power button for my TV. To test the code:

With this code, the TV will toggle on and off.

Click to Enlarge

After this you can use your favorite home automation project and control your IR devices with automations. You can omit any sensors that you don’t need. You will get some erroneous MQTT data if not all sensors are used. Below are the bits of Arduino code added for the IR module, and here’s the link to the github code:

I plan on 3D printing an enclosure with CR-10 I am reviewing, and I will remove the IR LED, and move it to a more suitable position, as both facing the same way isn’t ideal for my setup.

I would like to thank IC Station for sending the NodeMCU ($5.81 shipped) and IR transmitter and receiver ($3.39 shipped) for review. You can get 15% discount with coupon Karics. I finally have a complete gateway.

ESP8266, Mongoose OS & Grove Sensors – An Alternative Solution for Hackathons

April 12th, 2017 5 comments

CNXSoft: This is a guest post by Cesanta

If you walked into any Hardware hackathon over the last year, you would see they are about innovation and bringing new ideas to this world and most of them are centered around the connected devices nowadays. However, just walk the floor, talk to the teams and you can quickly see an elephant in the room. The Hackathons are about connected devices, but with the ‘recommended’ and frequently sponsored hardware distributed to the teams such as Intel Galileo, Raspberry Pi, etc…. developers may struggle for a long time to even connect it to the cloud!

Not to mention the innovation is usually hindered by a tedious environment setup which takes hours, things to learn about the specific hardware and how it can be programmed using low level languages. So many teams spent most of the time fighting with those issues and oftentimes still do not have their prototype ready and connected by the end of hackathon.

This situation can be improved by using ESP8266 boards with Mongoose OS and SeeedStudio Grove Sensors. The solution brings the following benefits:

  1. Low price:
    • ESP8266 development board is $4-15 depending on the board;
    • Seeed Studio Sensors are priced  $3 to $15 each, but you can also save by purchase them as a part of Grove Starter Kit for $39.
  2. The solution is solderless & plug and play – so anyone can actually use it fast.
  3. With Mongoose OS the firmware logic can be coded within few minutes using JavaScript code
  4. The data can be pushed to any cloud or public MQTT server such as Mosquitto, HiveMQ, AWS IoT, etc…

Let’s jump into the action and get ESP8266 & Seeed Light Sensor up and running with Mongoose OS in a few minutes. This example below shows how to get the hardware (sensor) data and send it to the cloud.

  1. Get your ESP8266 (e.g. NodeMCU) and Seeedstudio Light Sensor and Button ready.
  2. Download and install mOS tool for Mongoose OS. This works in Linux, Mac OS X, or Windows operating systems
  3. Connect the hardware
    • Power the Grove base shield: connect GND and VCC pins to the NodeMCU GND and VCC pins
    • Connect light sensor to slot 7 on the Grove base shield
    • Connect slot 7 to the ADC pin on the NodeMCU board
    • Connect NodeMCU board to your computer
  4. Program the board to retrieve the light sensor data and send it to the cloud (HiveMQ in this example)
    • Start mos tool, switch to the prototyping mode, edit init.js file
    • Click ‘Save and reboot device”
  5. Go to http://www.hivemq.com/demos/websocket-client/, connect and subscribe to the topic “my/topic”
  6. Press a button and see how light sensor reading is sent to the MQTT server

Light Sensor Data Shown on HiveMQ Dashboard – Click to Enlarge

Now you can see how easy it was! Want to play with other Seedstudio sensors from Grove Kits? Check video tutorials for button, motion sensor, moisture sensor, UV sensor, relay, buzzer, etc… including the one below with the light sensor.

Transform Your ESP8266 Board into a USB to Serial Board Easily with Arduino Serial Bypass Sketch

April 7th, 2017 6 comments

USB to serial boards are necessary to program and debug boards, and/or access the serial console, and while they are very cheap, you may be in a situation where you don’t have any around, but you do have some Arduino compatible boards. It’s been possible to transform an Arduino board into a USB to TTL debug for several years using ArduinoSerialBypass.ino sketch, but I’ve been informed this also works on ESP8266 boards such as Wemos D1 Mini.

The sketch could not be simpler:

The code simply makes sure that Tx and Rx pins are set as inputs in order not to disturb the serial connection as explained below:

This code makes the Arduino not interfere with pins 0 and 1 which are connected to RX and TX on the FTDI chip. This allows the data coming from the FTDI USB 2 Serial chip to flow directly to another device. Since RX and TX are labeled from the Arduino’s point of view, don’t cross the wires, but plug the device’s RX wire into the RX pin 0 and the TX wire into the TX pin 0

This should work with any Arduino compatible boards with a USB to serial chip, but it’s nice that it has been confirmed to work on Wemos D1 mini. If you’d rather get a WiFi to serial bridge, that’s what ESPLink firmware is for.

Thanks to Zoobab for the tip.

Categories: Espressif, Hardware Tags: arduino, esp8266, how-to

Karl’s Home Automation Project – Part 3: Adding Light Detection to a Motion Sensor

March 27th, 2017 No comments

This is the 3rd part of my Home Automation light project. In the first part, I wrote about basic setup with basic Sonoff Wifi MQTT switches and setting them up. In the second one, we added some 433 MHz motion sensors and a 433 MHz to MQTT bridge. And finally in part 3, we are going to modify the 433 MHz motion sensors to only work when it is dark in the room.

Motion Sensor

Click to Enlarge

The motion sensor I linked in part 2 is run by a common chip called a BISS0001. We are interested in pin 9. If voltage is below .2v it will not trigger a motion. This solves the problem discussed in part 2, when we have a gloomy day or if blinds are closed etc.

By adding an GL5537 LDR (Light Dependent Resistor) shown as R3 in the diagram above, you will achieve the desired effect. Extend the LDR with some wires and solder between ground and pin 9.

The GL5537 is extremely sensitive. You can adjust your sensitivity by placement. I put mine right next to the PIR sensor so it sees outside the window. It works perfectly. If you wanted it to get a little darker you can use the mounting hole on the back or make a new on the top or sides. Direct access to the outside light would mean it would need to be darker in the room for it to trigger. You have to be careful with the motion sensor placement or your light being triggered might cause the motion sensor not to trigger because there is too much light. I get this if the motion sensor is too close to the lamps I am triggering.

Home Assistant

Before modifying we had 2 automations one for before sunrise and one for after sunset:

Now that we’ve added the logic for light and dark at the motion sensor itself, we can simplify these 2 down to one automation, and only specify the time. The rest of the home assistant configuration can be found in 2nd article here.

That is all I have for now. If you have an idea or a product that you feel that meets the cheap and DIY criteria leave a comment below. I will test it out. I know you can do a ton of things with Home Assistant and a lot seem over the top. I want to focus on mundane things like turning off lights. I am also going to get some 433 MHz moisture sensors for my house to place in crawl spaces, and under the sink but that is pretty basic.

Continue reading “Part 4: MQTT Bridge Updated to Use YS-IRTM IR Receiver & Transmitter with NodeMCU“.

Xtream Codes IPTV Panel 2.4.2 Review – Part 4: Tutorial to Change the Main Server, Backup & Restore the Database

March 20th, 2017 3 comments

This is the fourth part of a review about Xtream Codes IPTV Panel, software to become your own content provider, and manage streams, clients, and resellers. The first three parts:

  1. Review of Xtream-Codes IPTV Panel Professional Edition – Part 1: Introduction, Initial Setup, Adding Streams…
  2. Xtream Codes IPTV Panel Review – Part 2: Movie Data Editing, Security, Resellers, Users and Pricing Management
  3. Xtream-Codes IPTV Panel Review – Part 3: Updates and New Features for Version 2.4.2

Main Server Change – Part 1: New Server

Changing your Main Server could bring you troubles, if you do not know what you are doing. Many different reasons to change the Main server such as  crashes, new one. making a Load Balancer to be a Main Server…

Remember, it’s all about the existing backup, and you’ll restore your backup later, after successfully changing the Main Server. That is not difficult and everybody can do it. But if you install your backup with your former configurations-Servers etc, it will need some corrections after the backup install is finish, and for example all your Clients, Servers ( and your Old Main Server) will be in again after you install your backup.

I’ll try to explain what that’s all about and show different examples.

  1. Changing the Main Server sounds and looks pretty easy, piece of cake, right?

But let me tell you, it’s not! Be absolutely sure about what you are doing before. We start with “Manage Server” left side in the Panel.

Then you scroll down to the end and you’ll see this:

Click to Enlarge

Warning: Make sure that you took all necessary steps before you press this button, all will be gone in a flash… BEFORE YOU Press MAIN SERVER CHANGE

Step 1: Do a Manuel Backup; this is still possible, since Xtream-Codes thought it would be a good idea to take the manually install Backup-Button off the road, for later installing your FULL BACKUP again by yourself!. NOT A GOOD IDEA, Xtream-Codes!

Step 2: Do a fresh automated backup on Xtream-Servers.

  • Database Manager—Remote Backup Now

Step 3: Take your time to think about your scenario! What do you want to do? Changing to a brand new Main? Formatted the old one only? Making an Existing Load balancer Main now? You see? Different procedures. It needs different preparing on this step of the game.

You have to think about the existing BACKUP, with all your clients and streams in, right? Or you want to loose them? I guess not. Again, think about, that the backup and later installing of your backup contains all your streams, clients etc…but also the old Server configurations.

Have also your ROOT ACCESS from the Panel at hand, because after pressing the CHANGE-Main Button…it happened a few times, that I could not login anymore in the CMS without root user/pass. You can find this Root USER/PASS in your Client Area WHMCS with Xtream-Codes,

Click My SERVICES—-

Press this then after:

And you see all what you need after:

We now change the Main to a NEW ONE:

After pressing the Button

Click to Enlarge

A warning pops up, asking, “Are you Sure”?

Click to Enlarge

We press OK! Seat belt on, and then this should come (In former versions I was simply getting kicked out the CMS, and have to login with Root user/pass only, Admins could not. This seemed to be fixed to a friendlier follow up now…)

Click to Enlarge

Now you put your NEW MAIN’s IP and SSH ROOT Password in, also your MYSQL ROOT Password, if any. If you are not sure, then in most cases simply put your ROOT SSH in again. Also, check the SSH Port, standard is Port 22, except if you changed it before. Don’t care about the rest now; you can change it later easily. Your New MAIN SERVER will install now, if all necessary data’s was right. And after a couple of Minutes, your New Main is installed

Click to Enlarge

After Installation of your NEW Main is finished, you want to restore the backup. Like I said, Xtream-Codes gives you right now (Sure that they will bring it up again) only the choice to install a Remote Backup from Xtream Codes Servers. To do this, you do as follows: Go DATABANK Manager and you see all your Remote Backups

Click to Enlarge

Right click the curved red and green arrow (load Backup), and after you choose your Remote Backup, this shows up:

Click to Enlarge

Press OK, and you see that Databank with all your Values is restored.

NEXT STEP, like I mentioned already above: after your Backup is installed, you will see, that your former OLD MAIN SERVER seems to be installed again! YOU HAVE TO GO ‘EDIT-SERVER…EDIT MAIN… and CORRECT IP AND SSH! This will do it then!.

And after successful installing the new Main (if he is a brand new one) , and installing the Backup then after, you Main will show the former IP of your Main, cause he was still in the installed backup in!

No problem at all, simply go edit Main-Server, insert again IP and SSH Root Password, and right SSH port, commonly Port 22, if you don’t changed it in your New Main.

Click to Enlarge

It also appears that your Load Balancers need a FULL REMAKE

PRESS FULL REMAKE ALL LB’s

AFTER PRESS FULL REMAKE ALL LOAD BALANCERS, HERE WE GO

It is possible, that you have to have to repeat this action with remaking all Load balancers. But be assured, it will work.

This was Part 1 of CHANGING the MAIN SERVER. I guess you know, what follows later, the little bit more complicated procedure of Changing The Main under different scenarios:

  1. We make an existing Load balancer to a NEW MAIN
  2. The preparation to do this

Changing Main Server – Part 2: Convert Load Balancer to Main Server

Scenario: We want a running Load balancer as a new Main Server! The right now “running” Main we want to send in retirement, right? This example requires that you have a few Load Balancers up and running. In case you have only 2 dervers in total, it’s not so complicated at all. Like I said above, each scenario is different. There are Admins with 20 or more Load balancers, and there are small ones, with 2 or 3 in total.

Do exactly Step by Step as follows, no twisting, no turning, no upside down please.. 🙂

Step 1: You go to TOOLS left Side, and transfer temporarily all streams from the future Main Server to another Load balancer of your choice! That’s how I have done it, not sure it will work later if you go another way, letting the streams on the future Main (the Server is a LB right now), but we have to delete this Server later out of the Panel configuration to make him Main! Reason: After we push the Remote-Backup back in, he will appear as a Load balancer again, and we can’t make him a Main Server without deleting him in the Panel.

Go exactly this way right from the start! NO REMOTE BACKUP BEFORE!! (Still hope that Xtream-Codes will implement the old feature back in soon, because not many can handle phpmyadmin, to implement a databank backup by their own later, or they should put a “hint or kind of warning” in before, something like Remote Backup now? Just in case the Admin forget it! Remember also, that the cron job “Remote Backup” is only once each 24 hours, so better do this manually Remote Backup before.)

Click to Enlarge

In general, a good idea in safety reason, the Remote Backup’s, it is a way more safe then before. Here we go now:

Click to Enlarge

After you’ve transferred your Main Server’s streams to another server, check first, the Main is really empty, it will need sometimes 1 or 2 or more minutes, depending of the quantity of your transferred streams. Now we have an empty Main, it’s the one, we do not need anymore after.

We have also to transfer the streams from the Load balancer we want as a NEW MAIN, making him completely empty. No streams on it. We do the same with the Load balancer we want as Main now! We are transferring his streams to another Load balancer the same way we have done before with the Main who has to go.

Step 2:

We do a REMOTE BACKUP after we transferred all streams, and to be on the safe side, a manual Backup to your Computer as well. First you press BACKUP DATABASE (the Backup File will load down to your computer), and direct after, we press REMOTE BACKUP NOW (Backup is loaded into Xtream Codes Server).

Click to Enlarge

Step 3:

We go MANAGE SERVER and at the bottom we see Main-Server-Change again:

Click to Enlarge

Let’s summarize what we have done.

  1. We have the Main and the future MAIN now with no Streams on it
  2. We are still in the process to change our Main Server
  3. Backups are already made (we are with an empty Main Server and an empty Load balancer right now)
  4. We have all our necessary data’s, IP and SSH Root Pass from the Load Balancer we want to put as a New Main. Login data’s ROOT for our CMS, just in case…

After that, we go MANAGE SERVERS-EDIT SERVER-DELETE SERVER.

We delete the Load balancer we want as NEW MAIN. Now we can press the Button Main Server Change.

Click to Enlarge

All necessary follow up’s standing already in Part 1 above!

We are ready to go!

  • Just in case you forgot or out of whatever reason you prefer to do a manually “load” of your saved databank backup, it’s also possible with phpmyadmin later.
  • In case you cannot do, open a ticket, XC is happy to help you out!
  • Don’t forget, Xtream-Codes support is not open 24/7!
  • And one of the most important last steps, after successfully installed the new Main, don’t forget to switch the old former MAIN OFF!
  • Switch him off, or make a new install! and sure you have to sort out your streams later, balancing them again.
  • In all other cases, like you have only 2 Servers, the procedure is similar and not complicated, cause of your limited streams, and clients. This example was written in case you got a few more Load Balancers running.
  • Don’t hesitate to open a ticket in case you are in trouble, Xtream Codes will help you in any cases.

I hope this little How-To helps you guys a little.

Ray

Google Releases Guetzli Open Source JPEG Encoder Generating 20 to 35% Smaller Files Compared to Libjpeg

March 17th, 2017 13 comments

Google has been working one several front to make data and images smaller, hence faster to load from the Internet, with project such as Zopfli algorithm producing smalled PNG & gzip files, or WebP image compression algorithm that provides better lossless compression compare to PNG, and better lossy compression compared to JPEG, but requires updated support from clients such as web browsers. Google has now released Guetzli algorithm that improve on the latter, as it can create JPEG files that are 20 to 35% smaller compared to libjpeg with similar quality, and still compatible with the JPEG format.

The image above shows a close up on a phone line with the original picture, the JPEG picture compressed with libjpeg with the artifacts around the line, and a smaller JPEG picture compressed with Guetzli with less artifacts.

You can find out more about the algorithm in the paper entitled “Guetzli: Perceptually Guided JPEG Encoder“, or read the abstract below:

Guetzli is a new JPEG encoder that aims to produce visually indistinguishable images at a lower bit-rate than other common JPEG encoders. It optimizes both the JPEG global quantization tables and the DCT coefficient values in each JPEG block using a closed-loop optimizer. Guetzli uses Butteraugli, our perceptual distance metric, as the source of feedback in its optimization process. We reach a 29-45% reduction in data size for a given perceptual distance, according to Butteraugli, in comparison to other compressors we tried. Guetzli’s computation is currently extremely slow, which limits its applicability to compressing static content and serving as a proof- of-concept that we can achieve significant reductions in size by combining advanced psychovisual models with lossy compression techniques.

The compression is quite slower than with libjpeg or libjpeg-turbo, but considering that on the Internet a file is usually compressed once, and decompressed many times by visitors, this does not matter so much. Another limitation is that it does not support progressive JPEG encoding.

You can try Guetzli by yourserlf as the code was released on github. It did the following to build the tool on Ubuntu 16.04:

You’ll the executable in bin/release directory, and you can run it to list all options:

Ideally you should have a raw or losslesly compressed image, but I tried a photo taken from my camera first:

But it reported my JPEG file was invalid, so I tried another file (1920×1080 PNG file):

It’s a single threaded process, and it takes an awful lot of time (about 3 minutes on an AMD FX8350 processor), at least with the current implementation. You may want to run it with “verbose” option to make sure it’s not dead.

I repeated the test with convert using quality 95, as it is the default option in Guetzli:

The file compressed with Guetzli is indeed about 15% smaller, and should have similar quality:

It’s just currently about 1,400 times slower on my machine.

How to Reinstall Android Firmware on Realtek RTD1295 TV Boxes

March 16th, 2017 14 comments

I started playing with Beelink SEA I TV box nearly two weeks ago, but I soon realized there was a big problem, while I could get an IP address with both Ethernet or WiFi, I could not access Internet, nor the local network with the box, and even ping would not work. So I contact Beelink to find a solution, and they believed I may have a problem with the firmware on my box, and recommended to re-flash it.

Great. I asked the firmware, and the company eventually provided me with two files:

Those are baidu link which may be slow to download outside of China, so the company also provided a mirror later. The customer representative told me those were “Lines brushes Pack” firmware, and after lots of email back and forth. I finally got proper instructions which should work for Beelink SEA I, but also other Realtek RTD1295 boxes such as Zidoo X9S or Eweat R9 Plus. Note that this method is only useful in case something really goes wrong, as the device normally support OTA firmware updates.

First you’ll need a Windows computer or laptop, and a USB male to USB male cable., before following the firmware recovery instructions they use at the factory.

  1. Download setup.exe
  2. Click on setup.exe to install Microsoft Visual C++ 2012 and .NET Framework 4.6.
  3. Now reboot as instructed, and right click on setup.exe to run it as an administrator, and install rtk_usb_mp_tool. If you don’t run it as Administrator you’ll run into permissions issues and the installation will fail.
    This will also install the USB drivers for “USB REDIRECTION” device. By default, this is install in {HOME}/rtk_usb_mp_tool directory
  4. Now you can start the program “rtumdfsample.exe”

    The window size is about 1300 x 900, and cannot be resized, so I allow you to curse or (gently) bang your head on the wall if you run this on a netbook or laptop with 1366×768 resolution or lower. You’ll feel better 🙂
  5. Now insert the USB cable between your computer and the USB 3.0 port of the device, and turn on the box. The display on the box should always show “boot”, and the top logo should change from the yellow fear to a green Android once you device is detected over USB.
  6. Now Click on “Open” button in the Install section of the user interface, to load the firmware file (in my case SEAI_101M0_16G_20170225.img).

    Click to Enlarge

    The top left icon will turn red, and update the firmware.

  7. Once it gets to 100%, you are done. Disconnect the USB cable, and restart the device into your freshly burned firmware.

The goods news is that networking works, I get the weather forecast within the launcher. The bad news is that the display turns off after 5 seconds, until I disconnect and reconnect the HDMI cable, and goes off again 5 seconds. At least the firmware update method worked…

How to Control Your Air Conditioner with Raspberry Pi Board and ANAVI Infrared pHAT

March 12th, 2017 7 comments

Leon ANAVI may be a full-time software engineer, but in his spare time he has started to develop open source hardware project with the help of others and by himself. Last year, I got hold of his RabbitMax Flex HAT for Raspberry Pi, and tested it with the provided LCD display, one temperature sensor, and a Raspberry Pi 2 board. The board also featured IR receiver & transmitter, and I tried to use it with my aircon remote control, but at the time I did not find a way to do it easily, and control my TV with LIRC instead. Leon has now made a simpler, smaller, and cheaper add-on board for Raspberry Pi Zero, and other Raspberry Pi boards with a 40-pin header, with 3x I2C headers, two IR transmitters, and one IR receiver. He sent me a sample of “ANAVI Infrared pHAT”, and after quickly describing the board, I’ll show how to I could control my air conditioner with a Raspberry Pi 2 board and his Infrared pHAT.

ANAVI Infrared pHAT

The top of the has the 3x I2C header for 3.3V sensors, a UART header to access to serial console, two x 5mm IR transmitters (IR LEDs), and one IR receiver (IR photo sensor). It also has an EEPROM to store the HAT ID.

Click to Enlarge

The other side comes with the 40-pin female header to connect to your Raspberry Pi board.

The board was designed with KiCAD, and the hardware design files are released under a “Creative Commons Attribution-Share Alike 3.0 United States” License on github.

ANAVI Infrared pHAT Connection to Raspberry Pi Board

There’s only one step: insert the board on the 40-pin connector of your RPi board. You can only make one mistake, inserting it the wrong way. It has to be connected in away that it covers part of the board.

I’ve connect it with a Raspberry Pi 2 board with a battery kit, but it fits even better on the Raspberry Pi Zero, or newly released Raspberry Pi Zero W.

Setting up Raspberry Pi, and Controlling the Air Conditioner with LIRC

It’s time to start software setup in order to control the Haier air conditioner pictured below.

You’ll need to install Raspbian, and some packages including LIRC, but I’ve already explained how to do that in RabbitMax Flex Getting Started Guide, so I’m not going to repeat those steps here, especially you can find them in ANAVI Infrared pHAT user’s manual too, and I’ll assume you have already setup your board.

The reason why I could record IR commands from my TV remote control, and not my aircon remote control last time around, is because aircon remotes send not only one byte but also status info each time. The trick is to use mode2’s “alternative display mode” to capture pulse/space data as raw config files.

Let’s do that:

Now I faced the IR receiver and pressed the power key on the remote control:

Wow, that’s a whole bunch of numbers, but that’s exactly what we need as those are the duration of the high and low levels of the IR signal. I have repeated the same command, but capturing 4 keys: off, on, up to 29C, and down to 28C.

Then we need to edit our lircd-haier-ac.conf file manually:

Note that you need to delete the first “big number” from each captured command. For example, I had to delete “4989552” from the first capture of the power key. If you want full control, you’ll need to record all keys. You may want to read lircd.conf manual to understand parameters like aep or aeps. I used the default values, but in case it does not work for you, or works unreliably, you may have to adjust them, possibly from data obtained using an oscilloscope. I did not have such problem, and copied the file to /etc/lirc/lircd.conf:

In theory, you can restart lircd from the command line:

but in my case, I always had troubles when running irsend command:

So I had to reboot the board with sudo reboot to enable changes. Later I used the reload command (to take into account the update config) after restart, and I could avoid a reboot:

Once it’s all working, we can list the keys we’ve just defined in lircd.cong:

To turn on the aircon:

Then I was not sure what action would happen when I recorded the up key once setting the temperature. So I first set the temperature to 23C to check whether it would increment the temperature to 24C, or set it to 29C:

And the later happened, which means you need to record all temperatures you want to set, and there’s no such thing as UP and DOWN keys.

You’ll already guessed how to turning off the aircon:

Then I realized that since “29C” and “28C” commands send the temperature, it might also send the power status, and indeed I can turn on the aircon @ 28C directly with with 28C command. So instead of recording keys for your aircon, you are actually recording “scenes” which you could name “night”, “25Cfanlowswingup”, “off”, and so on. I added 25Cfanlowswingup with temperature set to 25C, fan speed set to low, and swing set to up, added it to lircd.conf, and a single command would turn on the aircon and set all those values:

Pretty neat.

While the instructions above will work with any board with IR receiver (for first time setup) and IR transmitter, you may be interested in getting ANAVI Infrared pHAT on Indiegogo for $9 plus shipping ($5 to  $7). There are also other rewards including the pHAT, I2C sensors, and debug tools. The campaign has already surpassed its funding target ($500), and delivery is planned for September 2017.