Logic Machine Forum
Haier air conditioner - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Haier air conditioner (/showthread.php?tid=4458)



Haier air conditioner - a455115 - 21.12.2022

Hello, everyone.

I have a Haier air conditioner that I want to control through its RS 232 port. I found a description of how to make an MQTT device with an ESP 8266, but I don't want it to go over wifi. I can't convert RS 232 commands myself so please help. I am attaching the code with the commands for arduino, how to convert them for LM to reduce Wi-Fi devices. Please if anyone can and has the necessary time - I would be grateful for any help.

GitHub


RE: Haier air conditioner - admin - 21.12.2022

It won't work directly via RS232. You will need RS232 - TTL 5V converter and some soldering as the AC uses USB port for serial communication.
The command format is described here: https://blog-instalator-ru.translate.goog/archives/433?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp


RE: Haier air conditioner - a455115 - 22.12.2022

(21.12.2022, 09:57)admin Wrote: It won't work directly via RS232. You will need RS232 - TTL 5V converter and some soldering as the AC uses USB port for serial communication.
The command format is described here: https://blog-instalator-ru.translate.goog/archives/433?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp

Yes, that's clear, but I wanted to use the LM directly with a USB to TTL converter.


RE: Haier air conditioner - admin - 23.12.2022

Example of sending data packets:
Code:
port = require('serial').open('/dev/ttyUSB0', { baudrate = 9600 })

function send(...)
  local data = string.char(...)
  local len = #data + 1
  local hdr = string.char(0xFF, 0xFF, len)
  local csum = len

  for _, byte in ipairs({ ... }) do
    csum = bit.band(csum + byte, 0xFF)
  end

  local pkt = hdr .. data .. string.char(csum)
  port:write(pkt)
end

send(0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x4D, 0x02) -- turn on
send(0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x4D, 0x03) -- turn off
send(0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x4D, 0x01) -- request state



RE: Haier air conditioner - a455115 - 23.12.2022

Thank you so much! I'll try these days that I'm not at the air conditioner right now.

As always great admin!
Merry Christmas and New Year holidays!