question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with multiple modbus rtu slaves

See original GitHub issue

I’m submitting a … (check one with “x”)

Support/Advice

Feature

  • ( ) feature request

What is the motivation / use case for changing the behavior?

Simple question to get some hint

  • ( ) simple question => please visit the Wiki, the YouTube tutorials and the Info tab by clicking on the node inside Node-RED before
  • ( ) help wanted => you read all information and watched relevant YouTube tutorials, but you need more help

Problem

  • (X) bug report => please search github for a similar issue or PR and test Modbus problems with the modbus-serial package before submitting
  • ( ) unexpected behavior => please visit the Wiki before

Current behavior

Setting up multiple modbus rtu/rtu buffered slaves that utilise the same serial port cause issues. Setting up one at a time and testing works fine, which confirms there isn’t an issue with main codebase or hardware setup. More info here, https://discourse.nodered.org/t/multiple-modbus-rtu-slaves-causes-error/18783/8

Expected behavior

Multiple slaves should be accessible via the same serial port. Commands send concurrently should be queued per server, as not to choke up the comms bus. The same is true for initialisation, because as far as my tests show, these all try and happen at the same time, causing none of the servers to initialise.

Minimal reproduction of the problem with instructions

Hard to reproduce if you don’t have the same hardware setup. However there are two modbus slaves on each of the two node red tabs copied below. Disabling one tab and deploying allows the other connection to work fine. Enabling both causes the error condition above, proving that it’s an issue only with multiple modbus slaves on the same serial port.

Flow 2A:

[ { "id": "ae505081.3307", "type": "modbus-read", "z": "5484bbf1.3f12e4", "name": "digi", "topic": "", "showStatusActivities": false, "logIOActivities": false, "showErrors": false, "unitid": "", "dataType": "HoldingRegister", "adr": "14", "quantity": "1", "rate": "5", "rateUnit": "s", "delayOnStart": true, "startDelayTime": "1", "server": "7a2d3f7d.23a34", "useIOFile": false, "ioFile": "", "useIOForPayload": false, "x": 170, "y": 100, "wires": [ [ "d6f6caad.6f5908" ], [] ] }, { "id": "d6f6caad.6f5908", "type": "debug", "z": "5484bbf1.3f12e4", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 400, "y": 100, "wires": [] }, { "id": "7a2d3f7d.23a34", "type": "modbus-client", "z": "", "name": "Novus DigiRail 2A", "clienttype": "serial", "bufferCommands": true, "stateLogEnabled": false, "tcpHost": "127.0.0.1", "tcpPort": "502", "tcpType": "DEFAULT", "serialPort": "/dev/tty.usbserial-14130", "serialType": "RTU", "serialBaudrate": "9600", "serialDatabits": "8", "serialStopbits": "1", "serialParity": "even", "serialConnectionDelay": "1000", "unit_id": "246", "commandDelay": "1000", "clientTimeout": "1000", "reconnectTimeout": "2000" } ]

Flow 4C:

[ { "id": "6265f722.682958", "type": "modbus-read", "z": "9e57cfa0.6fc53", "name": "rail", "topic": "", "showStatusActivities": false, "logIOActivities": false, "showErrors": false, "unitid": "", "dataType": "HoldingRegister", "adr": "512", "quantity": "1", "rate": "7", "rateUnit": "s", "delayOnStart": false, "startDelayTime": "", "server": "1ee5d4d5.ce5dab", "useIOFile": false, "ioFile": "", "useIOForPayload": false, "x": 230, "y": 100, "wires": [ [ "3bc7006b.b025f" ], [] ] }, { "id": "3bc7006b.b025f", "type": "debug", "z": "9e57cfa0.6fc53", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 470, "y": 100, "wires": [] }, { "id": "1ee5d4d5.ce5dab", "type": "modbus-client", "z": "", "name": "DigiRail 4C", "clienttype": "serial", "bufferCommands": true, "stateLogEnabled": false, "tcpHost": "127.0.0.1", "tcpPort": "502", "tcpType": "DEFAULT", "serialPort": "/dev/tty.usbserial-14130", "serialType": "RTU", "serialBaudrate": "9600", "serialDatabits": "8", "serialStopbits": "1", "serialParity": "even", "serialConnectionDelay": "100", "unit_id": "247", "commandDelay": "1", "clientTimeout": "1000", "reconnectTimeout": "2000" } ]

Your Environment

Please tell us about your environment:

  • ( ) I am using just the Node-RED package and got modbus-serial package installed with it
  • (X) I have installed modbus-serial package global from source (using git clone)
  • ( ) I have installed modbus-serial as a global package (using npm i -g)

Yes, modbus-serial is the name but it does all, TCP and Serial. The node-modbus package is just for the Modbus Server node.

  • Device :

    • (X) macOS: 10.14.6
    • ( ) Linux: v
    • ( ) Windows: v
    • ( ) Raspbian: v
    • (X) Other: Balena
      • Name:
      • Version:

Tested on both macos and Balena (formerly Resin), so it’s not a vendor-specific issue.

  • Description of the connecting Modbus system:

    • Name : Novus
    • Version: USB-i485
    • Vendor :
    • Link : https://
  • node-red-contrib-modbus version: 5.1.0

  • Node: (min. 6.x) node --version = v10.14.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:28 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
biancodecommented, Aug 5, 2021

@biancode, being able to switch off reconnect on timeout is extremely useful… thanks.

What does “UnitId’s in parallel” do?

“UnitId’ in parallel” works with a queue on each UnitId and sends them in parallel per cycle if possible.

The order of UnitIds depends on msgs.

Option off sending: 1 2 3 2 1 3

Option on sending:

1,2,3 2,1,3

Modbus Gatways can handle that for example or TCP can do that - serial can normally not work in parallel.

1reaction
biancodecommented, May 25, 2020

@jcampino1 I tested with v5.13.1 and it works well to communicate with multiple Units over the same BUS (1 Port serial) - check that you do not have “parallel unitid” to on in the Modbus config node. If you need more help please open and fill out a new issue! 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with multiple modbus rtu slaves #161 - GitHub
It seems like a flex getter may be a workaround, as it gives you the ability to ensure that there are no requests...
Read more >
Multiple Modbus RTU Slaves causes error - Node-RED Forum
WIth modbus RTU, only 1 slave can be connected at a time. Maybe with your settings, there is a collision of data where...
Read more >
Modbus RTU 485 issue with two slave IDs read/write data
Hi. I am using CPU 1212 AC/DC/RLY +CB1242 RS 485. In my network I have two silimar devices with different slave IDs. Id...
Read more >
Do-more with multiple Modbus-RTU slaves.
Hi, I have 2 separate systems, one with 7 and the other with 12 modbus serial slaves (vfd's, other controllers) with occasional writes...
Read more >
Modbus master and multiple slaves via RS-485 converter.
This article illustrates how to fix the communication problem between Modbus driver and multiple slaves with a Ethernet/RS-485 converter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found