Problem with sending of commends to Serial Connection

Hello all,

I am relatively new to using Node-Red. I want to connect an external device via a USB RS232 interface to send and read commands. Connection and readout works fine, but sending commands causes me problems. For comparison with a Python script I can send data and get my desired information, that works. With Node-Red I can use the port equally for reading as with the Python Scrypt. But when I try to send the string I get no response. I am sure that the error is in the processing before sending the message.

I want to send the string "RF8 S\r\n" to my device to get the response.

What am I doing wrong? Can anyone help me?

Here is my Python Script:

import time
import serial

# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(
# Reading the data from the serial port. This will be running in an infinite loop.

while 1 :
        # get keyboard input
        test = "RF8 S\r\n"
        encoded = test.encode()
        print(f"encoded: {encoded}")
        bytesToRead = ser.inWaiting()
        data =
        print(f"data: {data}")

Output with Python Script:

encoded: b'RF8 S\r\n'
data: b'0112102\r\n'
encoded: b'RF8 S\r\n'
data: b'0112102\r\n'
encoded: b'RF8 S\r\n'
data: b'0112102\r\n'
encoded: b'RF8 S\r\n'
data: b'0112102\r\n'
encoded: b'RF8 S\r\n'
data: b'0112102\r\n'
encoded: b'RF8 S\r\n'

Output while just Sending with running Python Script and aserial in Block:

My Current Node-Red Solution that dont work:

I Inject this:
msg.payload = "RF8 S\r\n"

Function1 Block:

var buf = Buffer.from(msg.payload, "utf-8");

//msg.payload = msg.payload.toString('latin1');

msg.payload = buf;

return msg;

Please provide the flow data here - so one can check what's happening.
If you're unsure how to do this: Make sure your flow-in-question is currently shown, then open the Hamburger menu (top right corner), click Export, select Current flow, then press the Copy to clipboard button; close the dialog & then paste the data here. Please surround it with the Preformatted Text function in the button bar of this editor window; otherwise it's almost unreadable...

Try to modify your code in function 1 node to something like this

var buf = Buffer.from([0x52, 0x46, 0x38, 0x20, 0x53 , 0x0D, 0x0A]);
msg.payload = buf;
return msg;

And I am not sure if the serial request node can work together with the serial out node, so why not delete one of them and try.

By the way, a corresponding post has been discussed in this forum already.
How to send this HEX command to my device using Node-red - General - Node-RED Forum (

1 Like

Don't connect both a request node and output and input nodes at the same time. Either connect a request node, or a pair on Out/In

And, in fact, delete the ones you are not using.

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