# How to filter which measurement the gauge reads?

**URL:** <https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [15 January 2025 19:36 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655 "2025-01-15T19:36:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [15 January 2025 19:36 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/1 "2025-01-15T19:36:38Z")

</div>

I'm new to Node-Red. The project I'm working on is a thermostat circuit using arduino. Currently, I have two gauges, one reads temperature, the other reads humidity. But they both read the same result. How can I filter it so the temp gauge reads the temperature result, and humidity reads humidity? Also I will share the code I have, and a screenshot of the circuit.

```auto
#include <DHT11.h>

int in3 = 7;
int in4 = 8;
int enb = 9;

int threshold_temp = 25;

int chk;
float temperature; //Stores humidity value
float humidity; //Stores temperature value

DHT11 dht11(2);

void setup() {
Serial.begin(9600);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(enb, OUTPUT);

digitalWrite(in3, LOW);
digitalWrite(in4, LOW);

String temperature;
String humidity;
}

void loop() {
int temperature = 0;
int humidity = 0;

//Attempt to read the temperature and humidity values from the DHT11 sensor.
int result = dht11.readTemperatureHumidity(temperature, humidity);

//If reading is successful, print the temperature and humidity values.
//If there are errors, print the appropriate error messages
if (result == 0){
  Serial.print("Temperature: ");
  Serial.print(temperature );
  Serial.print("\tHumidity: ");
  Serial.print(humidity);
  Serial.println("%");
}else{
  //Print error messages based on error code
  Serial.print(DHT11::getErrorString(result));
}
if (temperature > threshold_temp) {
  analogWrite(enb, 255);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
}else{
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  }
}

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b16a69bf5d4ef902cf98f4826d855320e4024989.png)

---

<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:** [15 January 2025 22:12 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/2 "2025-01-15T22:12:50Z")

</div>

Add a debug node set to Output Complete Message to the serial node output and show us what it says.

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 14:18 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/3 "2025-01-16T14:18:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a661c9eaf3edc63cd2b618246ed60fd2f5f9d87.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 January 2025 15:08 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/4 "2025-01-16T15:08:51Z")

</div>

if this is dashboard 1, then you can set `{{payload[0]}}` .  
Or else you can split the array with a split node, then use a switch node to route the payloads using the property `msg.parts.index == 0`.

---

<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:** [16 January 2025 15:28 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/5 "2025-01-16T15:28:20Z")

</div>

Or change the code to send a JSON string which would make it easy in node red.

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 16:51 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/6 "2025-01-16T16:51:59Z")

</div>

how would I do that? I have the arduinoJSON library included, but no idea how to use it. and the examples don't help me at all

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 17:40 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/7 "2025-01-16T17:40:28Z")

</div>

where would I set that at? which node?

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 17:42 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/8 "2025-01-16T17:42:31Z")

</div>

So after looking some more, here is what my circuit looks like now. I mainly get errors of JSON having invalid tokens, but the readings it does get is the temp and humidity. I don't know what I need to configure in the switch node to get the gauges to only read their respective result.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/45245df706371620e0b6f1c7d6afe997096beccf.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 January 2025 18:05 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/9 "2025-01-16T18:05:31Z")

</div>

Please define that, as i gave 2 options. Are we talking about Dashboard 1 `node-red-dashboard` or dashboard 2 `@flowfuse/node-red-dashboard `

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 18:09 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/10 "2025-01-16T18:09:25Z")

</div>

I'm using node-red-dashboard. You said set {{payload[0]}}. Which node do I do that in?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 January 2025 18:10 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/11 "2025-01-16T18:10:10Z")

</div>

In the value format field of the gauge node

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 18:13 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/12 "2025-01-16T18:13:37Z")

</div>

so what does `msg.parts.index == 0` mean/do exactly? I just want to better understand what and why I'm typing it in. Same with `{{payload[0]}}`

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 January 2025 18:15 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/13 "2025-01-16T18:15:47Z")

</div>

msg.parts.index is part of another method as {{msg.payload[0]}} does not work in dashboard 2.

example of split method

```auto
[{"id":"a994bdfe788df235","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4]","payloadType":"json","x":130,"y":6720,"wires":[["cb980b777a8c9c4c"]]},{"id":"cb980b777a8c9c4c","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":290,"y":6720,"wires":[["8a44b87d9b8950cf"]]},{"id":"8a44b87d9b8950cf","type":"switch","z":"d1395164b4eec73e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"}],"checkall":"true","repair":false,"outputs":4,"x":430,"y":6720,"wires":[["1a43fd5b95b12ae1"],["2270647a77ea4fe8"],["b7f93ba2086299e4"],["186b3e98e0d20f4c"]]},{"id":"1a43fd5b95b12ae1","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6680,"wires":[]},{"id":"2270647a77ea4fe8","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6720,"wires":[]},{"id":"b7f93ba2086299e4","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6760,"wires":[]},{"id":"186b3e98e0d20f4c","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6800,"wires":[]}]

```

[How to import/export a flow](https://nodered.org/docs/user-guide/editor/workspace/import-export)

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 18:18 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/14 "2025-01-16T18:18:25Z")

</div>

so just putting that in as is does not work. what do I need to edit? change 0 to temperature/humidity?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 January 2025 18:20 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/15 "2025-01-16T18:20:58Z")

</div>

Again more context and maybe an example of what you put , export a small example flow and paste in reply, so we can see exactly what you have done

example of both methods working

```auto
[{"id":"a994bdfe788df235","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4]","payloadType":"json","x":130,"y":6720,"wires":[["cb980b777a8c9c4c","781da2ef23c8e777"]]},{"id":"cb980b777a8c9c4c","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":290,"y":6720,"wires":[["8a44b87d9b8950cf"]]},{"id":"781da2ef23c8e777","type":"ui_gauge","z":"d1395164b4eec73e","name":"","group":"2d4fe667.28f8ba","order":2,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{msg.payload[0]}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":290,"y":6860,"wires":[]},{"id":"8a44b87d9b8950cf","type":"switch","z":"d1395164b4eec73e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"}],"checkall":"true","repair":false,"outputs":4,"x":430,"y":6720,"wires":[["47b3af31334f4c49"],["2270647a77ea4fe8"],["b7f93ba2086299e4"],["186b3e98e0d20f4c"]]},{"id":"2270647a77ea4fe8","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6720,"wires":[]},{"id":"b7f93ba2086299e4","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6760,"wires":[]},{"id":"186b3e98e0d20f4c","type":"debug","z":"d1395164b4eec73e","name":"gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":6800,"wires":[]},{"id":"47b3af31334f4c49","type":"ui_gauge","z":"d1395164b4eec73e","name":"","group":"2d4fe667.28f8ba","order":1,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":610,"y":6680,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"Demo","tab":"0ca01f1e15e69b4d","order":2,"disp":true,"width":"18","collapse":false,"className":""},{"id":"0ca01f1e15e69b4d","type":"ui_tab","name":"demo","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 18:25 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/16 "2025-01-16T18:25:13Z")

</div>

current circuit:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c4b3a2fe2f8b3b751c7a2ea402bd2f1b0a4880c6.png)

Debug output:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cb6d3eae75eecf2b72c1992d0d3b3c0e94e38c18.png)

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 18:26 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/17 "2025-01-16T18:26:12Z")

</div>

JSON:

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

Temperature Gauge:

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

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 January 2025 18:26 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/18 "2025-01-16T18:26:54Z")

</div>

you have not enter {{msg.payload[0]}} in the value format field.

images are of no use please reread previous replies and follow requests.

Having looked again at your debug info the incoming payload is a buffer you will need to convert it. before you continue. The JSON node is not the right node, have alook at the buffer parser

> **[node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser)**
>
> Node-red nodes to convert values to and from buffer/array. Supports Big/Little Endian, BCD, byte swapping and much more

---

<div class="post-metadata">

**Author:** ![CaptScott331](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captscott331/32/98096_2.png) [@CaptScott331](https://discourse.nodered.org/u/CaptScott331)\
**Post date:** [16 January 2025 18:34 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/19 "2025-01-16T18:34:45Z")

</div>

when i put`{{msg.payload[0]}}` in the format field, it did not do anything different.

I feel another thing that would help is that before, in my code I had it so the serial monitor would display:

temperature: X  
humidity: X

but node-red did not like the letters. so I have it now that it only prints the numbers.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 January 2025 18:35 UTC](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655/20 "2025-01-16T18:35:21Z")

</div>

> [@E1cid](#):
>
> you have not enter {{msg.payload[0]}} in the value format field.

If this is handlebars, it should be `{{msg.payload.0}}`

[Next page](https://discourse.nodered.org/t/how-to-filter-which-measurement-the-gauge-reads/94655.md?page=2)
