Extract numbers from serial input

The task is probably simple to do, but after trying all examples i can find on the topic, i'm still struggling. So i'm not posting any of my non working flow :slight_smile:

I read a serial input, and want to extract only the numbers so i can use the values further in my flow for example in a chart or gauge. Preferably by using existing nodes, split, change etc.

[{"id":"0221fe0db6b96fa3","type":"serial in","z":"4656a7ccbca6a363","name":"","serial":"28e2a41a4b0a9950","x":990,"y":280,"wires":[["b9ab1baf53647282"]]},{"id":"28e2a41a4b0a9950","type":"serial-port","name":"","serialport":"COM8","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"}]

You have shared a single Serial In node

No users actually have access to your device so that is pretty pointless. In cases like this, it is helpful to provide dummy data via inject nodes instead.

Questions:

  1. What generates the serial data and do you have control over that (i.e. could you change it to a sensible/parse-able format)?
  2. Is there a protocol sheet you can share?

I was hoping that the debug info could help, but I see that this was to little info.

I read a senserion SHT sensor with a Arduino UNO. This is the serial print i use in the Arduino:

Serial.print("SHT85nr5:\n");
Serial.print(" RH: ");
Serial.print(sht.getHumidity(), 2);
Serial.print("\n");
Serial.print(" T: ");
Serial.print(sht.getTemperature(), 2);
Serial.print("\n");

I guess to simulate one value with inject would be something like this?
image
image

You would be better of having the arduino send a properly formatted JSON
This may help How to do serial communication between two boards? | ArduinoJson 6

It would be much better to send these in one go in a JSON formatted string. Build a string that looks something like

{"rh": 65, "t": 30}

Then when node red receives that, feed it through a JSON node, which will convert it to a javascript object, which you can do what you want with.

Thanks,
I think my solution is not exactly as smooth as the intention with suggestions here, but this is what I could manage out from the tips.

Arduino UNO:
Serial.print(sht.getHumidity(), 2);
Serial.print(",");
Serial.print(sht.getTemperature(), 2);
Serial.print("\n");

[{"id":"4656a7ccbca6a363","type":"tab","label":"Flow 11","disabled":false,"info":"","env":[]},{"id":"0268d882db65fd61","type":"serial in","z":"4656a7ccbca6a363","name":"","serial":"28e2a41a4b0a9950","x":450,"y":120,"wires":[["664986f8eb4d35a7"]]},{"id":"664986f8eb4d35a7","type":"csv","z":"4656a7ccbca6a363","name":"","spec":"rfc","sep":",","hdrin":"","hdrout":"all","multi":"one","ret":"\\r\\n","temp":"RH,T","skip":"0","strings":false,"include_empty_strings":false,"include_null_values":false,"x":590,"y":160,"wires":[["3da911677b658c1c","a762704eb1091d95"]]},{"id":"8710a581bf3258ad","type":"debug","z":"4656a7ccbca6a363","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1300,"y":120,"wires":[]},{"id":"3da911677b658c1c","type":"split","z":"4656a7ccbca6a363","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":730,"y":160,"wires":[["c6761f0d01bd6b32"]]},{"id":"af4e227fad55949e","type":"switch","z":"4656a7ccbca6a363","name":"","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"RH","vt":"str"},{"t":"eq","v":"T","vt":"str"}],"checkall":"true","repair":true,"outputs":2,"x":970,"y":160,"wires":[["bbf51e9a1c1448ad"],["3e02199ec808e680"]]},{"id":"b387856fbee04b83","type":"debug","z":"4656a7ccbca6a363","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1300,"y":200,"wires":[]},{"id":"c6761f0d01bd6b32","type":"json","z":"4656a7ccbca6a363","name":"","property":"payload","action":"obj","pretty":false,"x":850,"y":160,"wires":[["af4e227fad55949e"]]},{"id":"8e73c6b50161d62a","type":"ui_gauge","z":"4656a7ccbca6a363","name":"","group":"da8d7d36988223dc","order":5,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"C","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":1310,"y":80,"wires":[]},{"id":"c3f3b26a425e39f9","type":"ui_gauge","z":"4656a7ccbca6a363","name":"","group":"da8d7d36988223dc","order":6,"width":0,"height":0,"gtype":"gage","title":"Humidity","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":1300,"y":240,"wires":[]},{"id":"bbf51e9a1c1448ad","type":"change","z":"4656a7ccbca6a363","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Temperature","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":120,"wires":[["8710a581bf3258ad","8e73c6b50161d62a","4742f328a4b8e494"]]},{"id":"3e02199ec808e680","type":"change","z":"4656a7ccbca6a363","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Humidity","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":200,"wires":[["b387856fbee04b83","c3f3b26a425e39f9","4742f328a4b8e494"]]},{"id":"4742f328a4b8e494","type":"ui_chart","z":"4656a7ccbca6a363","name":"","group":"da8d7d36988223dc","order":6,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1290,"y":160,"wires":[[]]},{"id":"954246b950b69c22","type":"inject","z":"4656a7ccbca6a363","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"33.33,44.44","payloadType":"str","x":430,"y":200,"wires":[["664986f8eb4d35a7"]]},{"id":"a762704eb1091d95","type":"file","z":"4656a7ccbca6a363","name":"test.txt","filename":"C:\\pellesTestMappe\\test.txt","filenameType":"str","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":730,"y":200,"wires":[[]]},{"id":"28e2a41a4b0a9950","type":"serial-port","name":"","serialport":"COM8","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"},{"id":"da8d7d36988223dc","type":"ui_group","name":"Graf","tab":"5935c569c1b3150f","order":5,"disp":true,"width":24,"collapse":false,"className":""},{"id":"5935c569c1b3150f","type":"ui_tab","name":"ch1-4","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

What are you now getting from the COM node? If you are generating JSON as suggested you should not need the CSV, Split, or Switch nodes.