#StackBounty: #arduino #serial-port #node-red Serial communication to Arduino via node-red sends in "wrong" format

Bounty: 50

I have two Arduinos hooked together via ports 8 and 9 and trying to communicate between them using SoftwareSerial and a Node-red server. The first Arduino is connected to a computer running node-red and running this code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9); // RX, TX

int incomingByte;

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

void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    mySerial.print(incomingByte);
  }
}

The second Arduino is connected to another computer running the serial monitor and running this code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9); // RX, TX

int incomingByte;

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

void loop() {
  if (mySerial.available() > 0) {
    incomingByte = mySerial.read();
    Serial.println(incomingByte);
  }
}

The node-red sketch is very simple and is just an inject into a serial out. The inject just sets msg.payload to "H". I have another one that sets it to "L". When I press the inject, I get the following from the H via the serial monitor:

55
50

When I inject the "L" I get the following:

55
54

And when I tried injecting "HELLO", I get this:

55
50
54
57
55
54
55
54
55
57

I’m not sure what I’m doing wrong, but I expected to get something that is equivalent to "H" in some way. Node-red serial output is configured with 9600 baud as defined in the code.

Node-red screenshot


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.