03-31-2023, 04:55 AM
I have use KC868-A16 work with KC868-H32BS by RS485 cable via modbus.
I edit config files. mainly command at here:
uart:
id: mbus
tx_pin: GPIO13
rx_pin: GPIO16
baud_rate: 9600
modbus:
id: modbus1
uart_id: mbus
send_wait_time: 200ms
modbus_controller:
- id: h32bs
address: 1
modbus_id: modbus1
update_interval: 3s
switch:
- platform: modbus_controller
name: 'modbus-switch1'
address: 0 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1
ESPHome_A16_modbus_relay.txt (Size: 6.5 KB / Downloads: 227)
this is a demo , i have created one switch button in ESPHome, you can create many others.
H32BS use modbus command:
01 05 00 00 FF 00 turn on relay1
01 05 00 00 00 00 turn off relay1
make sure your relay board as these:
ON = 0xFF00 OFF=0000
if your relay board not use by this protocol. you can also write esphome as "write_lambda" way. i have tested, "write_lambda" to create switch also work fine. just need to create ON and OFF two command.
I edit config files. mainly command at here:
uart:
id: mbus
tx_pin: GPIO13
rx_pin: GPIO16
baud_rate: 9600
modbus:
id: modbus1
uart_id: mbus
send_wait_time: 200ms
modbus_controller:
- id: h32bs
address: 1
modbus_id: modbus1
update_interval: 3s
switch:
- platform: modbus_controller
name: 'modbus-switch1'
address: 0 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1
ESPHome_A16_modbus_relay.txt (Size: 6.5 KB / Downloads: 227)
this is a demo , i have created one switch button in ESPHome, you can create many others.
H32BS use modbus command:
01 05 00 00 FF 00 turn on relay1
01 05 00 00 00 00 turn off relay1
make sure your relay board as these:
ON = 0xFF00 OFF=0000
if your relay board not use by this protocol. you can also write esphome as "write_lambda" way. i have tested, "write_lambda" to create switch also work fine. just need to create ON and OFF two command.