How to propagate UnitId to multiple Modbus Read Nodes?

I'm trying to build an interactive dashboard for commissioning multiple Modbus devices that are identical.
I want to display several read-only values to the dashboard, as well as allow the user to read and write to certain values.
Most of these values are non-sequential registers.
New to the process, I've just gotten it up and running by using a single Modbus-Read node per register wanting to be read.
On the R/W nodes, I've got the Modbus-Read node going into a Dashboard Numeric Node, which then goes out to an individual Modbus-Write node.

This works, but it's primitive.
I'm trying to find a way to have an input box on the Dashboard for the UnitID. The user would fill that in, and that value would propagate to all of the Modbus-Read/Write nodes.
Similar with the Server field.
Because the devices are identical, all registers and other fields will be unchanged, with only the UnitID changing.

My best idea is that this can be done with individual Function nodes, grabbing a flow.UnitID value, then compiling the relevant msg.payload into a Modbus Flex Getter node. I think this would solve the the issue of programmatically changing the UnitID, but requires an individual Function node for each msg?

Advice would be greatly appreciated.
Thank you!

Since you are reading addresses 15 ~ 29, you should read all addresses in one go then break up/format the data into the required units.

This way, you only need 1 function (or change) node to setup the payload for the flex getter.

PS: you dont need all those "divide by x" function either

See this article for details Modernize your legacy industrial data. Part 2. • FlowFuse

Thank for the reply, I really appreciate it. You seem to be the exact person I need to learn from!
That article is spot-on for what I'm trying to do, and calls out the same crimes I just committed!

I understand these issues, and knew I would have to deal with them, but threw down what I could as proof of concept for now as I stumble through learning Node-Red and JavaScript in general.

The registers I'm polling range from 11 to 166, but only about 30 in total.
Timing is not important.

I'll check out the buffer-parser package and see if I can utilize that.

let me know if the 2nd article comes out going into detail on getting data from spread out registers.

It depends on how your devices handle calls for non-contiguous registers (you can not break them so give it a try)

Send a reqest for 50 register from (say 11 to 61) - see if it returns results with just missing data or if the end node does not like it you will just get a modbus failure.

If that is the case then you will need to make multiple calls

Usually a total of 80 registers is what i have seen as the max from Solar inverters and Modbus energy meters.

Each of those that i have worked with have been happy to ask for 80 registers even though non-contiguous and they just return Zero in the stream for the non-existent ones


I have wired the controller up to a USB-to-RS485 converter and used modscan without issue. By default, Modscan polls 100 contiguous registers.
I don't know how to poll non-contiguous registers in Modbus, as the necessary parameters are [starting] register, and number of registers to get. I assume you would send an additional request in queue for each non-contiguous chunk.

What I thought would work is to programmatically change the server settings via the Modbus Flex Connector. Specifically the UnitId parameter.
Upon changing this, it is not reflected in other Modbus nodes that are configured to use that server, so the change does not propagate.
Is this a bug? Or am I missing something?

I don't believe that's what I'd does or how it is designed to work.

The flex getter node is for a dynamic one off request to a particular "thing". Of course you can repeat the command as many times as you wish. The point is more that the properties you set in the message are used that one time for that request.

Take a look at the building examples that node has provided. Use ctrl-i :arrow_right: examples.

I've looked at the examples. While I greatly appreciate this Modbus package, it is actually poorly documented. Many things are inferred or left out entirely, such as this issue I'm running into.
I thought for sure I could use the Flex Connector to programmatically change the UnitID. I didn't even think I was being clever. I legitimately though that was its intended purpose.

As far as the examples, I have to reverse engineer most of them to even have a basic understanding of what they're doing.

How would you go about programmatically changing the UnitID?
For example, I want to populate a dashboard with values all from a single controller. I want a snapshot of that controller while I'm working on it.
Then I want to swap out the UnitID and get that same dashboard populated with data from the next controller, and so on.

I really just want a text entry field I can pop the MAC address into and then it shows all the data fields I'm polling.

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