Function node with 2 different outputs

#1

hi all
i am interfacing dht sensor with arduino and getting serial data on raspberry pi through node red now i want to create only 1 function to differentiate between temperature and humidity
Now i need the js of function node to to deploy

0 Likes

#2

please help i really need it

0 Likes

#3

Can you publish what you've got so far?

0 Likes

#4

Add a debug node to the serial Node so you can see what you are sending.

If you have been clever then there is a character between the two values that you know. Splitting on a character in a javascript function is easy and a quick google will lead to lots of tutorials for how to do it.

0 Likes

#5

here is my flow

0 Likes

#6

msg.payload gives temperature and msg.humidity gives humidity

0 Likes

#7

so your screenshot shows a red triangle :small_red_triangle: on the serial node which means it’s not configured correctly.

Add a debug to the serial node so you can see what it is sending when configured.
Without seeing what the message is, and what your function is it is difficult to suggest anything else

0 Likes

#8

Taking another look, if you mean you don't know how to send some to output1 and something else to output 2 , the docs have an example https://nodered.org/docs/writing-functions#multiple-outputs

0 Likes

#9

Isn’t the “switch” and “change” nodes enough for your application?

0 Likes