Modbus to MQTT Gateway
Turn any Modbus TCP or RTU device into an MQTT publisher with a visual flow. Loopze is a single Go binary with native Modbus and MQTT — no Node.js, no plugin hunt, no license keys. Drop a Modbus Read node, wire it to an MQTT Publish node, deploy.
What this gateway does
The classic IIoT pipeline: a PLC, energy meter, VFD or RTU on the shop floor speaks Modbus. Everything modern — historians, dashboards, cloud platforms, Unified Namespaces — speaks MQTT. Loopze sits in between, polls the Modbus registers, optionally scales and renames them, and publishes structured JSON to your MQTT broker.
- Reads Modbus TCP over Ethernet
- Reads Modbus RTU over RS-485 / USB serial
- Supports all standard function codes (FC1–FC4, FC5–FC6, FC15–FC16)
- Publishes to any MQTT 3.1.1 / 5.0 broker (Mosquitto, HiveMQ, EMQX, AWS IoT Core, Azure IoT Hub, …)
- Optional payload transforms in expr-lang, JavaScript or Go
- Optional embedded NATS broker if you want a zero-dependency stack
Typical setup
A real-world Modbus-to-MQTT flow in Loopze looks like this:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Modbus Read │ │ Transform │ │ MQTT Publish │
│ 192.168.1.50 │───▶│ raw * 0.1 │───▶│ factory/temp │
│ HR 40001 (×4) │ │ expr-lang │ │ QoS 1, retain │
│ poll 1000 ms │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
Three nodes, one wire, one deploy. The runtime handles reconnection, back-pressure and error reporting.
Example: energy meter on the shop floor
A typical SDM630 energy meter exposes 30+ float registers (voltage, current, power, energy). Bridging it to MQTT:
-
Modbus Read node
- Transport: TCP, 192.168.1.50:502
- Unit ID: 1
- Function: Read Holding Registers (FC3)
- Start register: 40001, count: 60
- Poll interval: 2000 ms
- Decoding: 32-bit float, big-endian
-
Transform node (JavaScript)
return { ts: Date.now(), meter: "sdm630-line-A", voltage_l1: msg.payload[0], voltage_l2: msg.payload[2], voltage_l3: msg.payload[4], total_kwh: msg.payload[28], }; -
MQTT Publish node
- Broker: mqtts://broker.example.com:8883
- Topic: factory/line-A/energy
- QoS: 1, retain: true
- Auth: username + password (or mTLS)
Click Deploy. Every two seconds, a JSON document lands on factory/line-A/energy.
Why Loopze for Modbus-to-MQTT bridging
Native, not bolted on
Many flow tools rely on community plugins for Modbus — varying quality, varying maintenance, varying behaviour across versions. Loopze implements Modbus directly in the runtime, in Go, with the same reconnect, back-pressure and error semantics as MQTT and OPC-UA.
Parallel polls, no head-of-line blocking
Have 20 Modbus devices on the same network? Each Modbus Read node runs in its own goroutine. A slow or unreachable device times out on its own thread without stalling the rest of the pipeline.
One binary on the edge
Modbus-to-MQTT gateways usually run on a Raspberry Pi, Moxa, Advantech or similar industrial PC. Loopze ships as a single ~5 MB binary you copy onto the device. No Node.js install. No Python runtime. No apt dance.
Open source, vendor-independent
AGPL-3.0 on GitHub. No license server, no telephone-home, no per-tag pricing. A commercial license is available for closed-source embedding.
Try it in 60 seconds
curl -L loopze.dev/install | sh
loopze --port 1880
Then open http://localhost:1880, add a Modbus Read node, wire it to MQTT Publish, deploy.
Frequently Asked Questions
What is a Modbus to MQTT gateway?
A piece of software (or hardware) that reads values from Modbus TCP or RTU devices and publishes them to an MQTT broker, typically as JSON. It is the standard way to bring legacy industrial data into a modern IIoT stack.
Does Loopze support Modbus TCP and Modbus RTU?
Both. TCP over Ethernet, RTU over RS-485 / USB serial. Same configuration model.
Can I scale and rename register values before publishing?
Yes — drop a transform between Read and Publish. Use expr-lang for short expressions, JavaScript for richer logic, Go for hot paths.
What MQTT brokers does Loopze work with?
Any MQTT 3.1.1 or 5.0 broker. Mosquitto, HiveMQ, EMQX, AWS IoT Core, Azure IoT Hub. The embedded NATS broker is also available if you want a self-contained stack.
Is Loopze a good fit for a Raspberry Pi or industrial gateway?
Yes. Single binary, ~5 MB on disk, ~20–40 MB resident. Runs comfortably on Pi, Moxa, Advantech, BeagleBone and similar ARM-based industrial gateways.
How does this compare to using Node-RED for the same job?
See Loopze vs Node-RED for the full breakdown. Short version: Loopze ships native Modbus inside the runtime; Node-RED relies on community npm packages of varying quality.