Smart Home Automation Forum
KC868-A16 work with relay board by RS485 modbus in ESPHome - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A16 (https://www.kincony.com/forum/forumdisplay.php?fid=25)
+--- Thread: KC868-A16 work with relay board by RS485 modbus in ESPHome (/showthread.php?tid=2754)

Pages: 1 2


KC868-A16 work with relay board by RS485 modbus in ESPHome - admin - 03-31-2023

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: 545)


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - sucaeddin - 04-22-2023

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?


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - admin - 04-23-2023

can you draw a photo, what do you want to do? no any relay controller connected?


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - sucaeddin - 04-23-2023

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.


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - admin - 04-23-2023

do you want to use ESP32 tuya adapter connect to your own relay board by modbus protocol?


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - sucaeddin - 04-23-2023

(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...!


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - admin - 04-23-2023

ok, you need to modify ESP32 arduino code, replace KinCony's protocol with your board's.


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - sucaeddin - 04-23-2023

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.php?tid=2316&highlight=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


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - admin - 04-24-2023

this need test, debug with your board.


RE: KC868-A16 work with relay board by RS485 modbus in ESPHome - Dario - 07-11-2023

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