Modbus RTU problem

Hi everyone!

I am using a raspberry pi 3 to read data from a sensor. The communication protocol is modbus rtu. To connect the sensor I am using the adapter of the picture. The nodes I use are "node-red-contrib-modbus 5.16.0".

Everything works perfectly until the raspi reboot. When I reboot the raspi the nodes are unable to reconnect with the sensor. The same problem occurs if I deploy NodeRed again. If I want to reconnect it I have to unplug the usb, go to the server configuration, check that the usb is not in the list, then connect it again and select the correct usb. Has anything similar ever happened to you?

I have try to solve the problem enabling the delay option and setting it with 60s but this does not work... Any help will be appreciated!

Hello .. i use a usb to serial converter also and never had a problem .. im using a RPi4.

The modbus node config is set to

in my setup the device always has the same number (ttyUSB0) since its the only usb device connected.
What about in your setup ? As i see in the screenshot you dont have anything else except the mini hdmi and power usb.

What does ls /dev/ttyUSB* give when the device is running ok and what when you get a disconnect ?

Silly question but have you tried a different usb port also ?

Do you get any modbus related errors in the node-red terminal when the nodes cannot reconnect ?

When is running ok: /dev/ttyUSB0 When got disconnected from node-red: /dev/ttyUSB0 When I disconnected the converter from the raspi: No such file or directory

Yes, I tried all the ports and two converters.

I don't know if this is an error but when I try to active the flow with the modbus node, it got disconnected a moment and then it connect again but showing connected instead of active:


So the device is still there and the RPi can still see it.
that means the modbus node cannot communicate with it.

What version of Nodejs you have installed ?
node -v

by the way i just noticed that you said 60 seconds for delay ?? you mean Modbus delay 60s ?
thats to long .. here is my config

Confirm your device's Baud rate settings

Can you share your flow to see the rest of your setup ?


This is ok, since I can communicate sometimes.

The flow is:

[{"id":"705b8111668bdc06","type":"debug","z":"52cd3d86b0ad24b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":240,"wires":[]},{"id":"71c73b087a382df5","type":"debug","z":"52cd3d86b0ad24b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":280,"wires":[]},{"id":"34f08b45633bbf38","type":"modbus-read","z":"52cd3d86b0ad24b8","name":"Interfacial temperature pre reference","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"HoldingRegister","adr":"202","quantity":"2","rate":"30","rateUnit":"s","delayOnStart":true,"startDelayTime":"60","server":"6201b97892a33d68","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":200,"y":260,"wires":[["705b8111668bdc06"],["71c73b087a382df5"]]},{"id":"6201b97892a33d68","type":"modbus-client","name":"","clienttype":"simpleser","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"115200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"2","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"200","parallelUnitIdsAllowed":true}]

Thats the Node-red version .. whats the Node js version ? From terminal run node -v
The Modbus nodes officially support Nodejs version up to version 14. (Github link)

Enable these option in Modbus node to get a more detailed status notification

Do you also get the same errors if you use the Modbus-Flex-Getter node instead ?

Have you tried lowering the 115200 baud rate to something lower on both the device and the node ?

Also increase the Reconnect to 2000 ms instead of 200 to avoid throttling the device after a disconnection.


Sorry, the versión is v12.22.5

I didn't try it, but I will!

The manual of the device doesn't show how to make it so I can't try this

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.