# A different gauge for each element of an array

**URL:** <https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995>\
**Category:** Dashboard\
**Created:** [7 July 2019 11:35 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995 "2019-07-07T11:35:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [7 July 2019 11:35 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/1 "2019-07-07T11:35:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [7 July 2019 11:59 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/2 "2019-07-07T11:59:25Z")

</div>

![nr1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c08a460418e156432006de46bd10b97a4673448d.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 July 2019 12:25 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/3 "2019-07-07T12:25:08Z")

</div>

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](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [7 July 2019 13:02 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/4 "2019-07-07T13:02:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [7 July 2019 13:26 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/5 "2019-07-07T13:26:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [7 July 2019 14:18 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/6 "2019-07-07T14:18:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [7 July 2019 14:26 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/7 "2019-07-07T14:26:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [7 July 2019 16:17 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/8 "2019-07-07T16:17:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [7 July 2019 16:23 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/9 "2019-07-07T16:23:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 July 2019 16:44 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/10 "2019-07-07T16:44:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [10 July 2019 17:55 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/11 "2019-07-10T17:55:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 July 2019 18:24 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/12 "2019-07-10T18:24:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [10 July 2019 18:48 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/13 "2019-07-10T18:48:56Z")

</div>

Also look at the working with messages page in the docs

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [10 July 2019 18:51 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/14 "2019-07-10T18:51:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [10 July 2019 19:14 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/15 "2019-07-10T19:14:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [10 July 2019 19:25 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/16 "2019-07-10T19:25:08Z")

</div>

There is option of course.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e821cd1badbed11588e6fd327fd2675ebea1ccec.png)

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [11 July 2019 20:38 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/17 "2019-07-11T20:38:12Z")

</div>

Thank you! This worked straight away. Namaste

---

<div class="post-metadata">

**Author:** ![gwgorman](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gwgorman/32/9662_2.png) [@gwgorman](https://discourse.nodered.org/u/gwgorman)\
**Post date:** [11 July 2019 20:38 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/18 "2019-07-11T20:38:46Z")

</div>

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](https://github.com/gwgorman/Flows/blob/master/LewisvilleLakeInfo.json)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d06b68c547c44f24c5e609f08877b770967eb29b.png)

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://discourse.nodered.org/u/Matt)\
**Post date:** [14 July 2019 12:29 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/19 "2019-07-14T12:29:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 July 2019 12:47 UTC](https://discourse.nodered.org/t/a-different-gauge-for-each-element-of-an-array/12995/20 "2019-07-14T12:47:15Z")

</div>

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.
