Operating an air conditioner isn't exactly cheap. So, if you forget yours on when leaving for a few days, you might put a dent in your wallet. That's why I wanted a system that allows me to monitor and control mine remotely.
Similarly to other projects, an ESP8266 is used to provide wirless communication to the system. I went for a Wemos D1 mini because it provides enough memory and GPIOs for this application as well an on-board USB port for power and serial debugging. The ESP8266 is setup so as to communicate to the home automation hub via MQTT, implemented using Marvinroger's Async MQTT client. Additionaly, its firmware can be updated over the air (OTA) so it doesn't have to be connected to a PC each time.
Since my air conditioner is rented with the apartment, permanent modifications were not an option. Moreover, the only apparent way to control the unit is by infrared, using the provided remote controller. Thus, I decided to attach an IR emitter (IR LED) close to the air conditioner's IR receiver and get the ESP8266 to drive it so it sends commands in the same way as the original remote.
I recorded a few of the signals of the original remote controller with an IR receiver connected to an arduino running a sketch provided by AnalasIR. The IR signals consist of pulses and pauses of varying lengths and I followed perhof's guide to decode them. The first pulse and pause are used to initate the communication. Then, the length of the pulses is kept constant at about 400us. The pauses however are either about 1180 us or 380us long, which translate to a binary HIGH and LOW respectively. Converting an IR signal this way yields a sequence of 264 bits or 33 bytes.
By analyzing those 33 bytes for various button presses of the remote, the following can be identified:
- starting from byte 3 (indexing starting at 0), every even byte is the bitwise NOT of the previous one.
- Temperature is stored in reverse order on 5 bits starting at bit 106.
- The operation mode (colling, heating) is stored on 3 bit starting at bit 204.
- The fan speed is defined by bits 200 to 202
- Bit 220 defines wether the air conditioner should be turned on or off.
Using this information, any desired settings can be encoded into a binary sequence and sent to the air conditioner with the IR emitter using the ESP8266.
- Wemos D1 Mini
- HC-SR501 PIR sensor
- DHT22 temperature and humidity sensor
- Infrared LED
- NPN transistor
Code Available on GitHub.