A different gauge for each element of an array

Good morning all,

I am trying to build a dashboard with lots of gauges to show the current integer values from a number of Arduino based modbus servers.

i can only get the data from the very first input register of each device to display on a gauge.

All my data is visible in the form of an array in the debug window.

I have a screenshot jpeg but the upload won't accept it, which doesn't help.

i read the search results about the 'change' and 'function' nodes but the OP is different and i cant follow what is happening.

Is there already a node available with which i can connect a different gauge node to different outputs, an output for each modbus input register?

Have a look at the section in docs Working with Messages. That will show you how to extract each element and send it to a different guage. You will need to send the array to multiple Change nodes in parallel, each one extracting one element, then pass these on to the dashboard nodes.
https://nodered.org/docs/user-guide/messages

Hi Colin, I have read that page from top to bottom 4 times now. It tells me what can be done, but not how to do anything. What prior knowledge is assumed?

Are there any other online resources, with examples that may help me?

I am prepared to learn this for myself but it is a struggle tbh

So you need to split the array and route each element to different flow path.
This is two step operation.

  1. Split
  2. Route

For split there is Split node. Read info page , configure and try. See the output of split node by using debug node with option to see whole msg. You should get series of messages, every message contains a single element of your array in payload and in addition the msg.parts property. This will be used in step 2.

For route there is Switch node. Read info page. As every message contains now parts property , the property msg.parts.index is the one you should then examine to route the message to desired output.

1 Like

Hi, I have seen and read the info pages. I even think I understand what you are suggesting. However, the debug outputs the same as before. I cannot understand how to configure the split node. I still get the output as an array.

"Array - the message is split into either individual array elements, or arrays of a fixed-length."

I believe I want the former, however, I have no option to do this. Only "fixed length of n" is available.

I am using Node red v0.20.6

Here is example where first step is split array into separated messages
https://cookbook.nodered.org/basic/operate-on-array

Okay, I now have all my measurements split into seperate messages in the debug window.

I don't get any msg at all on the outputs of the switch node when set as:

property msg.payload

== msg. 1
== msg. 2
== msg. 3

Is this configuration correct?

I've been at this for well over 25 hours since yesterday morning!

I'm giving it up for now, it's time to salvage some of my weekend.

Attach a debug node (your friend) set to display the 'complete msg object' on the output of the split node. This way you can see what the data is. You probably want to set msg.part to a number.

I am stuck on the switch node of my problem. I am not making any progress at all. My array is split into separate messages. I believe it is a syntax thing that I am not aware of.

Array element 0 to the first output

Array element 1 to the second output

Array element 2 to the third output

Etc.

What comparator do I use, and to what do I compare it to, to generate my outputs as numbers?

I have tried:

== 0

== [0]

..for each option available.

There is no 'element' option, to filter out the array element by its index in the array.

Am I wasting my time trying to do this with the switch node?

If you add a debug node to the output of the split node and display the full msg object, you will see a section called parts if you look in there you will see the number of each part and you could use the variable name in the switch statement.

1 Like

Also look at the working with messages page in the docs

In the 'parts' section for each message, the 'id' is the same for each message. The '_msgid' is different, but gives no output.

What exactly is the 'variable name'?

What do I select from the option list?

Only the 'index' is different in the 'parts' but there is no option to compare the index.

There is option of course.

1 Like

Thank you! This worked straight away. Namaste

1 Like

I created a flow that uses USGS data for a lake dam. It comes in as an array of information, shows on a dashboard with gauges, so this might be useful for you to look at. Here's part of the flow, the entire thing can be downloaded from my Github --> https://github.com/gwgorman/Flows/blob/master/LewisvilleLakeInfo.json

Thank you for sharing this, i look forward to learning how to open it

If you go to the github page and mark and copy the complete flow text there then in node-red you should be able to Import it using Import from the hamburger menu.