Input Serial Data

Hi Everyone,

I linked an Arduino with weather sensors via a serial port. The data flows and ai can see it in serial monitor. It is basic temperature, humidity etc. And the values are correct.

In Node Red I get the connection connected and add a debug to see the data. The data I see there does not display correct.

I use Grapserial on the PI

I made sure the buadrate is 9600 all the way .
I played with the timeouts on the port...

Should there be any conversion I have to do in the function on the data?

The data I see there does not display correct.

What does the data look like ? ie: example please.

Apologies, I though I did add the examples... :)This is the data from the serial port

This is my serial port config:

This is my Function for the temp:

Here is my Node Red flow

[{"id":"ee557bae.a02638","type":"ui_chart","z":"d971816a.acd5b","name":"Outside Temperature","group":"aa8b42d9.2d49f","order":2,"width":0,"height":0,"label":"Outside Temperature","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1020,"y":2060,"wires":[]},{"id":"f4c2ac16.5b0a3","type":"function","z":"d971816a.acd5b","name":"readTemperature","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;\nvar result = (hum11000)+ (hum2100) + (hum310) + hum4;\nresult = result/100;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":490,"y":2060,"wires":[["629077e1.d47768","9c18d992.68cad8","ee557bae.a02638","9b0cdf43.2425c"]]},{"id":"66c91139.80222","type":"serial in","z":"d971816a.acd5b","name":"","serial":"b8e97986.3ee848","x":190,"y":2400,"wires":[["f4c2ac16.5b0a3","9a558a18.73e028","b2370f2e.1c6ce","f43a55d2.58a868","44f4da4c.5a64a4","4e85ec4b.99ac44","3b18e27d.297e8e"]]},{"id":"629077e1.d47768","type":"debug","z":"d971816a.acd5b","name":"readTemperature","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":730,"y":2020,"wires":[]},{"id":"9c18d992.68cad8","type":"ui_gauge","z":"d971816a.acd5b","name":"Temperature","group":"c29a1ff.3a5f7e","order":2,"width":"5","height":"5","gtype":"gage","title":"Temperature","label":"Deg","format":"{{value}}","min":"-5","max":"50","colors":["#7cc1fa","#006fdd","#ff0202"],"seg1":"20","seg2":"28","x":710,"y":2080,"wires":[]},{"id":"9b0cdf43.2425c","type":"mqtt out","z":"d971816a.acd5b","name":"","topic":"OutsideTemperature","qos":"","retain":"","broker":"bd123c7c.248f6","x":740,"y":2120,"wires":[]},{"id":"9a558a18.73e028","type":"function","z":"d971816a.acd5b","name":"readPressureOutside","func":"var hum1= msg.payload[6]-48;\nvar hum2= msg.payload[7]-48;\nvar hum3= msg.payload[8]-48;\nvar hum4= msg.payload[10]-48;\nvar hum5= msg.payload[11]-48;\nvar result = (hum110000)+ (hum21000) + (hum3100) + (hum410) + hum5;\nresult = result/1000;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":500,"y":2400,"wires":[["be85c68c.c20898","cd3a8494.19c268","dcbe2d4a.41439","99bfe284.24632"]]},{"id":"b2370f2e.1c6ce","type":"function","z":"d971816a.acd5b","name":"readHumidity","func":"var hum1= msg.payload[13]-48;\nvar hum2= msg.payload[14]-48;\nvar hum3= msg.payload[16]-48;\nvar hum4= msg.payload[17]-48;\nvar result = (hum11000)+ (hum2100) + (hum310) + hum4;\nresult = result/100;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":470,"y":2200,"wires":[["e72d8dd7.57567","8f2103e7.7c155","6a9cc33b.d225ac","e2bdce0c.9ad9c"]]},{"id":"f43a55d2.58a868","type":"function","z":"d971816a.acd5b","name":"readAltitude","func":"var hum1= msg.payload[19]-48;\nvar hum2= msg.payload[20]-48;\nvar hum3= msg.payload[21]-48;\nvar hum4= msg.payload[22]-48;\nvar hum5= msg.payload[24]-48;\nvar hum6= msg.payload[25]-48;\nvar result = (hum11000)+ (hum2100) + (hum310) + hum4 + hum5 + hum6;\n//result = result/100;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":470,"y":2580,"wires":[["923d29fb.ae8858","950113e6.77b8d","53fc6edc.ab28e"]]},{"id":"44f4da4c.5a64a4","type":"function","z":"d971816a.acd5b","name":"readAltitudef","func":"var hum1= msg.payload[27]-48;\nvar hum2= msg.payload[28]-48;\nvar hum3= msg.payload[29]-48;\nvar hum4= msg.payload[30]-48;\nvar hum5= msg.payload[32]-48;\nvar hum6= msg.payload[33]-48;\nvar result = (hum11000)+ (hum2100) + (hum310) + hum4 + hum5 + hum6;\n//result = result/100;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":470,"y":2760,"wires":[["2fb1ba7.1a7aa46","c318ad0a.6b871","d4a252b7.ec0ad"]]},{"id":"4e85ec4b.99ac44","type":"function","z":"d971816a.acd5b","d":true,"name":"Temperature from DFRoot","func":"var hum1= msg.payload[58]-48;\nvar hum2= msg.payload[59]-48;\nvar hum3= msg.payload[61]-48;\nvar hum4= msg.payload[62]-48;\n\nvar result = (hum11000)+ (hum2100) + (hum310) + (hum4);\nresult = result/100;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":510,"y":2980,"wires":[["3545fd72.e4f072"]]},{"id":"3b18e27d.297e8e","type":"function","z":"d971816a.acd5b","d":true,"name":"Barometric from DFRoot","func":"var hum1= msg.payload[67]-48;\nvar hum2= msg.payload[68]-48;\nvar hum3= msg.payload[69]-48;\nvar hum4= msg.payload[71]-48;\nvar hum5= msg.payload[72]-48;\n\nvar result = (hum110000)+ (hum21000) + (hum3100) + (hum4*10) + (hum5);\nresult = result/10000;\nvar result1 = {payload:result};\nreturn[result1];","outputs":1,"noerr":0,"x":510,"y":2920,"wires":[["32a860de.30487"]]},{"id":"be85c68c.c20898","type":"debug","z":"d971816a.acd5b","name":"readPressure","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":720,"y":2360,"wires":},{"id":"cd3a8494.19c268","type":"ui_chart","z":"d971816a.acd5b","name":"Outside Pressure","group":"aa8b42d9.2d49f","order":2,"width":0,"height":0,"label":"Outside Pressure","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1010,"y":2380,"wires":[]},{"id":"dcbe2d4a.41439","type":"mqtt out","z":"d971816a.acd5b","name":"","topic":"OutsidePressure","qos":"","retain":"","broker":"bd123c7c.248f6","x":730,"y":2500,"wires":},{"id":"99bfe284.24632","type":"ui_text","z":"d971816a.acd5b","group":"405b9d98.dcf064","order":6,"width":"6","height":"1","name":"Outside - hPa","label":"Outside - hPa","format":"{{msg.payload}}","layout":"row-spread","x":1000,"y":2440,"wires":},{"id":"e72d8dd7.57567","type":"debug","z":"d971816a.acd5b","name":"readHumidity","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":720,"y":2180,"wires":},{"id":"8f2103e7.7c155","type":"ui_gauge","z":"d971816a.acd5b","name":"Outside Humidity","group":"c29a1ff.3a5f7e","order":3,"width":"5","height":"5","gtype":"gage","title":"Outside Humidity","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#fecb3e","#66fb84","#00b500"],"seg1":"","seg2":"","x":1010,"y":2280,"wires":},{"id":"6a9cc33b.d225ac","type":"ui_chart","z":"d971816a.acd5b","name":"Outside Humidity","group":"aa8b42d9.2d49f","order":3,"width":0,"height":0,"label":"Outside Humidity","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1010,"y":2240,"wires":[]},{"id":"e2bdce0c.9ad9c","type":"mqtt out","z":"d971816a.acd5b","name":"","topic":"OutsideHumidity","qos":"","retain":"","broker":"bd123c7c.248f6","x":720,"y":2300,"wires":},{"id":"923d29fb.ae8858","type":"debug","z":"d971816a.acd5b","name":"readAltitude","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":700,"y":2560,"wires":},{"id":"950113e6.77b8d","type":"ui_text","z":"d971816a.acd5b","group":"405b9d98.dcf064","order":4,"width":"6","height":"1","name":"Approx. Altitude Meters","label":"Approx. Altitude Meters","format":"{{msg.payload}}","layout":"row-spread","x":1030,"y":2600,"wires":},{"id":"53fc6edc.ab28e","type":"mqtt out","z":"d971816a.acd5b","name":"","topic":"OutsideAltitude","qos":"","retain":"","broker":"bd123c7c.248f6","x":700,"y":2640,"wires":},{"id":"2fb1ba7.1a7aa46","type":"debug","z":"d971816a.acd5b","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":700,"y":2740,"wires":},{"id":"c318ad0a.6b871","type":"ui_text","z":"d971816a.acd5b","group":"405b9d98.dcf064","order":3,"width":"6","height":"1","name":"Approx. Altitude Feet","label":"Approx. Altitude Feet","format":"{{msg.payload}}","layout":"row-spread","x":1020,"y":2800,"wires":},{"id":"d4a252b7.ec0ad","type":"mqtt out","z":"d971816a.acd5b","name":"","topic":"OutsideAltitudef","qos":"","retain":"","broker":"bd123c7c.248f6","x":700,"y":2840,"wires":},{"id":"3545fd72.e4f072","type":"debug","z":"d971816a.acd5b","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":800,"y":2980,"wires":},{"id":"32a860de.30487","type":"debug","z":"d971816a.acd5b","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":800,"y":2920,"wires":},{"id":"aa8b42d9.2d49f","type":"ui_group","z":"","name":"Chart","tab":"7755a63f.7986a8","order":2,"disp":true,"width":"6","collapse":false},{"id":"b8e97986.3ee848","type":"serial-port","z":"","serialport":"/dev/ttyACM1","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"3600","bin":"bin","out":"time","addchar":"","responsetimeout":"10000"},{"id":"c29a1ff.3a5f7e","type":"ui_group","z":"","name":"Outside","tab":"46a35ba4.6ae124","order":3,"disp":true,"width":"6","collapse":false},{"id":"bd123c7c.248f6","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"NodeRedSQLClient","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"405b9d98.dcf064","type":"ui_group","z":"","name":"Wind","tab":"46a35ba4.6ae124","order":4,"disp":true,"width":"6","collapse":false},{"id":"7755a63f.7986a8","type":"ui_tab","z":"","name":"Chart","icon":"dashboard","disabled":false,"hidden":false},{"id":"46a35ba4.6ae124","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Please export your flow again, read this post and edit your post. And preferably only export the nodes that give you problems and use an inject node to emulate your problem. (as we don't have your device)

Hi.

I would first recommend an actual split character rather than after 3600 ms as your flow of data could be mid stream when that time occurs.

If you are in control of the data being sent from the Arduino, I would strongly suggest you format it in a manor that is easily and safely decoded at the node-red side.

For example, generate valid JSON at the Arduino then you and easily and with 100% certainty access the correct data parts from the serial data stream.

If you don't know how to do this, give us a shout

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