Skip to main content

serial

UART serial communication for GPS modules, Arduino, sensor arrays, and industrial equipment.

Overview

The serial node provides UART (Universal Asynchronous Receiver/Transmitter) communication for connecting GPS modules, Arduino boards, Modbus devices, industrial sensors, and other serial equipment.

2
Wires (TX/RX)
115200
Default Baud
3.3V
Logic Level
Full
Duplex

Voltage Level Warning

Raspberry Pi uses 3.3V logic. Never connect 5V serial devices directly! Use a logic level converter for Arduino (5V) or RS-232 devices. Direct 5V connection can damage your Pi.

Raspberry Pi Serial Ports

Primary UART (ttyAMA0)

TX (Transmit) GPIO 14 (Pin 8)
RX (Receive) GPIO 15 (Pin 10)
Used for Bluetooth on Pi 3/4 by default

Enable UART

# Edit /boot/config.txt
enable_uart=1

# Disable Bluetooth (use full UART)
dtoverlay=disable-bt

# Or use mini UART for Bluetooth
dtoverlay=miniuart-bt

Properties

Property Type Required Default Description
port string Yes - Serial port path (e.g., /dev/ttyAMA0)
baudRate number No 9600 Communication speed
dataBits number No 8 Data bits (5, 6, 7, or 8)
parity string No "none" "none", "even", "odd", "mark", "space"
stopBits number No 1 Stop bits (1 or 2)
split string No "\n" Character to split input on

Common Baud Rates

9600
GPS, basic sensors
19200
Modbus RTU
115200
Arduino, ESP32
921600
High-speed debug

Inputs

msg.payload

Data to send over serial. Can be string or buffer.

// Send string
msg.payload = "AT+GMR\r\n";

// Send bytes
msg.payload = Buffer.from([0x01, 0x03, 0x00, 0x00]);

return msg;

Outputs

Received Data
{
  "payload": "$GPGGA,123519,4807.038...",
  "port": "/dev/ttyAMA0",
  "_serial": {
    "baudRate": 9600,
    "bytesReceived": 82
  }
}

Common Use Cases

GPS Module

Parse NMEA sentences from GPS

Port: /dev/ttyAMA0

Baud: 9600

Split: \n

Arduino Communication

Exchange data with Arduino

Port: /dev/ttyUSB0 (USB)

Baud: 115200

Level converter needed!

Modbus RTU

Industrial sensor protocol

Port: /dev/ttyUSB0

Baud: 19200

Config: 8N1

ESP32/ESP8266

AT commands or custom protocol

Port: /dev/ttyAMA0

Baud: 115200

3.3V compatible

Example: GPS Position Tracker

Parse GPS NMEA data and extract coordinates.

serial (GPS) function map widget
// Function node to parse GPGGA sentence
var line = msg.payload;

if (!line.startsWith('$GPGGA')) {
    return null;
}

var parts = line.split(',');

// Parse latitude (ddmm.mmmm)
var lat = parseFloat(parts[2]);
var latDeg = Math.floor(lat / 100);
var latMin = lat - (latDeg * 100);
var latitude = latDeg + (latMin / 60);
if (parts[3] === 'S') latitude = -latitude;

// Parse longitude (dddmm.mmmm)
var lon = parseFloat(parts[4]);
var lonDeg = Math.floor(lon / 100);
var lonMin = lon - (lonDeg * 100);
var longitude = lonDeg + (lonMin / 60);
if (parts[5] === 'W') longitude = -longitude;

msg.payload = {
    latitude: latitude,
    longitude: longitude,
    satellites: parseInt(parts[7]),
    altitude: parseFloat(parts[9])
};

return msg;

Troubleshooting

No data received
  • Check TX→RX and RX→TX wiring (crossed)
  • Verify baud rate matches device
  • Ensure UART is enabled in /boot/config.txt
  • Check permissions: sudo usermod -a -G dialout $USER
Garbled/corrupted data
  • Baud rate mismatch - try common values
  • Check data bits, parity, stop bits (usually 8N1)
  • Voltage level mismatch - use logic converter
  • Ground not connected between devices
Permission denied on port
sudo usermod -a -G dialout $USER
sudo usermod -a -G tty $USER
# Log out and back in

Related Nodes