Sensors to function. function to switch

i m retrieving temperature value from dht22 to a function node in msg.payload. how to turn something On or Off based on temperature value? help would be much appriciated.

Use a debug node to understand your data, this page in the docs is a key doc to read

Then investigate the switch node to separate messages.

How to turn something on /off well that will depend on what the something is, but I'm sure looking at the and you should be able to get started.

PS, this should really be asked in #general as you aren't developing the Node-RED code...

temperature value is in payload when attached debug node. something connected to raspberry gpio pin. what should be the code in function node. i tried if else but it wont return Boolean.

You don't need a function node.

If your data is msg.payload you could use a switch to only allow through the values you want and then a change node.

Alternatively post your code and what the data see in the debug...

1 Like

thats what i have done so far. in function node its just msg.payload=msg.payload; return msg;

debug shows: 16/07/2019, 13:04:20node: ff5af76a.59b928rpi-dht22 : msg.payload : string[5]


16/07/2019, 13:04:20node: 4c3eb789.797c58rpi-dht22 : msg.payload : string[5]


So you didn't post the contents of your function node which does make it more difficult

But I'm guessing it's because you're msg.payload is a string not a number.
Try searching this internet for "javascript convert string to number" or you could use a switch node...