Modbus TCP Gateway and Modbus to MQTT
Това съдържание още не е налично на вашия език.
You have a meter, a drive, or a PLC that speaks Modbus, and something upstream that wants the values on MQTT. This is the shortest path with HotLoop, and it keeps working when the network does not.
There are three ways. Pick by what the box is for.
| Path | Use it when |
|---|---|
| Edge Relay | You want a headless box at the machine that polls and forwards, with no database and no screen. |
| Gateway, Edge, or IoT | You want screens, alarms, and a historian beside the polling, and a broker in the same process. |
| Flow | You want to wire it yourself, with a transform between the register and the topic. |
A Modbus to MQTT gateway for the line you already run
Section titled “A Modbus to MQTT gateway for the line you already run”Move Modbus to MQTT in one hop and keep the tags in a namespace you own. Try HotLoop free.
Modbus TCP gateway: pick the word order your manual prints
Section titled “Modbus TCP gateway: pick the word order your manual prints”Vendors disagree about which register comes first in a float32. HotLoop supports all four word orders under the names vendor manuals print: ABCD, CDAB, BADC and DCBA. Set a device default and override it per tag. The result is the float the device holds, on the first read.
Type your own two registers into the word-order demo below.
Modbus to MQTT in one step
Section titled “Modbus to MQTT in one step”HotLoop reads Modbus TCP and RTU devices and publishes the values to your MQTT broker as plain topics or as Sparkplug B. It serves the same values on OPC UA. Put the headless Edge Relay on any low-cost box next to the machine: readings queue to disk when the uplink dies and replay when it returns. You keep the data, and you lose the glue code.
Follow Modbus to MQTT step by step.
A PLC gateway for the whole plant
Section titled “A PLC gateway for the whole plant”Modbus is the 1979 workhorse of plant data. HotLoop is a PLC gateway with eighteen native drivers, so the same box reads OPC UA, EtherNet/IP, S7comm, MTConnect and more beside Modbus. The Modbus driver is verified against real Modbus servers over TCP on bare metal, tested 2026-11-17, and every driver lists what it was tested against. Add the history and the alarms in the HotLoop Gateway and one tool covers the site.
With the Edge Relay
Section titled “With the Edge Relay”You need a broker to publish to and a Sparkplug group id. The relay reads one device file, and the device is a Modbus device by protocol and address.
{ "devices": [ { "id": "meter-01", "name": "Line meter", "protocol": "modbus", "address": "10.0.1.50:502", "enabled": true, "pollIntervalMs": 1000 } ], "tags": [ { "deviceId": "meter-01", "name": "Voltage", "address": "holding:100:float32:CDAB", "dataType": "float", "enabled": true } ]}Install the relay with Helm or Podman Quadlet and point it at the broker. From then on every reading goes out as a Sparkplug B edge node, with births, sequence numbers, and deaths the way the specification says.
Write the register address the way the manual prints it
Section titled “Write the register address the way the manual prints it”Modbus mistakes are quiet. A float across two registers with the wrong word order is a plausible number that is not the truth, so read these four lines before you trust a screen.
holding:100:float32:CDAB a float across registers 100-101, word-swappedholding:40:bit3 bit 3 of register 40input:12:int16 a signed input registercoil:5 a single coil- Word order.
ABCD,CDAB,BADC, andDCBAare all supported. Set a device default withbyteOrderand override per tag with the fourth field. - Numbering. Addresses are raw and zero-based. If your drawings use 40001-style numbering, set
oneBased: trueand write the numbers from the drawings. - Blocks. Adjacent and near-adjacent registers merge into one request, so sixty tags are a handful of reads.
The protocols page has the whole reference, and says what the driver has been run against.
When the uplink drops
Section titled “When the uplink drops”The relay queues readings to a file on disk. When the broker returns, the queue drains oldest first before live readings go out, and each replayed reading is flagged is_historical so the host upstream does not take a replay for the tag’s current value. The queue is capped at 64 MiB by default. Delivery is at least once, so whatever consumes it has to tolerate a duplicate after a crash mid-replay.
With the Gateway and its own broker
Section titled “With the Gateway and its own broker”HotLoop can run an MQTT broker in the same process, on by default, listening on port 1883. Add the Modbus device to the Gateway, and publish to that broker with edge publish so a small install has nothing extra to deploy. For many sites or heavy fan-out, point it at Mosquitto, EMQX, or another dedicated broker. The embedded broker page says when to use which.
With Flow
Section titled “With Flow”Flow has Modbus read and write nodes and MQTT 5 nodes, so the flow is a Modbus read, a Function or Change node if you want to reshape the value, and an MQTT out. Quick start gets Flow running.
Where to go next
Section titled “Where to go next”- Build a unified namespace on Sparkplug B with the same relay.
- OPC UA to MQTT, for devices that speak OPC UA.
- Install the Edge Relay.
Questions
Section titled “Questions”What is a Modbus TCP gateway?
Section titled “What is a Modbus TCP gateway?”A Modbus TCP gateway reads the registers of PLCs, drives and meters and passes the values to the systems that need them. HotLoop does it with a native Modbus driver and serves the values over OPC UA, MQTT and Sparkplug B.
How do I get Modbus to MQTT?
Section titled “How do I get Modbus to MQTT?”HotLoop polls Modbus TCP and RTU devices and publishes them to an MQTT broker as plain topics or as Sparkplug B. The headless Edge Relay does the same job on a low-cost box next to the machine and queues readings to disk until the uplink returns.
Is HotLoop a PLC gateway for more than Modbus?
Section titled “Is HotLoop a PLC gateway for more than Modbus?”Yes. HotLoop ships eighteen native drivers, including OPC UA, Modbus TCP and RTU, MQTT and Sparkplug B, EtherNet/IP, S7comm, MTConnect, BACnet/IP and SNMP. Each driver lists what it was tested against.