Topic hub

Industrial IoT

Getting data out of meters, drives and controllers on the low-voltage side. Modbus RTU and TCP, OPC UA, MQTT Sparkplug 3.0.0, fieldbus gateways and the wiring rules that keep RS-485 reliable.

Updated 28 November 2026 · Modbus RTU, Modbus TCP, RS-485, OPC UA, IEC 62541, Sparkplug, report by exception, fieldbus gateway, store and forward, open62541, PyModbus

Overview

Industrial IoT mostly means getting data out of equipment that already exists: energy meters, variable-speed drives, programmable logic controllers (PLCs) and remote I/O. It speaks old, stable protocols over RS-485 or Ethernet, and a gateway reads it and publishes the result. This hub is for makers reading an inverter or a heat pump and for product teams building a gateway that stays in a plant for years.

This site covers the low-voltage signal side only: the RS-485 pair, the Ethernet port and the gateway. The terminals of drives, meters and panels often sit next to mains or higher voltages. Wiring inside those enclosures is work for a qualified electrician, and nothing here is a guide to it.

Key ideas

Modbus is a register map, not a data model

The MODBUS Application Protocol Specification (V1.1b3, 26 April 2012) defines four tables: discrete inputs (single bits, read-only), coils (single bits, read-write), input registers (16-bit words, read-only) and holding registers (16-bit words, read-write). Each table allows 65536 items, and multi-byte values travel big-endian, most significant byte first. A protocol data unit (PDU) is at most 253 bytes, which makes a serial frame 256 bytes and a Modbus TCP frame 260 bytes.

The protocol has no types beyond bits and 16-bit words, no units and no names. A 32-bit float or a scaled temperature exists only in the maker’s register list. The data model numbers elements from 1 while the PDU addresses them from 0, and the mapping to the device is vendor specific.

Modbus TCP uses port 502 (IANA service name mbap). The 7-byte header it adds holds a transaction number, a protocol number, a length and a unit identifier, and nothing that authenticates the sender. The Modbus/TCP Security specification (MB-TCP-Security-v36, 30 July 2021) wraps it in Transport Layer Security (TLS) v1.2 or newer, with mutual authentication and x.509v3 certificates that carry a role, on port 802 (mbap-s). Check whether each device implements it, and plan network separation for plain port 502 traffic (security hub).

RS-485 rules that the Modbus serial guide states

The MODBUS over Serial Line guide (V1.02, 20 December 2006), which the Modbus Organization recommends for new designs, sets these rules:

  • One master and up to 247 slaves, addresses 1 to 247. Slaves never transmit unless asked.
  • Every device must implement RTU mode, which is the default. The default parity is even. 9600 and 19200 bit/s are required, and 19200 is the default.
  • 32 devices are always allowed on a segment without a repeater.
  • The trunk may run 1000 m at 9600 baud with AWG26 or thicker cable. Drops (stubs) are never longer than 20 m.
  • Terminate both ends of the trunk, and only the ends: 150 Ω, or 120 Ω in series with 1 nF where the line is polarised. Polarisation resistors (450 Ω to 650 Ω) go in one place for the whole bus.
  • Connect the signal common to protective ground at one point only.

Built-in termination or bias resistors on a USB-to-RS-485 adapter count towards these limits.

RS-485 segment (low voltage)meterdriveI/Oaddr 1addr 2addr 3LTLTtrunk up to 1000 m at 9600 baud, drops at most 20 mGatewayModbus masterpolls registersSparkplug edge nodeWill = NDEATHbuffers if host downMQTT serverPrimary hostOther hostNBIRTH, NDATAdataSTATE
A Modbus RTU segment read by a gateway that publishes Sparkplug B. The trunk has a line termination (LT) at each end only, and the gateway registers NDEATH as its MQTT Will Message. Values from MODBUS over Serial Line V1.02 and Sparkplug 3.0.0.

OPC UA: typed, browsable and secured by design

OPC Unified Architecture (OPC UA), released by the OPC Foundation in 2008, is a platform-independent, service-oriented architecture. Where Modbus gives you numbered registers, OPC UA gives you an information model: named, typed nodes you can browse, read, write and subscribe to. Security is part of the base design, with encrypted sessions, signed messages, X.509 certificate authentication, user access rights and auditing. The specification is the OPC 10000 series, parts 1 to 26 at release 1.05.0x as of November 2026, and IEC publishes it as IEC 62541. The binary protocol uses port 4840 (opcua-tcp), with 4843 registered for OPC UA over TLS.

OPC UA also has a publish-subscribe model. Part 14 (release 1.05.06, 22 October 2025) maps it to UDP and Ethernet without a broker, and to MQTT and AMQP brokers, with binary (UADP) or JSON messages.

Sparkplug makes MQTT stateful

Plain MQTT says nothing about topic names, payloads or device liveness. Sparkplug defines all three. The current specification is Sparkplug 3.0.0 (title page dated 16 November 2022), and its clients are ordinary MQTT 3.1.1 or 5.0 clients.

  • Topics follow namespace/group_id/message_type/edge_node_id/[device_id], with namespace spBv1.0. Payload format A is deprecated, and format B is encoded with Google Protocol Buffers.
  • Message types are NBIRTH, NDEATH, DBIRTH, DDEATH, NDATA, DDATA, NCMD, DCMD and STATE.
  • A death certificate is registered as the MQTT Will Message in the CONNECT packet, so it reaches subscribers even when the gateway vanishes without a clean disconnect.
  • Data SHOULD be sent by report by exception: full values in the birth message, then only changes. NDATA and DDATA go at QoS 0. The birth and death messages are what tell a host its values are current.
  • An edge node may name one Primary Host Application. If that host’s STATE shows it offline, the edge node can store data and send it later, flagged is_historical.

The Eclipse Foundation runs a Sparkplug 3.0 compatibility programme with a technology compatibility kit (TCK).

Reliability lives in the gateway

The Modbus TCP Unit Identifier lets one IP address front a whole serial bus, so one gateway fault takes the whole bus offline. The master runs one transaction at a time, so poll only the registers you need, at the rate the process changes. Buffer at the edge when the uplink fails, and mark buffered data as historical so it never overwrites a live value.

For makers

Buy an isolated USB-to-RS-485 adapter, find the device’s register list, and read one holding register with PyModbus or the Home Assistant Modbus integration before writing anything. Check the address offset, the byte and word order, and the scaling against the device’s own display. Never open a panel to reach the terminals. Use an existing low-voltage port.

For product teams

Treat each gateway as a single point of failure. Pick Sparkplug for MQTT-based sites so liveness is in the protocol, ask vendors for TCK listing, and keep plain Modbus TCP on a separated network unless devices support Modbus/TCP Security. For OPC UA, budget for certificate management on every server and client.

Where to start

Read /learn/beginner/07-mqtt-basics/ first, since Sparkplug and OPC UA PubSub both sit on MQTT. /learn/beginner/05-sensors-over-i2c/ teaches the habit of reading a register map from a datasheet, which is most of Modbus work. The gateways hub covers brokers, bridges and storage behind the gateway. The messaging hub compares MQTT with CoAP and HTTP, and the hardware design hub covers gateway boards.

Tools and platforms

Versions as of 28 November 2026.

Job Pick Why, from its own documentation
Read Modbus into a home server Home Assistant Modbus integration TCP, UDP, RTU over TCP and serial; all four register types; YAML configuration
Modbus in visual flows node-red-contrib-modbus 5.62.1 TCP and serial client, read, write and flex nodes, plus a test server
Script, test or simulate Modbus PyModbus 3.16.2 Client, server and simulator over serial, TCP, TLS and UDP; BSD licence
Embed OPC UA in C open62541 C99, MPL 2.0, certified for the Standard UA Server Profile 2017
Sparkplug reference code Eclipse Tahu Client libraries and reference implementations, EPL-2.0
MQTT server for Sparkplug Eclipse Mosquitto Implements MQTT 5.0, 3.1.1 and 3.1, which Sparkplug clients use

Common mistakes

  • Off-by-one register addresses: the manual numbers from 1, the request from 0.
  • Assuming a word order for 32-bit values. The specification defines only 16-bit registers, so check the device’s list.
  • Termination at every device, or none, instead of at the two ends of the trunk.
  • Drops longer than the 20 m the serial guide allows.
  • Publishing Sparkplug data on a timer instead of by exception, which the specification advises against.
  • Putting plain Modbus TCP on a network that untrusted devices can reach.

Going deeper