Reading Modbus Registers only works with SW "Modbus Poll"

Hi!

I am a newbee to the modbus topic and ran into an problem, where I do not have any clue how to go on.

I want to read my Heating System Control Device Danfoss ECL Comfort 210 and later transfere the results to my Smart Home System.
The documentation for the communication to the Danfoss System can be found here.

I got an Modbus USB to RS485 Converter with FT232RL Chip, connected the cables and run an test with my windows computer.
Here I was using the software "Modbus Poll" and I was able to read the holding registers.

Settings (as can be read from the Danfoss document):
Serial
38400 Baud
8 Data bits
Even Parity
1 Stop Bit

If I connect the converter to my Smart Home System (Homeassistant) and set the integration up, I am not getting any response, nevertheless the settings are the same (at least appearing to me). Homeassistant is using the pymodbus library.

Also I tried a Modbus TCP Gateway. I connected "Modbus Poll" via TCPtoRTU. Also here I am not getting any responses.

Any ideas what I am overlooking?

Thanks!
 
Please post screenshots of the communication settings and register definitions you're using successfully in Modbus Poll and also the communication settings and register definitions you have setup in home assistant.

Also, are you sure there are no responses at all? Could the device be returning an error response?
 
As I thought it was an Homeassistant Bug, I already reported this issue here

Modbus Poll
IMG_4707.jpeg
IMG_4708.jpeg

HomeAssistant:
IMG_4706.jpeg

The Debug Logs from pymodbus in Homeassistent say, that there is no response.
IMG_4709.jpeg

@jschulze: Thanks for looking into this
 
The request packets seem to be identical, so your slave and register addressing settings match.

My guess is it's either a timing issue, or perhaps your USB to RS-485 adapter is not actually the /dev/ttyUSB0 device.

Try changing the following to match your Modbus Poll settings:
delay: 0
message_wait_milliseconds: 20
timeout: 1

Does the USB to RS-485 adapter that you're using have transmit and receive LEDs? If so, confirm whether they are blinking when home assistant attempts to send requests.

If possible, you may want to try a Modbus slave simulator software tool with home assistant to confirm the requests are getting out and are using the expected communication settings (baud rate, parity, etc.). Here's the slave version of Modbus Poll:
https://www.modbustools.com/modbus_slave.html
 
Home Assistant appears to be set up to poll two devices at the same slave node ID:
Sensor1 is Slave #1 and Sensor 2 is also Slave #1

If you actually have two slaves with the same slave node ID, and they're both connected, powered and both are on the 485 network, then both will attempt to reply to a message addressed to slave #1, which will create chaos on the bus, disrupt both messages with result being that the master will not receive an intelligible reply and will time out.
 
Home Assistant appears to be set up to poll two devices at the same slave node ID:
Sensor1 is Slave #1 and Sensor 2 is also Slave #1

If you actually have two slaves with the same slave node ID, and they're both connected, powered and both are on the 485 network, then both will attempt to reply to a message addressed to slave #1, which will create chaos on the bus, disrupt both messages with result being that the master will not receive an intelligible reply and will time out.
I only have one slave, direct connection. Modbus address „1“. I just try to read two ready to different holding registers from the same device.
 
I'd try changing the Danfoss hardware to support 8 Data Bits and NO parity. With serial, some chipsets won't support an 11 bit frame (start bit, 8 data bits, stop bit, parity bit).
 
I'd try changing the Danfoss hardware to support 8 Data Bits and NO parity. With serial, some chipsets won't support an 11 bit frame (start bit, 8 data bits, stop bit, parity bit).
Thanks for the hint. Unfortunately in the Danfoss Device only the Baudrate can be changed.
 
The request packets seem to be identical, so your slave and register addressing settings match.

My guess is it's either a timing issue, or perhaps your USB to RS-485 adapter is not actually the /dev/ttyUSB0 device.

Try changing the following to match your Modbus Poll settings:
delay: 0
message_wait_milliseconds: 20
timeout: 1

Does the USB to RS-485 adapter that you're using have transmit and receive LEDs? If so, confirm whether they are blinking when home assistant attempts to send requests.

If possible, you may want to try a Modbus slave simulator software tool with home assistant to confirm the requests are getting out and are using the expected communication settings (baud rate, parity, etc.). Here's the slave version of Modbus Poll:
https://www.modbustools.com/modbus_slave.html
So I did the test.

1. /dev/ttyUSB0 is the Modbus adaptor.
Screenshot 2024-01-23 193052.png

I changed the parameters, to the values suggested.
As soon as the parameters are active, I can see the TXD and RXD starting to blink regularly.
Still the debug from Homeassistant shows not data recieved.

Just to be sure, i reattached the adaptor to my windows PC. Works like a charm with "Modbus Poll" ;)

For setting up the Windows as a slave, I need a second adaptor, right? And then I need to invert A and B at the slave adaptor?
 
Yes, you would need a second USB to RS-485 adapter. But, you never cross-wire RS-485. If you have two of the same adapters, you would connect A to A and B to B.

Note, however, the A and B labeling on RS-485 devices is not standardized. Some vendors use A for the RS-485 + signal and B for the RS-485 - signal, while others use B for the RS-485 + signal and A for the RS-485 - signal.

Additionally, you should also have a 3rd wire connected for the signal common (i.e. 0V ground reference). If you do not have this connection, it could explain why communications is not working with home assistant, due to differing local ground references.
 
As soon as the parameters are active, I can see the TXD and RXD starting to blink regularly.
Still the debug from Homeassistant shows not data recieved.
As a test, do both the TXD and RXD LEDs blink when home assistant attempts to communicate, even when you have the Danfoss device disconnected or powered off?

If not, the fact that both TXD and RXD are flashing means the Danfoss device is responding. Perhaps it is responding too fast and responding while home assistant is still driving the RS-485 bus, causing its responses to be corrupted.

Does the Danfoss device have any type of Response Delay setting? If so, try setting that to 100 or 200 milliseconds to see if that resolves the issue.
 
As a test, do both the TXD and RXD LEDs blink when home assistant attempts to communicate, even when you have the Danfoss device disconnected or powered off?

If not, the fact that both TXD and RXD are flashing means the Danfoss device is responding. Perhaps it is responding too fast and responding while home assistant is still driving the RS-485 bus, causing its responses to be corrupted.

Does the Danfoss device have any type of Response Delay setting? If so, try setting that to 100 or 200 milliseconds to see if that resolves the issue.
So if nothing is connected, only the TXD LED is blinking, when Homeassistant is sending the request.
Unfortunately I really only can change the Baudrate for the Danfoss Device.
 
Yes, you would need a second USB to RS-485 adapter. But, you never cross-wire RS-485. If you have two of the same adapters, you would connect A to A and B to B.

Note, however, the A and B labeling on RS-485 devices is not standardized. Some vendors use A for the RS-485 + signal and B for the RS-485 - signal, while others use B for the RS-485 + signal and A for the RS-485 - signal.

Additionally, you should also have a 3rd wire connected for the signal common (i.e. 0V ground reference). If you do not have this connection, it could explain why communications is not working with home assistant, due to differing local ground references.
I simulated the Slave on my PC with the "Modbus Slave" and the value at the holding register was read successfully with Homeassistant.

It looks like it is an timing issue, but I have no idea where in Homeassistant I could change the parameters in detail to make this work out
 
OK, that's good news then. As I said, if both TXD and RXD LEDs are blinking when the Danfoss device is connected, that means communications is 90% working - the request from home assistant is getting to the Danfoss device and the Danfoss device is responding. This means all communication settings (i.e. baud rate, parity, address, etc.) are correct and the request sent by home assistant is a valid request (since the Danfoss is responding).

Here's something you can try that might shed some more light on the problem. Connect both your PC and the Danfoss device to home assistant. Download and run a serial port analyzer tool such as one of the following:
https://ioninja.com/
https://freeserialanalyzer.com/screenshots
Capture the Modbus communications between home assistant and the Danfoss device using the analyzer tool and post the results back here.

If the issue is due to home assistant driving the bus for too long after send a request, and there are no response delay settings in the Danfoss device and no post-drive timing parameters in home assistant (which would be unlikely anyway), you may be able to put an RS-485 repeater between home assistant and the Danfoss device to solve the issue, such as one of the following:
https://www.commfront.com/collectio...ter-extender-converter?variant=39593903489121
https://www.advantech.com/en-us/pro...4510/mod_30aee6b2-329f-498d-a4ee-b2c5b8921ae7
https://www.dfrobot.com/product-2278.html
 
I don't think the Delay setting in Home Assistant will make any difference, as it only applies to the very first request sent, and seems to exist more for Modbus/TCP devices than Modbus RTU devices.

From the Home Assistant Modbus documentation:
delay integer (Optional, default: 0)

Time to delay sending messages in seconds after connecting. Some modbus devices need a delay of typically 1-2 seconds after connection is established to prepare the communication. If a device does not respond to messages after connecting, then try this parameter. Remark: solely affect the first message.
 
OK, that's good news then. As I said, if both TXD and RXD LEDs are blinking when the Danfoss device is connected, that means communications is 90% working - the request from home assistant is getting to the Danfoss device and the Danfoss device is responding. This means all communication settings (i.e. baud rate, parity, address, etc.) are correct and the request sent by home assistant is a valid request (since the Danfoss is responding).

Here's something you can try that might shed some more light on the problem. Connect both your PC and the Danfoss device to home assistant. Download and run a serial port analyzer tool such as one of the following:
https://ioninja.com/
https://freeserialanalyzer.com/screenshots
Capture the Modbus communications between home assistant and the Danfoss device using the analyzer tool and post the results back here.

If the issue is due to home assistant driving the bus for too long after send a request, and there are no response delay settings in the Danfoss device and no post-drive timing parameters in home assistant (which would be unlikely anyway), you may be able to put an RS-485 repeater between home assistant and the Danfoss device to solve the issue, such as one of the following:
https://www.commfront.com/collectio...ter-extender-converter?variant=39593903489121
https://www.advantech.com/en-us/pro...4510/mod_30aee6b2-329f-498d-a4ee-b2c5b8921ae7
https://www.dfrobot.com/product-2278.html
As I set up the new test, I changed the cables so I can work more comfortably.
Now the communication between Homeassistant and Danfoss works :)
Seems like "Modbus Poll" has some kind of error handling?!

Thanks you @jschulze @David_2 and @RonDawson for finding the root cause :)
Have a nice evening!
 
I doubt Modbus Poll has any special error handling, nor would any other master. Something else is probably going on here.

Just to confirm the root cause, what exactly did you do to resolve the issue? You said you changed the cables, I assume that means you got new cabling. What's different about the new cabling? For example, longer, shorter, additional conductors, etc.? Did you make any new connections, such as connecting the ground wire between Home Assistant and the Danfoss? Does it only work when both USB to RS-485 converters are connected to the bus? Did you change how you're powering any of the equipment?
 
I changed the cable, which was connected to the Danfoss slave.
I used 3x0,8mm² flexibel instead of an Ethernet cable. Lenght is roughly the same. No new connections, there were always A/B/GND connected. Connection now works with only one USB to RS-485 connected to the bus. No change in the powering.
 
Top