# Function node with 2 different outputs

**URL:** <https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660>\
**Category:** General\
**Created:** [6 March 2019 06:28 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660 "2019-03-06T06:28:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mani2411](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mani2411](https://discourse.nodered.org/u/mani2411)\
**Post date:** [6 March 2019 06:28 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/1 "2019-03-06T06:28:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mani2411](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mani2411](https://discourse.nodered.org/u/mani2411)\
**Post date:** [6 March 2019 06:31 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/2 "2019-03-06T06:31:08Z")

</div>

please help i really need it

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 March 2019 07:06 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/3 "2019-03-06T07:06:26Z")

</div>

Can you publish what you've got so far?

---

<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:** [6 March 2019 07:10 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/4 "2019-03-06T07:10:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mani2411](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mani2411](https://discourse.nodered.org/u/mani2411)\
**Post date:** [6 March 2019 07:11 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/5 "2019-03-06T07:11:43Z")

</div>

here is my flow

 ![Screenshot%20(254)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b31399e0c897e7a2fffe3c513aea5fa49b4a713c.png)

---

<div class="post-metadata">

**Author:** ![mani2411](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mani2411](https://discourse.nodered.org/u/mani2411)\
**Post date:** [6 March 2019 07:18 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/6 "2019-03-06T07:18:52Z")

</div>

msg.payload gives temperature and msg.humidity gives humidity

---

<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:** [6 March 2019 07:24 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/7 "2019-03-06T07:24:47Z")

</div>

so your screenshot shows a 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

---

<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:** [6 March 2019 08:06 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/8 "2019-03-06T08:06:05Z")

</div>

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](https://nodered.org/docs/writing-functions#multiple-outputs)

---

<div class="post-metadata">

**Author:** ![machadotiago](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/machadotiago/32/23776_2.png) [@machadotiago](https://discourse.nodered.org/u/machadotiago)\
**Post date:** [6 March 2019 10:16 UTC](https://discourse.nodered.org/t/function-node-with-2-different-outputs/8660/9 "2019-03-06T10:16:23Z")

</div>

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