Modbus in Node-red add-on not working

Hi.I tried to connect to my Waveshare RS485 to ETH converter via Modbus, but it failed giving me the error message: “Error: listen EADDRNOTAVAIL: address not available 192.168.67.7:502”.
!

Also tried with Modbus-Read, there’s giving me the error: “Error: Client Not Ready To Read At State init”
I tried to read data from the device,and it’s working with Modbus TCP(Modbus Poll, and the Waveshare company provided tester software) with the same IP and Port. Any ideas? Thanks!

I wonder if you are trying to connect a server to a server? Your picture shows you are working with a Modbus-Server-node which will almost certainly not do what you want.

This server node is really used just for testing. Your end device on the RS485 side of the adaptor is a slave/server which responds to requests from your Node-RED program, acting as a master/client. The ‘modbus server node’ is used only to test other master/clients (by responding to Modbus requests, not making them).

If you are using a Modbus-Read node, then that has to be set up with the correct device/register details. It also needs a Modbus-Client configuration node. In Node-RED the configuration nodes act as connector between the flow nodes and the outside world. If your Modbus-read node has a ‘client server’ configuration node setup with the correct details, then the node status would show ‘active’ and not ‘initialized’. The status suggests that the Modbus configuration node is not connecting correctly.

This the the Modbus Read node settings. The unit id (usually 1) and the FC (3 or 4 for the register type) must be set, along with the register address according to the Modbus register of the end device you are trying to connect to.

Some confusion may arise because, in the Modbus-read node UI setup, it requires a ‘server’, which is actually the configuration node. This is a Modbus-client node, because it acts as a client (master) to the external device. This node then acts as a local server to the flow node. You only need to set up the one Modbus-Client node (connected to your adaptor) which is then used by all the Modbus nodes to connect to the adaptor.

Here is my Modbus-Client node. This is set up to talk to my adaptor - it needs the adaptor IP and port (in your case port will be 502) and for TCP type default. This node then establishes a connection to the adaptor.

Any Modbus node can then send Modbus commands to this ‘server’ acting as a client node, which then uses Modbus over TCP to send them to the adaptor, which then turns that into Modbus over serial commands for the end device. In all of this, the Node-RED program flow is acting as the client, and the end device is acting as a server. The two bits in the middle are, like a plug and socket extension lead, acting as both server-client. The config node is server to the Node Red Modbus Read, and client to the adaptor, and the adaptor is a server to the config node, and client to the end device (which is a server).

I hope this makes sense and it helps you set up your Modbus-Read and a Modbus-Client node correctly.

2 Likes