Modbus reading sensor values stops

Hi everyone,

I have been trying to solve this problem for the past month but ultimately gave up and have to write for help.
Thanks so much for helping in advance!

What I am trying to do is read sensor values with an industrial PLC (Weidmüller). It is preinstalled with Node-RED (unfortunately I do not have admin priviliges for it). I have three other devices that broadcast over TCP with modbus. Sensors broadcast over modbus with RS485. This data is then converted via a Weidmüller Ethernet/Modbus gateway. I get the data frmo the three devices, but the sensor data is very unstable, sometimes I receive it for a short period of time, but then it disconnects.

Node-RED version: v1.1.2
Node-JS version: v10.15.3
node-red-contrib-modbus: v5.14.0
Gateway settings:
Baud-rate: 19200
8,N,1
Port: 10502 (port for sensors set to 10502, port for other three devices set to 502)
Mode: TCP master to Serial Slave Gateway

The hardware seems to be okay, I have a modbus read device, with which I could see that data can be queried. All devices are set to 19200 8N1

A sample flow looks like this:

[{"id":"ca696b6c.9d71b8","type":"tab","label":"Temperature Sensors","disabled":false,"info":""},{"id":"c6079f81.ffa22","type":"function","z":"ca696b6c.9d71b8","name":"FC(3) 4002","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 1, \n    'address': 4001 , \n    'quantity': 1 ,\n\n};    \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":100,"wires":[["33d2bc11.397b54"]]},{"id":"4ca7ddba.281224","type":"comment","z":"ca696b6c.9d71b8","name":"Temperature [°C]*100","info":"","x":480,"y":60,"wires":[]},{"id":"a373bca0.3c0988","type":"ui_text","z":"ca696b6c.9d71b8","group":"69845a.d3c883a8","order":1,"width":0,"height":0,"name":"","label":"Temperature [°C] - Sensor #1","format":"{{msg.payload.data}}","layout":"row-spread","className":"","x":920,"y":100,"wires":[]},{"id":"33d2bc11.397b54","type":"modbus-flex-getter","z":"ca696b6c.9d71b8","name":"RS485 Busch","showStatusActivities":true,"showErrors":false,"logIOActivities":false,"server":"f610a4f1.e28a68","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":540,"y":100,"wires":[[],["853889c8.5a5508"]]},{"id":"ddaa9e31.67d08","type":"comment","z":"ca696b6c.9d71b8","name":"Temperature Sensor #1 - id:1","info":"","x":180,"y":60,"wires":[]},{"id":"a12c6b36.9bc8a","type":"comment","z":"ca696b6c.9d71b8","name":"Temperature Sensor #1 - id:2","info":"","x":180,"y":160,"wires":[]},{"id":"dd460bfd.62c1c8","type":"comment","z":"ca696b6c.9d71b8","name":"Temperature Sensor #1 - id:3","info":"","x":180,"y":260,"wires":[]},{"id":"5ddad991.4d0d6","type":"function","z":"ca696b6c.9d71b8","name":"FC(3) 4002","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 2, \n    'address': 4001 , \n    'quantity': 1 ,\n\n};    \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":220,"wires":[["b68692fe.91523"]]},{"id":"82a6e9e1.788d18","type":"comment","z":"ca696b6c.9d71b8","name":"Temperature [°C]*100","info":"","x":480,"y":180,"wires":[]},{"id":"4aff082f.40e08","type":"ui_text","z":"ca696b6c.9d71b8","group":"69845a.d3c883a8","order":2,"width":0,"height":0,"name":"","label":"Temperature [°C] - Sensor #2","format":"{{msg.payload.data}}","layout":"row-spread","className":"","x":920,"y":220,"wires":[]},{"id":"b68692fe.91523","type":"modbus-flex-getter","z":"ca696b6c.9d71b8","name":"RS485 Busch","showStatusActivities":true,"showErrors":false,"logIOActivities":false,"server":"dee8f168.19d7","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":540,"y":220,"wires":[[],["b4db04c6.aa3688"]]},{"id":"d84e7ef2.4d18a","type":"function","z":"ca696b6c.9d71b8","name":"FC(3) 4002","func":"msg.payload = { \n    'fc': 3, \n    'unitid': 3, \n    'address': 4001 , \n    'quantity': 1 ,\n\n};    \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":320,"wires":[["98820d56.57996"]]},{"id":"95b295eb.0a951","type":"comment","z":"ca696b6c.9d71b8","name":"Temperature [°C]*100","info":"","x":480,"y":280,"wires":[]},{"id":"33e938a5.594ca8","type":"ui_text","z":"ca696b6c.9d71b8","group":"69845a.d3c883a8","order":3,"width":0,"height":0,"name":"","label":"Temperature [°C] - Sensor #3","format":"{{msg.payload.data}}","layout":"row-spread","className":"","x":920,"y":320,"wires":[]},{"id":"98820d56.57996","type":"modbus-flex-getter","z":"ca696b6c.9d71b8","name":"RS485 Busch","showStatusActivities":true,"showErrors":false,"logIOActivities":false,"server":"89d8269e.c9936","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":540,"y":320,"wires":[[],["b30b3817.b47598"]]},{"id":"904acd2b.a57c4","type":"debug","z":"ca696b6c.9d71b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":60,"wires":[]},{"id":"8a5dff72.b9fad","type":"inject","z":"ca696b6c.9d71b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"25","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":190,"y":220,"wires":[["c6079f81.ffa22","5ddad991.4d0d6","d84e7ef2.4d18a"]]},{"id":"853889c8.5a5508","type":"function","z":"ca696b6c.9d71b8","name":"1/100","func":"msg.payload.data = msg.payload.data/100;\n\n    \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":100,"wires":[["a373bca0.3c0988"]]},{"id":"b4db04c6.aa3688","type":"function","z":"ca696b6c.9d71b8","name":"1/100","func":"msg.payload.data = msg.payload.data/100;\n\n    \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":220,"wires":[["4aff082f.40e08"]]},{"id":"b30b3817.b47598","type":"function","z":"ca696b6c.9d71b8","name":"1/100","func":"msg.payload.data = msg.payload.data/100;\n\n    \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":320,"wires":[["33e938a5.594ca8"]]},{"id":"69845a.d3c883a8","type":"ui_group","z":"","name":"EE451 Temp Sensors","tab":"1e910cf.d5362f3","order":5,"disp":true,"width":"6","collapse":false,"className":""},{"id":"f610a4f1.e28a68","type":"modbus-client","z":"","name":"RS485 1","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.1.110","tcpPort":"10502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":false},{"id":"dee8f168.19d7","type":"modbus-client","z":"","name":"RS485 2","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.1.110","tcpPort":"10502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"2","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"89d8269e.c9936","type":"modbus-client","z":"","name":"RS485 3","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.1.110","tcpPort":"10502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"3","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"1e910cf.d5362f3","type":"ui_tab","z":"","name":"Sensors","icon":"dashboard Jó","order":2,"disabled":false,"hidden":false}]

I ran out of ideas, can you please help? Much appreciated!

What sensor are we talking about?
If temp sensor what type.
I have had issues with my Dallas one wire temp sensors and i developed a "baby sitter "flow.
It basically monitors the mqtt message i get from sensor. If i stop receiving messages it sends me an email stating such, and sends a command to reboot my esp8266 then i get a confirmation email saying it's working again.
My issue on my sensor was because i was using the internal pull up resistor instead of the preferred external 4.7k pull up resistor

So basically we really need to know what specific sensor to troubleshoot the connection is done right.

I use EE451 temp. sensors among dewpoint sensors, power meters and a flow meter. Even if the PLC sensor read does not work, I am able to read sensor data with the modbus device previously mentioned.

What I noticed is that there are sensors which have 8,E,1 setting instead of 8,N,1 and that there are two sensor branches, not just a single daisy chain. At the end of each sensor-branch there is a 120 Ω termination resistor. However, when I unplug one of the branches, the other branch does not work. So I think, it is not the problem.

1 Like

All devices on RS485 bus must have the same comm. settings. 8.E.1 means that even parity used and don't match. Some devices goes on error state on comm error. RS485 bus must also terminated with 120 Ohm resistors on both bus ends. A star connection of RS485 brings always problems. Use a RS485 repeater for star connection. For long distance of cable use shielded twisted pair cable. Connect only one end of shield to ground.

1 Like

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