RS485 Modbus RTU Control for Taiwan Hitachi Air Conditioner on MTK Linkit Smart 7688 Duo
You need Taiwan Hitachi air conditioners with RS485 signal transmitters. However, this project should be able to control any Modbus RTU via RS485 with little modification.
This build this project, you need:
- MTK Linkit Smart 7688 Duo
- RS-485 module for Arduino (MAX485)
- RC-RO1XT - Hitachi RS485 Controller
Name | MAX485 Pin | 7688 Pin | Desc |
---|---|---|---|
5V | VCC | 5V | |
GND | GND | GND | |
RS485 A | A | connect to RS485 bus | |
RS485 B | B | connect to RS485 bus | |
MAX485_TX | DI | D17 | |
MAX485_DE | DE | D15 | |
MAX485_RE | RE | D16 | |
MAX485_RX | RO | D14 |
- Download the whole project in zip format from here
- In Arduino, Sketch -> Include Library -> Add .zip library and add the zip file.
By using this library in our Arduino side code, we contrl the Modbus devices by SoftwareSerial.
We talk to the Arduino side by open serial port /dev/ttyS0
.
The OpenWRT side is basically a web service taking REST call and send the request to Arduino side.
The basic operation is to control the Modbus devices by web service calls.
The Modbus devices takes four parameters:
- Slave Address
- In Modbus protocol topography requires each units on the bus to have a unique id (an integer value).
- This id is set (by jumper) in the RC-RO1XT, the Hitachi RS485 Controller.
- Function Code
- 0x03 -> Read
- 0x06 -> Write
- Resgister Address
- Resgister Value
Resgister Address | Item | Resgister Value |
---|---|---|
0x00 | Current Temperature | Celsius (Read Only) |
0x20 | Power | 0: OFF 1: ON |
0x21 | Operational Mode | 0: Cooling 1: Dehumidify 2: Fan Only 3: Auto 4: Heating |
0x22 | Fan Speed | 5: Auto 4: High 3: Mid 1: Low 7: Quiet |
0x23 | Target Temperature | Range 16℃ - 32℃ |
0x24 | Sleep Mode | 0: OFF Others: minutes in sleep mode (1~1440) |
0x25 | Fuzzy Mode | 0: OFF 1: ON |
0x29 | Auto On/Off Timer | 0: OFF Others: minutes (1~1440) |
0x2A | Air Flow Up/Down | 0: OFF Others: angle |
0x2B | Air Flow Left/Right | 0: OFF Others: angle |
0x2D | Remote Control On/Off | 0: Enable 1: Disable |
0x2E | Beeper On/Off | 0: Enable 1: Disable |
Request
curl -X GET http://<ip-address>:8080/2/0x00
Response
{ "value": 24 }
Request
curl -X GET http://<ip-address>:8080/2/0x20
Response
{ "value": 0 }
curl -X PUT -H "Content-Type: application/json" -d "{\"value\": 1}" http://<ip-address>:8080/2/0x20
- https://github.com/4-20ma/ModbusMaster
- https://github.com/openopen114/Arduino_Modbus_viaRS485/blob/master/ArduinoCode/ModbusMaster_viaRS485/ModbusMaster_viaRS485.ino
Yu-Hua Chang
MIT