![]() |
RS485 not receiving anything - 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: RS485 not receiving anything (/showthread.php?tid=2748) |
RS485 not receiving anything - victorclaessen - 03-28-2023 Hi, I have the A16 wired up to a RS485 expansion board (16 inputs, 16 outputs) that is controlled by modbus RTU. I have the ESP32 programmed with ESPHome. I can send commands to the expansion board, and I have control over the outputs (I see the onboard output-LEDs toggling), and I can see from the onboard communication LED on the expansion board that the expansion board sends a modbus response, but the ESP32 on the A16 does not receive anything on pin 16 (485RX). I have verbose logs activated on the UART defined in ESPHome. I can see the raw bytes leaving on pin 13 (485TX), but no bytes are arriving on pin 16. Obviously, I also cannot read the inputs of the expansion board (as that would require receiving the modbus response). Are you sure that the RX pin number is correct? Could it be that I have a broken pcb trace? Best regards, Victor P.S. Below is the relevant part of the esphome configuration Code: logger: RE: RS485 not receiving anything - admin - 03-29-2023 i will test RS485 with a relay board, later feedback to you. RE: RS485 not receiving anything - victorclaessen - 03-29-2023 Thanks. FYI: I'm using this board https://www.aliexpress.com/item/1005003432158161.html Modbus command reference attached in zip file. RE: RS485 not receiving anything - admin - 03-31-2023 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 ![]() 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. RE: RS485 not receiving anything - victorclaessen - 03-31-2023 Hi, Thanks for testing this! In my case, the device represents the inputs/outputs as registers, not coils. I used the write_lambda in debugging the problem to make sure that I get the correct modbus command (which I know is now correct because the output actually toggles). Have you checked if you can also read the inputs from the KC868-H32BS via RS485? The weird thing in my case is that nothing comes in on the UART. Can you confirm that if you add this code to the UART definition in esphome, that you then can see incoming messages in addition to the outgoing messages? Code: logger: RE: RS485 not receiving anything - admin - 03-31-2023 read the "inputs" from the KC868-H32BS via RS485? the "INPUTs" means digital input? or you want to read OUTPUT relay state? RE: RS485 not receiving anything - victorclaessen - 03-31-2023 I meant 'digital input', yes. But reading back the OUTPUT relay state is a similar test, because that also requires the reception of a modbus reply. RE: RS485 not receiving anything - admin - 03-31-2023 about OUTPUT relay state update, just use by these config. that means every 3 seconds refresh OUTPUT status for home assistant dashboard. you can change the interval time. modbus_controller: - id: h32bs address: 1 modbus_id: modbus1 update_interval: 3s RE: RS485 not receiving anything - victorclaessen - 04-11-2023 Hi, It took me a while to source an RS485-USB adapter. Now I can see follow the communication between the A16 and the expansion board. Physically, I can confirm that the A16 sends a request: 01 03 00 01 00 01 d5 ca And that the expansion board sends a response: 01 03 02 00 01 79 84 That totally makes sense. But in the esphome log I confirm see that the response is not received by the UART (and therefore not handled by esphome). Code: 14:47:01 [V] [modbus_controller:036] Sending next modbus command to device 1 register 0x01 count 1 Also, with a modbus test program (CAS Modbus Scanner) I can confirm the working of the expansion board. Reading and writing works. Do you agree that the only remaining conclusion is that there must be something wrong on the board between the RS485 chip and the ESP32 input? RE: RS485 not receiving anything - admin - 04-11-2023 It took me a while to source an RS485-USB adapter. Now I can see follow the communication between the A16 and the expansion board. --> if you can do this, monitor data from A16--> expansion board , and data A16 <-- expansion board. that means ESP32 and RS485 circuit is good. maybe you can change setting of ESPHome's log output level. |