Read Modbus RTU holding registers over a serial connection using pymodbus

domain: pymodbus.readthedocs.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Import the serial sync client: from pymodbus.client import ModbusSerialClient
  2. Instantiate client = ModbusSerialClient(port='/dev/ttyUSB0', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=3)
  3. Call client.connect(); framer defaults to RTU binary framing
  4. Read registers the same way as TCP: result = client.read_holding_registers(0, 10, slave=1); check result.isError()
  5. On a shared RS-485 bus, poll multiple devices by varying the slave id per call with a short delay between polls
  6. Call client.close() when finished polling

Known gotchas

Related routes

Read Modbus TCP holding/input registers from a device using pymodbus
pymodbus.readthedocs.io · 6 steps · unrated
Read Modbus Holding Registers (function code 03) vs Input Registers (function code 04) with correct addressing
iot · 5 steps · unrated
Read inverter registers from a SunSpec-compliant device using Modbus TCP
sunspec.org · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans