Displaying Multiple serial entries as separate lines node red

Hi All, huge noob here and i need help. im working towards being able to cast up to 20 voltage readings from an arduino serial print to node red, but want to show them just as separate lines. however i can't seem to get it to work just on a test basis of experimenting.

for my learning purposes i just want to serial.print 2 line statements that i've separated with a colon and 'newlined' with "\n"

tried various guides where they use function but it doesn't do anything for me. both my statements just appear as 1 message line.

here's the e.g. serial print structure (ignore the LED thing):

void loop() {


digitalWrite(led, HIGH);
led_on = digitalRead(led);
if(led_on == HIGH)
{
Serial.print("3 Second LED");
Serial.print(",");
Serial.print("test");
Serial.print("\n");
}
delay (3000);

in node-red i've done a function that takes the serial in and splits it to 2 messages, the details of the function are:

var outputMsgs = [];
var values = msg.payload.trim().split(",");
for(var v in values){
    outputMsgs.push({payload:values[v]});
}
return msg;

however it is just showing in message 1: "3 second LED:test"

any help is greatly appreciated.

Home
Arduino 1 MSG: 3 Second LED,test

Arduino 1 MSG:

just an FYI that is what it outputs on dashboard for node-red

You have not assigned outputMsgs to msg or a property of msg. So it returns the original msg.
Or try
return outputMsgs;

Oh my god. I hate when it's a simple thing invisible due to tunnel vision. Thanks man! All working as expected!

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