# Multiple Sensor Data Using Arduino

**URL:** <https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206>\
**Category:** Dashboard\
**Created:** [16 April 2019 05:13 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206 "2019-04-16T05:13:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maverick](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@maverick](https://discourse.nodered.org/u/maverick)\
**Post date:** [16 April 2019 05:13 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/1 "2019-04-16T05:13:28Z")

</div>

Hi,  
I am trying to interface dht11 sensor in arduino and trying to read it in serial monitor in node red. The "split node" is working fine, but after that the "Payload Object Sensor" function is not working. Please resolve this situation. The related codes are given below:

[{"id":"99ef7505.c281c8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"61fee05.2f50b2","type":"serial in","z":"99ef7505.c281c8","name":"","serial":"a2dd7e6a.214a8","x":60,"y":180,"wires":[["ddf9c433.b32258"]]},{"id":"5c3851c1.3b432","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"console":"false","complete":"true","x":510,"y":120,"wires":},{"id":"dd3f2d0e.54406","type":"file","z":"99ef7505.c281c8","name":"Sensor Data","filename":"D:\My Files\Sensor.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","x":800,"y":160,"wires":[]},{"id":"190e0530.f9648b","type":"ui\_gauge","z":"99ef7505.c281c8","name":"Temp DHT11","group":"2b53962a.e11c1a","order":1,"width":0,"height":0,"gtype":"gage","title":"Temp DHT11","label":"","format":"{{value}}°C","min":0,"max":"60","colors":["#008000","#ff8000","#ff0000"],"x":980,"y":220,"wires":},{"id":"ddf9c433.b32258","type":"function","z":"99ef7505.c281c8","name":"","func":"var newMsg = {payload: msg.payload.toString()};\nreturn newMsg;","outputs":1,"noerr":0,"x":180,"y":180,"wires":[["69577f5b.d860a"]]},{"id":"69577f5b.d860a","type":"split","z":"99ef7505.c281c8","name":"","splt":" ","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":300,"y":180,"wires":[["6ec1d5b5.6fa74c","5c3851c1.3b432"]]},{"id":"6ec1d5b5.6fa74c","type":"function","z":"99ef7505.c281c8","name":"Payload Object Sensor","func":"var newMsg = {};\nvar Sensor = {\n NData: 0, \n Temp\_DHT11: 0,\n Humid\_DHT: 0,\n Time: new Date().toString()\n};\n\ncontext.data = context.data || {};\n\nswitch(msg.parts.index){\n case 0:\n context.data.NData = parseFloat(msg.payload);\n msg = null;\n break;\n case 1:\n context.data.Temp\_DHT11 = parseFloat(msg.payload);\n msg = null;\n break;\n case 2:\n context.data.Humid\_DHT = parseFloat(msg.payload);\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\n\nAllData = context.data.NData &&\n context.data.Temp\_DHT11 &&\n context.data.Humid\_DHT;\n\nif(AllData){\n var time = Date();\n context.data.Time = time.toString();\n Sensor = context.data;\n newMsg = { payload: context.data,\n topic: 'Frame Sensor' };\n context.data = null;\n return newMsg;\n}\nelse\n return msg;\n\n\n","outputs":1,"noerr":0,"x":490,"y":240,"wires":[["6ea2f4d2.fa18dc","dd3f2d0e.54406","db161a91.1bf308"]]},{"id":"6ea2f4d2.fa18dc","type":"function","z":"99ef7505.c281c8","name":"Split Data","func":"var msgTemp\_DHT11 = {payload: msg.payload.Temp\_DHT11};\nvar msgHumid\_DHT = {payload: msg.payload.Humid\_DHT};\n\nreturn [msgTemp\_DHT11, msgHumid\_DHT];","outputs":2,"noerr":0,"x":695.3627052307129,"y":336.9830274581909,"wires":[["190e0530.f9648b","2fbba10c.d9999e"],["dbcc3883.4d3b78","e6b489b1.c1b568"]]},{"id":"dbcc3883.4d3b78","type":"ui\_gauge","z":"99ef7505.c281c8","name":"Humid DHT11","group":"539bb2f8.4cd23c","order":1,"width":0,"height":0,"gtype":"gage","title":"Humid DHT11","label":"","format":"{{value}}%","min":0,"max":"100","colors":["#ffff80","#ff8000","#008000"],"x":990,"y":300,"wires":},{"id":"2fbba10c.d9999e","type":"ui\_chart","z":"99ef7505.c281c8","name":"Graph 5 min Temp DHT11 (°C)","group":"2b53962a.e11c1a","order":2,"width":0,"height":0,"label":"Graph 5 min Temp DHT11 (°C)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"10","ymax":"40","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":260,"wires":[,]},{"id":"e6b489b1.c1b568","type":"ui\_chart","z":"99ef7505.c281c8","name":"Graph 5 min Humid DHT11 (%)","group":"be69083c.111928","order":2,"width":0,"height":0,"label":"Graph 5 min Humid DHT11 (%)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"0","ymax":"100","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":340,"wires":[,]},{"id":"db161a91.1bf308","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":120,"wires":},{"id":"a2dd7e6a.214a8","type":"serial-port","z":"","serialport":"COM5","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"0","bin":"bin","out":"time","addchar":"false","responsetimeout":""},{"id":"2b53962a.e11c1a","type":"ui\_group","z":"","name":"Sensor DHT11","tab":"ba6c5c45.1e5fb","order":2,"disp":true,"width":"6"},{"id":"539bb2f8.4cd23c","type":"ui\_group","z":"","name":"Pressure, Humidity","tab":"ba6c5c45.1e5fb","order":4,"disp":true,"width":"6"},{"id":"be69083c.111928","type":"ui\_group","z":"","name":"DHT11: Humid (5 Min)","tab":"ba6c5c45.1e5fb","order":5,"disp":true,"width":"6"},{"id":"ba6c5c45.1e5fb","type":"ui\_tab","z":"","name":"MONITORING","icon":"dashboard","order":1}]

#include \<DHT.h\>

/\*

- Codigo para Arduino Pro Micro el cual permite leer los sensores:
- DS18B20, Read Temp: (Pin 8, Comunicacion 1-Wire),
- DHT11, Read Temp y Humedad: (Ping 9, Comunicacion 1-Wire),
- BMP180 Read Temp, Altitud, Presion: (Pin 2=SDA, 3=SLC, Comunicacion I2C).
- El formato de la trama enviada por puerto Serial (USB): NData Data1 Data2 Data3 Data4 ... DataN
- La trama es Procesada con Node Red para su visualizacion.  
\*/

#define PIN\_SENSOR\_DHT 2

DHT SensorDHT(PIN\_SENSOR\_DHT,DHT11);

void setup() {  
Serial.begin(9600);  
SensorDHT.begin();  
}

void loop() {  
//Read Temperature and Humidity from DHT11 Sensor  
String Temp\_DHT = (String)SensorDHT.readTemperature();  
String Humid\_DHT = (String)SensorDHT.readHumidity();

/\*Read Temperature from DS18B20 Sensor  
SensorDS.requestTemperatures();  
String Temp\_DS = (String)SensorDS.getTempCByIndex(0);

//Read Temperature from BMP180 Sensor  
String Temp\_BMP = (String)SensorBMP.readTemperature(); //Celcius  
String Pressure\_BMP = (String)SensorBMP.readPressure(); //Pascal  
String Altitude\_BMP = (String)SensorBMP.readAltitude(); //mts \*/  
int NData = 2;  
String str\_Payload;

//Crea un string con el formato: NData Data1 Data2 Data3 ... DataN  
str\_Payload += NData;  
str\_Payload += " " + Temp\_DHT;  
str\_Payload += " " + Humid\_DHT;  
/\* str\_Payload += " " + Temp\_DS;  
str\_Payload += " " + Temp\_BMP;  
str\_Payload += " " + Pressure\_BMP;  
str\_Payload += " " + Altitude\_BMP;\*/  
str\_Payload += " ";

byte Payload[str\_Payload.length()];  
int LengthFrameAPI = 6 + sizeof(Payload);  
int LengthPayload = sizeof(Payload);

Serial.print(str\_Payload);

delay(1000);  
}

---

<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 April 2019 07:52 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/2 "2019-04-16T07:52:15Z")

</div>

Please see the post below for how to share flows here, the one you posted is not importable. However before doing that you say that it is just one function that is not working. Start by putting a debug node showing what is going into the function and check that is correct. Next you can insert node.warn() statements into your code to show the state of variables as it runs through. The warn text will be shown in the debug pane. If that does not help then post just the function here and show us what is going into it.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<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:** [16 April 2019 09:18 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/3 "2019-04-16T09:18:40Z")

</div>

Here is the flow please help`[{"id":"99ef7505.c281c8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"61fee05.2f50b2","type":"serial in","z":"99ef7505.c281c8","name":"","serial":"a2dd7e6a.214a8","x":60,"y":180,"wires":[["ddf9c433.b32258"]]},{"id":"5c3851c1.3b432","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"console":"false","complete":"true","x":510,"y":120,"wires":[]},{"id":"dd3f2d0e.54406","type":"file","z":"99ef7505.c281c8","name":"Sensor Data","filename":"D:\\My Files\\Sensor.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","x":800,"y":160,"wires":[[]]},{"id":"190e0530.f9648b","type":"ui_gauge","z":"99ef7505.c281c8","name":"Temp DHT11","group":"2b53962a.e11c1a","order":1,"width":0,"height":0,"gtype":"gage","title":"Temp DHT11","label":"","format":"{{value}}°C","min":0,"max":"60","colors":["#008000","#ff8000","#ff0000"],"x":980,"y":220,"wires":[]},{"id":"ddf9c433.b32258","type":"function","z":"99ef7505.c281c8","name":"","func":"var newMsg = {payload: msg.payload.toString()};\nreturn newMsg;","outputs":1,"noerr":0,"x":180,"y":180,"wires":[["69577f5b.d860a"]]},{"id":"69577f5b.d860a","type":"split","z":"99ef7505.c281c8","name":"","splt":" ","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":300,"y":180,"wires":[["6ec1d5b5.6fa74c","5c3851c1.3b432"]]},{"id":"6ec1d5b5.6fa74c","type":"function","z":"99ef7505.c281c8","name":"Payload Object Sensor","func":"var newMsg = {};\nvar Sensor = {\n NData: 0, \n Temp_DHT11: 0,\n Humid_DHT: 0,\n Time: new Date().toString()\n};\n\ncontext.data = context.data || {};\n\nswitch(msg.parts.index){\n case 0:\n context.data.NData = parseFloat(msg.payload);\n msg = null;\n break;\n case 1:\n context.data.Temp_DHT11 = parseFloat(msg.payload);\n msg = null;\n break;\n case 2:\n context.data.Humid_DHT = parseFloat(msg.payload);\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\n\nAllData = context.data.NData &&\n context.data.Temp_DHT11 &&\n context.data.Humid_DHT;\n\nif(AllData){\n var time = Date();\n context.data.Time = time.toString();\n Sensor = context.data;\n newMsg = { payload: context.data,\n topic: 'Frame Sensor' };\n context.data = null;\n return newMsg;\n}\nelse\n return msg;\n\n\n","outputs":1,"noerr":0,"x":490,"y":240,"wires":[["6ea2f4d2.fa18dc","dd3f2d0e.54406","db161a91.1bf308"]]},{"id":"6ea2f4d2.fa18dc","type":"function","z":"99ef7505.c281c8","name":"Split Data","func":"var msgTemp_DHT11 = {payload: msg.payload.Temp_DHT11};\nvar msgHumid_DHT = {payload: msg.payload.Humid_DHT};\n\nreturn [msgTemp_DHT11, msgHumid_DHT];","outputs":2,"noerr":0,"x":695.3627052307129,"y":336.9830274581909,"wires":[["190e0530.f9648b","2fbba10c.d9999e"],["dbcc3883.4d3b78","e6b489b1.c1b568"]]},{"id":"dbcc3883.4d3b78","type":"ui_gauge","z":"99ef7505.c281c8","name":"Humid DHT11","group":"539bb2f8.4cd23c","order":1,"width":0,"height":0,"gtype":"gage","title":"Humid DHT11","label":"","format":"{{value}}%","min":0,"max":"100","colors":["#ffff80","#ff8000","#008000"],"x":990,"y":300,"wires":[]},{"id":"2fbba10c.d9999e","type":"ui_chart","z":"99ef7505.c281c8","name":"Graph 5 min Temp DHT11 (°C)","group":"2b53962a.e11c1a","order":2,"width":0,"height":0,"label":"Graph 5 min Temp DHT11 (°C)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"10","ymax":"40","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":260,"wires":[[],[]]},{"id":"e6b489b1.c1b568","type":"ui_chart","z":"99ef7505.c281c8","name":"Graph 5 min Humid DHT11 (%)","group":"be69083c.111928","order":2,"width":0,"height":0,"label":"Graph 5 min Humid DHT11 (%)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"0","ymax":"100","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":340,"wires":[[],[]]},{"id":"db161a91.1bf308","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":120,"wires":[]},{"id":"a2dd7e6a.214a8","type":"serial-port","z":"","serialport":"COM5","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"0","bin":"bin","out":"time","addchar":"false","responsetimeout":""},{"id":"2b53962a.e11c1a","type":"ui_group","z":"","name":"Sensor DHT11","tab":"ba6c5c45.1e5fb","order":2,"disp":true,"width":"6"},{"id":"539bb2f8.4cd23c","type":"ui_group","z":"","name":"Pressure, Humidity","tab":"ba6c5c45.1e5fb","order":4,"disp":true,"width":"6"},{"id":"be69083c.111928","type":"ui_group","z":"","name":"DHT11: Humid (5 Min)","tab":"ba6c5c45.1e5fb","order":5,"disp":true,"width":"6"},{"id":"ba6c5c45.1e5fb","type":"ui_tab","z":"","name":"MONITORING","icon":"dashboard","order":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:** [16 April 2019 09:20 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/4 "2019-04-16T09:20:31Z")

</div>

```auto
[{"id":"99ef7505.c281c8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"61fee05.2f50b2","type":"serial in","z":"99ef7505.c281c8","name":"","serial":"a2dd7e6a.214a8","x":60,"y":180,"wires":[["ddf9c433.b32258"]]},{"id":"5c3851c1.3b432","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"console":"false","complete":"true","x":510,"y":120,"wires":[]},{"id":"dd3f2d0e.54406","type":"file","z":"99ef7505.c281c8","name":"Sensor Data","filename":"D:\\My Files\\Sensor.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","x":800,"y":160,"wires":[[]]},{"id":"190e0530.f9648b","type":"ui_gauge","z":"99ef7505.c281c8","name":"Temp DHT11","group":"2b53962a.e11c1a","order":1,"width":0,"height":0,"gtype":"gage","title":"Temp DHT11","label":"","format":"{{value}}°C","min":0,"max":"60","colors":["#008000","#ff8000","#ff0000"],"x":980,"y":220,"wires":[]},{"id":"ddf9c433.b32258","type":"function","z":"99ef7505.c281c8","name":"","func":"var newMsg = {payload: msg.payload.toString()};\nreturn newMsg;","outputs":1,"noerr":0,"x":180,"y":180,"wires":[["69577f5b.d860a"]]},{"id":"69577f5b.d860a","type":"split","z":"99ef7505.c281c8","name":"","splt":" ","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":300,"y":180,"wires":[["6ec1d5b5.6fa74c","5c3851c1.3b432"]]},{"id":"6ec1d5b5.6fa74c","type":"function","z":"99ef7505.c281c8","name":"Payload Object Sensor","func":"var newMsg = {};\nvar Sensor = {\n NData: 0, \n Temp_DHT11: 0,\n Humid_DHT: 0,\n Time: new Date().toString()\n};\n\ncontext.data = context.data || {};\n\nswitch(msg.parts.index){\n case 0:\n context.data.NData = parseFloat(msg.payload);\n msg = null;\n break;\n case 1:\n context.data.Temp_DHT11 = parseFloat(msg.payload);\n msg = null;\n break;\n case 2:\n context.data.Humid_DHT = parseFloat(msg.payload);\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\n\nAllData = context.data.NData &&\n context.data.Temp_DHT11 &&\n context.data.Humid_DHT;\n\nif(AllData){\n var time = Date();\n context.data.Time = time.toString();\n Sensor = context.data;\n newMsg = { payload: context.data,\n topic: 'Frame Sensor' };\n context.data = null;\n return newMsg;\n}\nelse\n return msg;\n\n\n","outputs":1,"noerr":0,"x":490,"y":240,"wires":[["6ea2f4d2.fa18dc","dd3f2d0e.54406","db161a91.1bf308"]]},{"id":"6ea2f4d2.fa18dc","type":"function","z":"99ef7505.c281c8","name":"Split Data","func":"var msgTemp_DHT11 = {payload: msg.payload.Temp_DHT11};\nvar msgHumid_DHT = {payload: msg.payload.Humid_DHT};\n\nreturn [msgTemp_DHT11, msgHumid_DHT];","outputs":2,"noerr":0,"x":695.3627052307129,"y":336.9830274581909,"wires":[["190e0530.f9648b","2fbba10c.d9999e"],["dbcc3883.4d3b78","e6b489b1.c1b568"]]},{"id":"dbcc3883.4d3b78","type":"ui_gauge","z":"99ef7505.c281c8","name":"Humid DHT11","group":"539bb2f8.4cd23c","order":1,"width":0,"height":0,"gtype":"gage","title":"Humid DHT11","label":"","format":"{{value}}%","min":0,"max":"100","colors":["#ffff80","#ff8000","#008000"],"x":990,"y":300,"wires":[]},{"id":"2fbba10c.d9999e","type":"ui_chart","z":"99ef7505.c281c8","name":"Graph 5 min Temp DHT11 (°C)","group":"2b53962a.e11c1a","order":2,"width":0,"height":0,"label":"Graph 5 min Temp DHT11 (°C)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"10","ymax":"40","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":260,"wires":[[],[]]},{"id":"e6b489b1.c1b568","type":"ui_chart","z":"99ef7505.c281c8","name":"Graph 5 min Humid DHT11 (%)","group":"be69083c.111928","order":2,"width":0,"height":0,"label":"Graph 5 min Humid DHT11 (%)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"0","ymax":"100","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":340,"wires":[[],[]]},{"id":"db161a91.1bf308","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":120,"wires":[]},{"id":"a2dd7e6a.214a8","type":"serial-port","z":"","serialport":"COM5","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"0","bin":"bin","out":"time","addchar":"false","responsetimeout":""},{"id":"2b53962a.e11c1a","type":"ui_group","z":"","name":"Sensor DHT11","tab":"ba6c5c45.1e5fb","order":2,"disp":true,"width":"6"},{"id":"539bb2f8.4cd23c","type":"ui_group","z":"","name":"Pressure, Humidity","tab":"ba6c5c45.1e5fb","order":4,"disp":true,"width":"6"},{"id":"be69083c.111928","type":"ui_group","z":"","name":"DHT11: Humid (5 Min)","tab":"ba6c5c45.1e5fb","order":5,"disp":true,"width":"6"},{"id":"ba6c5c45.1e5fb","type":"ui_tab","z":"","name":"MONITORING","icon":"dashboard","order":1}]

```

---

<div class="post-metadata">

**Author:** ![emetechnologies](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@emetechnologies](https://discourse.nodered.org/u/emetechnologies)\
**Post date:** [16 April 2019 09:35 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/5 "2019-04-16T09:35:13Z")

</div>

```auto
[{"id":"99ef7505.c281c8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"61fee05.2f50b2","type":"serial in","z":"99ef7505.c281c8","name":"","serial":"a2dd7e6a.214a8","x":60,"y":180,"wires":[["ddf9c433.b32258"]]},{"id":"5c3851c1.3b432","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"console":"false","complete":"true","x":510,"y":120,"wires":[]},{"id":"dd3f2d0e.54406","type":"file","z":"99ef7505.c281c8","name":"Sensor Data","filename":"D:\\My Files\\Sensor.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","x":800,"y":160,"wires":[[]]},{"id":"190e0530.f9648b","type":"ui_gauge","z":"99ef7505.c281c8","name":"Temp DHT11","group":"2b53962a.e11c1a","order":1,"width":0,"height":0,"gtype":"gage","title":"Temp DHT11","label":"","format":"{{value}}°C","min":0,"max":"60","colors":["#008000","#ff8000","#ff0000"],"x":980,"y":220,"wires":[]},{"id":"ddf9c433.b32258","type":"function","z":"99ef7505.c281c8","name":"","func":"var newMsg = {payload: msg.payload.toString()};\nreturn newMsg;","outputs":1,"noerr":0,"x":180,"y":180,"wires":[["69577f5b.d860a"]]},{"id":"69577f5b.d860a","type":"split","z":"99ef7505.c281c8","name":"","splt":" ","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":300,"y":180,"wires":[["6ec1d5b5.6fa74c","5c3851c1.3b432"]]},{"id":"6ec1d5b5.6fa74c","type":"function","z":"99ef7505.c281c8","name":"Payload Object Sensor","func":"var newMsg = {};\nvar Sensor = {\n NData: 0, \n Temp_DHT11: 0,\n Humid_DHT: 0,\n Time: new Date().toString()\n};\n\ncontext.data = context.data || {};\n\nswitch(msg.parts.index){\n case 0:\n context.data.NData = parseFloat(msg.payload);\n msg = null;\n break;\n case 1:\n context.data.Temp_DHT11 = parseFloat(msg.payload);\n msg = null;\n break;\n case 2:\n context.data.Humid_DHT = parseFloat(msg.payload);\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\n\nAllData = context.data.NData &&\n context.data.Temp_DHT11 &&\n context.data.Humid_DHT;\n\nif(AllData){\n var time = Date();\n context.data.Time = time.toString();\n Sensor = context.data;\n newMsg = { payload: context.data,\n topic: 'Frame Sensor' };\n context.data = null;\n return newMsg;\n}\nelse\n return msg;\n\n\n","outputs":1,"noerr":0,"x":490,"y":240,"wires":[["6ea2f4d2.fa18dc","dd3f2d0e.54406","db161a91.1bf308"]]},{"id":"6ea2f4d2.fa18dc","type":"function","z":"99ef7505.c281c8","name":"Split Data","func":"var msgTemp_DHT11 = {payload: msg.payload.Temp_DHT11};\nvar msgHumid_DHT = {payload: msg.payload.Humid_DHT};\n\nreturn [msgTemp_DHT11, msgHumid_DHT];","outputs":2,"noerr":0,"x":695.3627052307129,"y":336.9830274581909,"wires":[["190e0530.f9648b","2fbba10c.d9999e"],["dbcc3883.4d3b78","e6b489b1.c1b568"]]},{"id":"dbcc3883.4d3b78","type":"ui_gauge","z":"99ef7505.c281c8","name":"Humid DHT11","group":"539bb2f8.4cd23c","order":1,"width":0,"height":0,"gtype":"gage","title":"Humid DHT11","label":"","format":"{{value}}%","min":0,"max":"100","colors":["#ffff80","#ff8000","#008000"],"x":990,"y":300,"wires":[]},{"id":"2fbba10c.d9999e","type":"ui_chart","z":"99ef7505.c281c8","name":"Graph 5 min Temp DHT11 (°C)","group":"2b53962a.e11c1a","order":2,"width":0,"height":0,"label":"Graph 5 min Temp DHT11 (°C)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"10","ymax":"40","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":260,"wires":[[],[]]},{"id":"e6b489b1.c1b568","type":"ui_chart","z":"99ef7505.c281c8","name":"Graph 5 min Humid DHT11 (%)","group":"be69083c.111928","order":2,"width":0,"height":0,"label":"Graph 5 min Humid DHT11 (%)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"basis","nodata":"","ymin":"0","ymax":"100","removeOlder":"5","removeOlderUnit":"60","outputs":2,"x":1040,"y":340,"wires":[[],[]]},{"id":"db161a91.1bf308","type":"debug","z":"99ef7505.c281c8","name":"Frame from Sensors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":120,"wires":[]},{"id":"a2dd7e6a.214a8","type":"serial-port","z":"","serialport":"COM5","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"0","bin":"bin","out":"time","addchar":"false","responsetimeout":""},{"id":"2b53962a.e11c1a","type":"ui_group","z":"","name":"Sensor DHT11","tab":"ba6c5c45.1e5fb","order":2,"disp":true,"width":"6"},{"id":"539bb2f8.4cd23c","type":"ui_group","z":"","name":"Pressure, Humidity","tab":"ba6c5c45.1e5fb","order":4,"disp":true,"width":"6"},{"id":"be69083c.111928","type":"ui_group","z":"","name":"DHT11: Humid (5 Min)","tab":"ba6c5c45.1e5fb","order":5,"disp":true,"width":"6"},{"id":"ba6c5c45.1e5fb","type":"ui_tab","z":"","name":"MONITORING","icon":"dashboard","order":1}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 April 2019 09:43 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/6 "2019-04-16T09:43:27Z")

</div>

A good way of debugging a function is to use `node.warn` something like this  
`node.warn("idx ="+msg.parts.index);`

second you should read; [https://nodered.org/docs/writing-functions#storing-data](https://nodered.org/docs/writing-functions#storing-data)  
and look at your function again

---

<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:** [16 April 2019 09:43 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/7 "2019-04-16T09:43:31Z")

</div>

Hey @emetechnologies thanks for getting involved, but just posting a flow without any context as to why is confusing.  
If you are trying to help @mani2411 can you explain how you have changed the flow?  
Or,  
If you are @mani2411, why have you posted the same flow 3 times?

---

<div class="post-metadata">

**Author:** ![emetechnologies](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@emetechnologies](https://discourse.nodered.org/u/emetechnologies)\
**Post date:** [16 April 2019 10:05 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/8 "2019-04-16T10:05:45Z")

</div>

this is due to some poor internet connection.

---

<div class="post-metadata">

**Author:** ![emetechnologies](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@emetechnologies](https://discourse.nodered.org/u/emetechnologies)\
**Post date:** [16 April 2019 10:13 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/9 "2019-04-16T10:13:48Z")

</div>

It is the same flow uploaded by the creator. There was an error submitting the flow so I re-send it on his behalf. Please find any solution for the functions as we are very new to node red and unable to solve this problem.

---

<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 April 2019 20:35 UTC](https://discourse.nodered.org/t/multiple-sensor-data-using-arduino/10206/10 "2019-04-16T20:35:31Z")

</div>

Did you see what I posted in the first reply? To repeat:  
Start by putting a debug node showing what is going into the function and check that is correct. Next you can insert node.warn() statements into your code to show the state of variables as it runs through. The warn text will be shown in the debug pane. If that does not help then post just the function here and show us what is going into it.

You have not followed that advice.
