How to filter which measurement the gauge reads?

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.

#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);
  }
}

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

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.

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

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

where would I set that at? which node?

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.

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

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

In the value format field of the gauge node

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]}}

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

example of split method

[{"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

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

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

[{"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}]

current circuit:

Debug output:

JSON:

Temperature Gauge:

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

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.

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