Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-A16 work with relay board by RS485 modbus in ESPHome
#1
use KC868-A16 work with KC868-H32BS by RS485 cable via modbus.

this is a demo , i have created one switch button in ESPHome, you can create many others.

KC868-H32BS use modbus command:
01 05 00 00 FF 00  CRC turn on relay1
01 05 00 00 00 00  CRC 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.

   
   
yaml files for KC868-A16 work with modbus switch:

.txt   ESPHome_A16_modbus_relay.txt (Size: 6.5 KB / Downloads: 540)
Reply
#2
I have a KinCony ESP32 Tuya IoT adapter module. Is there a library you would recommend to use as modbus_switch in home assistant? My aim is to use it as a gateway between home assistant and TUYA. Is it possible?
Reply
#3
can you draw a photo, what do you want to do? no any relay controller connected?
Reply
#4
There are 32 buttons on the KinCony ESP32 Tuya IoT adapter module that we can control from TUYA. I want to introduce them as Home assistanta modbus_switch. It will be as if the module has a virtual relay. When I open switch_1 from Modbus, I will see that it is opened from the TUYA application. The KinCony ESP32 Tuya IoT adapter module already has rs485 hardware. But I am trying to add the modbus code.
Reply
#5
do you want to use ESP32 tuya adapter connect to your own relay board by modbus protocol?
Reply
#6
(04-23-2023, 02:51 AM)admin Wrote: do you want to use ESP32 tuya adapter connect to your own relay board by modbus protocol?

YES...!
Reply
#7
ok, you need to modify ESP32 arduino code, replace KinCony's protocol with your board's.
Reply
#8
Yes, I will modify the ESP32 Tuya IoT adapter module software. I changed the program before with your help. https://www.kincony.com/forum/showthread...light=TUYA
I am using RS485 in that article. But now I am trying Modbus protocol. In the Arduino IDE. I've used several modbus libraries. I couldn't decide which one is the best. That's why I asked your suggestion. Thanks
Reply
#9
this need test, debug with your board.
Reply
#10
would this be a correct config with 4 A16 boards?

uart:
id: mbus
tx_pin: GPIO13
rx_pin: GPIO16
baud_rate: 9600

modbus:
id: modbus1
uart_id: mbus
send_wait_time: 200ms

modbus_controller_board2:
- id: a16-Board2
address: 1
modbus_id: modbus1
update_interval: 1s

modbus_controller_board3:
- id: a16-Board3
address: 2
modbus_id: modbus1
update_interval: 1s

modbus_controller_board4:
- id: a16-Board4
address: 3
modbus_id: modbus1
update_interval: 1s

switch:
- platform: modbus_controller_board2
name: 'modbus_board2-switch1'
address: 0 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1c
....


switch:
- platform: modbus_controller_board2
name: 'modbus_board2-switch16'
address: 15 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1

#Board 3

switch:
- platform: modbus_controller_board3
name: 'modbus_board3-switch1'
address: 0 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1c
....


switch:
- platform: modbus_controller_board3
name: 'modbus_board3-switch16'
address: 15 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1

#Board 4

switch:
- platform: modbus_controller_board4
name: 'modbus_board4-switch1'
address: 0 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1c
....


switch:
- platform: modbus_controller_board4
name: 'modbus_board4-switch16'
address: 15 # 0:relay1 1:relay2 ......
register_type: coil
bitmask: 1
Reply


Forum Jump:


Users browsing this thread:
2 Guest(s)