Skip to main content

modbus-rtu

Communicate with Modbus RTU devices over RS-485 or RS-232 serial connections for industrial sensor and actuator control.

Overview

The modbus-rtu node provides serial communication with Modbus RTU devices over RS-485 or RS-232 interfaces. It supports master and slave modes with configurable baud rates, parity, and CRC-16 error checking for reliable data exchange with industrial sensors, actuators, and controllers.

RS-485
Interface
115200
Max Baud
CRC-16
Error Check
247
Max Devices

Serial Interface Wiring

RS-485 (2-Wire)

Data+ (A) Non-inverting
Data- (B) Inverting
GND Signal ground
Max Distance 1200m (4000ft)

RS-232 (Point-to-Point)

TX (Transmit) Pin 3
RX (Receive) Pin 2
GND Pin 5
Max Distance 15m (50ft)

Properties

Property Type Required Default Description
port string Yes - Serial port path (e.g., /dev/ttyUSB0, COM3)
baudRate number No 9600 Serial baud rate (9600, 19200, 38400, 57600, 115200)
dataBits number No 8 Data bits per frame (7 or 8)
parity string No "none" "none", "even", or "odd"
stopBits number No 1 Stop bits (1 or 2)
slaveId number Yes - Slave device address (1-247)
function string Yes - Modbus function code (e.g., "readInputRegisters")
timeout number No 3000 Response timeout in milliseconds

Inputs

Read Input Registers
{
  "payload": {
    "function": "readInputRegisters",
    "address": 30001,
    "quantity": 4
  }
}
Write Coil
{
  "payload": {
    "function": "writeSingleCoil",
    "address": 1,
    "value": true
  }
}

Outputs

Read Response
{
  "payload": {
    "slaveId": 1,
    "function": "readInputRegisters",
    "address": 30001,
    "values": [2450],
    "crc": "valid"
  },
  "port": "/dev/ttyUSB0",
  "baudRate": 9600
}
Error Response
{
  "error": {
    "code": "0x02",
    "message": "Illegal data address",
    "slaveId": 1
  }
}

Use Cases

Sensor Networks

Connect temperature, humidity, and pressure transmitters on RS-485 multidrop networks spanning hundreds of meters.

Motor Drives

Control variable frequency drives (VFDs) and servo controllers via serial Modbus for speed and torque adjustments.

Legacy Equipment

Interface with older PLCs and industrial equipment that only support RS-485/RS-232 serial communication.

Remote IO

Read and control remote I/O modules distributed across a facility using daisy-chained RS-485 wiring.

Example: RS-485 Sensor Network

Read temperature from multiple sensors on an RS-485 bus.

[
  {
    "id": "rtu-sensor-1",
    "type": "modbus-rtu",
    "port": "/dev/ttyUSB0",
    "baudRate": 9600,
    "parity": "none",
    "slaveId": 1,
    "function": "readInputRegisters",
    "address": 0,
    "quantity": 2
  },
  {
    "id": "rtu-sensor-2",
    "type": "modbus-rtu",
    "port": "/dev/ttyUSB0",
    "baudRate": 9600,
    "parity": "none",
    "slaveId": 2,
    "function": "readInputRegisters",
    "address": 0,
    "quantity": 2
  }
]

Tips & Best Practices

Line Termination: Add 120-ohm termination resistors at both ends of the RS-485 bus to prevent signal reflections.

Biasing Resistors: Use pull-up (A) and pull-down (B) biasing resistors to define bus idle state and prevent floating.

Turnaround Delay: Allow sufficient turnaround time (3.5 character times) between request and response for reliable communication.

USB Adapters: Use quality USB-to-RS-485 adapters (FTDI or CH340 chipset). Avoid generic adapters that may cause timing issues.

Related Nodes