Mitsubishi Electric AC (air condition unit) and ATW (air to water unit) control by UART using amasing IoT platform - Mongoose OS
Inspired by great research made by Hadley Rich from New Zealand and SwiCago, who sorted all out and made an Arduino implementation and tutorial
The protocol was sniffed from original Mitsubishi MAC-567IF-E
controller:
Mitsubishi indoor unit's control board has CN105 (RED) connector for communication purposes. The communication performed by UART @ 2400 8E1 (5V TTL). The CN105 connector pinouts (1..5) = 12V, GND, 5V,TX, RX
There are UART0
and UART2
available for this board
All model coming with CN105 on an indoor unit's board, except PCA-RP71HAQ, PEA-RP400GAQ and PEA-RP500GAQ
More details available on MELCloud and KumoCloud pages
IMPORTANT: When mounting the MEC-AC
unit inside an indoor unit, refer to the installation manual of the indoor unit.
Do not mount the Interface unit inside the indoor unit, if not mentioned
AC
's indoor unit mount:
ATW
's indoor unit mount:
"mel_ac": {
"enable": true, // Enable MEL-AC library
"uart_no": 0, // UART number
"uart_baud_rate": 2400, // Do not change this, unless required
"period_ms": 250, // Packets handler timer, ms
"rpc_enable": true // Enable MEL-AC RPC handlers
}
If RPC is present in your project, MEL-AC will add it's command handlers: MEL-AC.GetParams
and MEL-AC.SetParams
$ mos --port mqtt://192.168.1.9/esp32_585E14 call RPC.list
[
"MEL-AC.SetParams",
"MEL-AC.GetParams",
"Sys.SetDebug",
"Sys.GetInfo",
"Sys.Reboot",
"RPC.Ping",
"RPC.Describe",
"RPC.List"
]
$ mos call --port ws://192.168.1.216/rpc MEL-AC.GetParams
{
"connected": true,
"power": 0,
"mode": 3,
"setpoint": 21.0,
"fan": 3,
"vane_vert": 0,
"vane_horiz": 3,
"isee": true,
"operating": false,
"room": 25.0
}
http://192.168.1.216/rpc/MEL-AC.GetParams
{"connected": true, "power": 0, "mode": 1, "setpoint": 20.0, "fan": 2, "vane_vert": 0, "vane_horiz": 3, "isee": true, "operating": false, "room": 22.0}
$ mos --port mqtt://192.168.1.9/esp32_585E14 call MEL-AC.GetParams
{
"connected": true,
"power": 0,
"mode": 3,
"setpoint": 21.0,
"fan": 3,
"vane_vert": 0,
"vane_horiz": 3,
"isee": true,
"operating": false,
"room": 25.0
}
$ mos call --port ws://192.168.1.216/rpc MEL-AC.SetParams '{"mode":1,"fan":2,"setpoint":20}'
{
"success": true,
"power": 0,
"mode": 1,
"setpoint": 20.0,
"fan": 2,
"vane_vert": 0,
"vane_horiz": 3
}
$ curl -d '{"mode":1,"fan":2,"setpoint":20}' 192.168.1.216/rpc/MEL-AC.SetParams
{"success": true, "power": 0, "mode": 1, "setpoint": 20.0, "fan": 2, "vane_vert": 0, "vane_horiz": 3}
$ mos --port mqtt://192.168.1.9/esp32_585E14 call MEL-AC.SetParams '{"power":1,"mode":1,"fan":2,"setpoint":20}'
{
"success": true,
"power": 1,
"mode": 1,
"setpoint": 20.0,
"fan": 2,
"vane_vert": 0,
"vane_horiz": 3
}
The library init makes a timer is set up at mel_ac.period_ms
milliseconds intervals to handle the device.
The handler quering the HVAC params in a loop and sends new params when there are changes happen.
Library triggering events as follows:
MGOS_MEL_AC_EV_INITIALIZED
: when the service initialized successfullyMGOS_MEL_AC_EV_CONNECTED
: whenconnected
state changed. New state goes to*ev_data
MGOS_MEL_AC_EV_PACKET_WRITE
: after packet sent to HVACMGOS_MEL_AC_EV_PACKET_READ
: after new packet has been read from HVACMGOS_MEL_AC_EV_PACKET_READ_ERROR
: when there was a problem in packet from HVACMGOS_MEL_AC_EV_PARAMS_CHANGED
: when new changed params loaded from HVACMGOS_MEL_AC_EV_ROOMTEMP_CHANGED
: when room temperature change received from HVACMGOS_MEL_AC_EV_TIMERS_CHANGED
: when timers changed on HVACMGOS_MEL_AC_EV_OPERATING_CHANGED
: when operating state changed on HVACMGOS_MEL_AC_EV_PARAMS_SET
: when new params successfully set to HVACMGOS_MEL_AC_EV_TIMER
: before every service timer handler runningMGOS_MEL_AC_EV_CONNECT_ERROR
: when handshake packet returned error
void mgos_mel_ac_get_params(struct mgos_mel_ac_params *params);
bool mgos_mel_ac_set_power(enum mgos_mel_ac_param_power power);
bool mgos_mel_ac_set_mode(enum mgos_mel_ac_param_mode mode);
bool mgos_mel_ac_set_setpoint(float setpoint);
bool mgos_mel_ac_set_ext_temp(float temp);
bool mgos_mel_ac_set_fan(enum mgos_mel_ac_param_fan fan);
bool mgos_mel_ac_set_vane_vert(enum mgos_mel_ac_param_vane_vert vane_vert);
bool mgos_mel_ac_set_vane_horiz(enum mgos_mel_ac_param_vane_horiz vane_horiz);
void mgos_mel_ac_set_params(struct mgos_mel_ac_params *params);
Setters return false
in case of invalid argument value
It's currently tested on ESP8266 and ESP32 platforms
For a complete demonstration of the driver, look at this Mongoose App
Larger project is mel-ac-homekit
A sample case 3D design for WiFi-NodeM: