HVAC control by mqtt message

01.06.2020

ESP8266 is one of my favourite microcontrollers so far. It offers good connectivity at reasonable price. Since the introduction of arduino ecosystem, developers have released many libraries of which you can easily use in your projects (usually with slight modifications). After getting familiar with these tools, you can’t help noticing the possibilities it opens.

I have “old” air condition unit from Mitsubishi, that offers no wifi connectivity (only IR). Since all of my home appliances were already running top of raspberry pi and node-red, it was only natural step to embed this to the system. We shall call this device “interface unit” or later abbreviation “IU”.

Mitsubishi kirigamine HVAC, running since 2008.

Communication between HVAC and interfaceunit is Mitsubishi IR protocol. Interface unit communicates outside with Node-red using MQTT-messages on top of wireless network (WLAN).

How data flows: We can control HVAC unit through internet. Raspberry is running nodered and Mosquitto MQTT broker. Our DIY Interface unit is connected to home network and is directly controlling the HVAC via remote control emulation.

Powering the IU (interface unit) is possible either using regular mini-usb , or battery. I decided to go with 18650 lithium cell powered solution since they allow cordless assembly and mobility (for easier upgrades / modifications). Also battery seems to last quite long. (I change battery always when cleaning the unit)

Hardware is build on top of commercially available solution. Unit is know by name “ESP-wroom”.

ESP-WROOM (ESP8266, battery version)

For IR-communication (to send only), we need a proper IR-diode. I found something from my drawer that suits this purpose. Treshold voltage for my chosen diode was 1,8V, and ESP is able to supply 3.3V (with 20mA current). With 75 ohm resistor we should be OK. Also using dedicated transistor would be preferred solution, but maybe later. Our shield is connected to ESP-Wroom by using pin header with 2.54mm pin spacing.

Our DIY “shield” installed on top of ESP-wroom.

Using small slice of raster pcb, hardware was ready in it’s crude form. Simple blink program up and running, and in no time, I was able to confirm working IR (using my smart phone camera to visualise IR).

Next part is all about getting IR signals from existing handheld remote control unit. For this purpose, I purchased a license for AnalysIR -software, that we are using to detect signals and define protocol being used by the transmitter. You can use existing arduino libraries and build your own receiver without this software, but I decided to support the developer.

AnalysIR has more than enough protocols, so we should be covered. We will need need IR-receiver unit-tool, which can be built from ESP8266 with supplied firmware from AnalysIR and simple IR-receiving-module. It is connected with USB cable to PC. It also supports WiFi -connectivity, but I had problems getting it working.

Custom 3D-printed case hides the nasty wiring job, this will do for now. After cycling thru all the main functions from remote control, I was able to track which bytes were changing at each time. Last byte was checksum (sum of all bit values in hex), so it needs to be calculated in the microcontroller before each transmission takes place. AnalysIR really saved a lot of time, right tool for the job. We could have just copied raw signal stream, but now we can precisely control only the bytes that are needed.

I also tried battery saving function where ESP deep sleeps for 1 minute at a time, and then fetches MQTT -messages from node-red server, and sends only changes, if neccessary. This of course makes system less responsive, but works well in home automation since there is no need for immediate action (temperature control). It is really matter of taste, which direction you go with this one.

At the moment my system is running on batteries and deepsleep, which seem to serve its purpose.

This project was quite educational and had many plot twists on the way. Like all projects, they are just playground to endless experimentation. Hope you got some ideas and can reuse atleast some part of it. Please send questions if you are stuck with it.

Parts used in this project:

ESP-wroom microcontroller module (battery version)

breadboard / protoboard

IR-LED

Wemos D1 mini (for IR-decoding)

IR-receiver module (for IR-decoding)

Raspberry Pi 3

Mitsubishi MSZ-FA35VA

Software used in this project:

AnalysIR

Arduino IDE

Raspberry OS

Mosquitto MQTT

Node-red