Nan error on temp & humidity data

http://127.0.0.1:1880/#flow/182883fd.98030c
i use node red with arduino to show the temp and humidity
but agn and agn it show the error like msg.playground: number nan
means not showing the value in number
how can i solve this peoblem
i use TEMP FUNCTION :-1:
var temp1= msg.payload[6]-48;
var temp2= msg.payload[7]-48;
var temp3= msg.payload[9]-48;
var temp4= msg.payload[10]-48;
var result = (temp11000)+ (temp2100) + (temp310) + temp4;
result = result/100;
var result1 = {payload:result};
return[result1];
i use HUMIDITY FUNCTION :-
var hum1= msg.payload[0]-48;
var hum2= msg.payload[1]-48;
var hum3= msg.payload[3]-48;
var hum4= msg.payload[4]-48;
var result = (hum1
1000)+ (hum2100) + (hum310) + hum4;
result = result/100;
var result1 = {payload:result};
return[result1];
then i use clipboard to import code :-
[{"id":"74e0880a.c777f8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"e26c53af.cca2b","type":"serial in","z":"74e0880a.c777f8","name":"","serial":"58430f06.f23e4","x":137.5173568725586,"y":193.7500286102295,"wires":[["e45d22bf.57606","e06252b0.156d2"]]},{"id":"e45d22bf.57606","type":"function","z":"74e0880a.c777f8","name":"Temp","func":"\nvar temp1= msg.payload[6]-48;\nvar temp2= msg.payload[7]-48;\nvar temp3= msg.payload[9]-48;\nvar temp4= msg.payload[10]-48;\n\nvar result = (temp11000)+ (temp2100) + (temp310) + temp4; \nresult = result/100;\n\nvar result1 = {payload:result};\n\nreturn[result1];","outputs":1,"noerr":0,"x":307.07645416259766,"y":92.56599521636963,"wires":[["d914ac8d.cd404","9f2a37c9.0d8f88"]]},{"id":"d914ac8d.cd404","type":"debug","z":"74e0880a.c777f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false, "complete":"false","x":581.3498992919922,"y":37.79081916809082,"wires":[]},{"id":"e06252b0.156d2","type":"function","z":"74e0880a.c777f8","name":"Humidity","func":"var hum1= msg.payload[0]-48;\nvar hum2= msg.payload[1]-48;\nvar hum3= msg.payload[3]-48;\nvar hum4= msg.payload[4]-48;\n\nvar result = (hum11000)+ (hum2100) + (hum310) + hum4; \nresult = result/100;\n\nvar result1 = {payload:result};\n\nreturn[result1];","outputs":1,"noerr":0,"x":315.0911521911621,"y":286.6883945465088,"wires":[["f35a3030.d7841","f7b0f890.f22e18"]]},{"id":"f35a3030.d7841","type":"debug","z":"74e0880a.c777f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false, "complete":"false","x":582.6041069030762,"y":361.12417221069336,"wires":},{"id":"9f2a37c9.0d8f88","type":"ui_gauge","z":"74e0880a.c777f8","name":"Temp","group":"d5da3e9b.46abf","order":0,"width":0, "height":0,"gtype":"gage","title":"temp","label":"units","format":"{{value}} °C","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":570.0998001098633,"y":99.71789360046387,"wires":},{"id":"f7b0f890.f22e18","type":"ui_gauge","z":"74e0880a.c777f8","name":"Humidity","group":"d5da3e9b.46abf","order":1,"width":0, "height":0,"gtype":"gage","title":"Humidity","label":"units","format":"{{value}}%","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":583.8411865234375,"y":288.4635429382324,"wires":},{"id":"58430f06.f23e4","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":"d5da3e9b.46abf","type":"ui_group","z":"","name":"DHT11","tab":"784aac14.5c2404","order":2,"disp":true,"width":"6", "collapse":false},{"id":"784aac14.5c2404","type":"ui_tab","z":"","name":"Station","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

how can i show data in number format

Please use the </> icon here in the editor and paste your code in between the backticks.

If you get NaN, you receive: not a number. Attach a debug node to the com5 node and see what you receive.


After doing this i see both nan and number both are coming
i want to show only number not in nan

That debug shows you are getting NAN and

If you have control of the code on the Arduino, you should send an json object with the temp and humidity in it.

Or you could just filter out NaN in your function nodes.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.