MHI2MQTT

Arduino-based communication interface for Mitsubishi Heavy Industries (MHI) SRK/SRF series air conditioners. It will likely work for more models but I am not able to test this. Connects to the MHI CNS connector and synchronizes to its Serial Peripheral Interface (SPI). Updates from the MHI are sent via serial to an ESP8266 running an MQTT client. Updates received on the ESP8266 via MQTT are sent to the Arduino over serial and injected into the SPI data frames to update the MHI.

Getting started

The provided code is not a library, but is rather intended as a ready-to-use firmware solution for wirelessly controlling the aircon via MQTT using an Arduino Pro Mini/ESP8266 combination.

Circuit and connector

Connection scheme

I would like to advise you to not solder a fixed connection between the Arduino and ESP-01. Using male and female pin headers for the connection (see figure above) will enable you to easily upload updates the Arduino at a later stage.

The CNS socket on the MHI indoor unit’s PCB accepts a JST-XH 5-pin female connector. It can be bought pre-wired as a 4S LiPo balance cable. In addition, I use a prefab male-to-female version of this cable as an extension cord.

JST-XH pin layout (looking at the male socket on the PCB with the locking protrusions/slots downwards):
Pin 1 (left) = 12V, pin 2 = SPI clock, pin 3 = SPI MOSI, pin 4 = SPI MISO, pin 5 (right) = GND.

Check before connecting with a multitester. GND versus clock should be +5V. If the voltage over outer pins is -12V then connector orientation is wrong. Pins 2 - 5 are 5V and directly compatible with an Arduino Pro Mini 5V/16 MHz version. Note that the 3.3V/8MHz version is NOT directly compatible and logic level conversion is necessary. The 8 MHz is possibly to slow to keep up with SPI communication and data processing, although I didn’t test this.

The Arduino Pro Mini is 12V tolerant according to its specs, but using the 12V (pin 1) of the MHI unit did not work in my setup. I use a Pololu D24V5F5 step-down voltage regulator to power both the Pro Mini and the ESP8266.

Oh, and while you’re at it, take out the two LEDs on the Arduino. They are ridiculously bright. Really, the light will pass through the plastic casing and will light up your aircon like it’s Christmas all year. It’s better to use a soldering iron to do this (find good instructions on YouTube). Do not start cutting the LEDs traces as you will likely damage traces underneath.

After soldering and uploading the firmware, I wrapped the entire contraption in shrink wrap to fix all the (re)movable parts and protect against causing possible short-circuits while installed in the aircon.

Contraption

Parts

Installation

Dependencies

The following additional libraries are necessary and should be added to the Arduino IDE before compiling and flashing the sketches:

Installing the sketches

Two sketches are provided:

Arduino IDE settings

Once the sketch is flashed for the first time, future updates to the ESP-01 can also be uploaded OTA. Name and password are equal to those set for the configuration access point (Default: MHI Roomname with password mitsubishi). The Arduino Pro Mini cannot be updated OTA.

Connecting and configuring the system

The system will connect to the selected WiFi network and the MQTT broker. You can quickly check if everything works by using the command line to temporarily subscribe to the relevant topics: Roomname/Aircon/#. If all is well, a successful connection will be notified on the debug topic. Within ~10 seconds after connection, the aircon’s current settings will be sent to the status topics. From now on, sending payloads to the topics (see table below under Wireless operation using MQTT) should cause the aircon to respond within max. 2 seconds. All successful commands will be acknowledged by the aircon on the respective status topic.

* Google for a service manual of your aircon model for instructions on how to get access to the CNS connector. The image below is of an SRK50ZS-S where I extended the CNS connector from the more difficult-to-reach side panel to the front mains connection box for easy access. Please switch off the mains before doing this and take care that the module is properly isolated (e.g. shrink wrap) and fixed with a cable tie so it can’t touch the high-voltage terminals.

Installed

Wireless operation using MQTT

The table below shows the topics and respective value range that can be used to operate the aircon:

MHI2MQTT Topics & Values

The default topic statusRoomtemp will be updated with the ambient temperature (in degrees Celsius) every ~6 seconds.
Various service commands can be send to the service topic and the system will respond as follows:

MHI2MQTT Service commands

Behavior when the WiFi network or MQTT broker is down

Notes

Details about the communication protocol

Notes on handling SPI communication in the code

The Arduino Mini Pro had problems staying in sync with the aircon’s SPI data during the early test phase. To solve this, a state machine type of approach was chosen to prevent the SPI interrupt routine from being obstructed (by e.g. UART serial communication with the ESP-01) until a full 20-byte is received (state 0). Then, two states are possible: one to update frames, calculate checksums and send values obtained from the aircon to the ESP-01 (state 1); and one where the serial connection is checked for data arriving from the ESP-01 (state 2). When debugging is enabled using the service command debugon, the debug topic will provide a cumulative count of the number of SPI synchronisation errors (until a reboot/reset). I never ran into sync issues anymore since I started using the state machine approach, so this debugging feature is obsolete unless you want to test the sketch on other Arduino boards.

Acknowledgments

This work would not have been possible in the current form without the ingenious work of others: WiFiManager by Tzapu, PubSubClient by Nick O’Leary, EasyTransfer by Bill Porter and ArduinoJson by Benoît Blanchon. In addition to using these libraries, parts of the code were obtained from the example sketches.

License

This project is licensed under the terms of the MIT license.