Modbus RTU#

A connection type for ModbusDevice

Modbus RTU

Modbus RTU is a connection type for ModbusDevice, not a separate driver class: set "transport": "rtu" in the config’s connection block, or pass a ModbusRTUTransport explicitly. The Python code is identical to Modbus TCP; only the connection block changes.

Creating a ModbusDevice over RTU#

{
  "version": 1,
  "protocol": "modbus",
  "device": {
    "name": "field_sensor",
    "description": "RS-485 field temperature sensor"
  },
  "connection": {
    "transport": "rtu",
    "port": "/dev/ttyUSB0",
    "baudrate": 9600,
    "parity": "N",
    "stopbits": 1,
    "bytesize": 8,
    "timeout": 2.0,
    "unit_id": 1
  },
  "registers": [
    {
      "name": "temperature",
      "starting_address": 0,
      "register_type": "input",
      "data_type": "float32",
      "poll": true
    }
  ]
}
from instro.modbus import ModbusDevice

device = ModbusDevice(config="field_sensor.json")
device.open()

Parameters and methods specific to ModbusDevice can be found in the Reference.