In this guide 6 sections
They do different jobs, so most plants run all three. Modbus polls registers in PLCs, drives and energy meters. OPC UA serves named, typed, secured machine data. MQTT carries telemetry from the site gateway to a broker. Choose per link in the chain, by what that link has to do.
Each one was built for a different link
Modbus is a plain request and response protocol. A master asks for holding registers or coils, and the device replies with raw numbers. Nothing in the reply says what the number means.
OPC UA works differently. A server publishes a model of the machine with named nodes, data types, engineering units and ranges, and it adds certificates and encryption on top. MQTT is only a transport: a client publishes a message to a topic, and the broker hands it to every subscriber.
Comparing them head to head is like comparing a spanner with a toolbox. They sit at different points between the machine and the office. Different jobs.
- Modbus RTU runs over RS-485 twisted pair, Modbus TCP over Ethernet on port 502
- OPC UA servers are built into many newer PLCs and CNC controls
- MQTT brokers such as Mosquitto or EMQX keep topics and retained messages
- Modbus carries no timestamps, units or security of its own
Where Modbus still wins
Drives, energy meters, temperature controllers and older PLCs almost always speak Modbus. It is simple, cheap to implement and well understood by every electrician. If a device offers nothing else, you poll it.
The cost is the register map. You must read the vendor’s manual. Register 40001 may hold output frequency, scaled by ten, while two registers together form a 32-bit float with a set word order. Get the word order wrong and a healthy motor reads as a fault. Check it early.
Poll sensibly. A bus with twenty slaves cannot be read every 100 milliseconds, and a slow RS-485 line with long cable runs needs correct termination and a sensible baud rate.
When OPC UA earns its extra setup
Choose OPC UA when the controller already has a server and the data has structure. A CNC with axis loads, a tool number, a program name and an alarm list is a good case. The names arrive with the values, so nobody maintains a spreadsheet of addresses.
Setup takes more effort. You exchange certificates, set a security policy, open the right firewall port and decide who may browse or write. That work pays off on lines you intend to extend.
Use subscriptions rather than polling where the server supports them. The server reports a change only when a value moves past a deadband, which saves bandwidth on a thin site link.
- Named nodes instead of raw register numbers
- Subscriptions with a sampling interval and deadband
- Certificate trust lists per client
- Companion models for CNC and packaging equipment
Why MQTT belongs between gateway and broker
A site gateway should not be asked by ten applications for the same value. It reads each device once, then publishes to a topic such as plant1/line2/press4/temperature. Anything that needs the value subscribes.
MQTT copes with poor links. The gateway holds a persistent session, sets a quality of service level and uses a last will message so the broker marks the site offline when the connection drops. Retained messages give a new subscriber the latest value at once.
It does not describe the data. Agree a payload format, such as JSON with a timestamp, a unit and a quality flag, before the first topic goes live.
A layout that uses all three
Put the protocols in order along the path. Meters and drives are polled by Modbus, the newer CNC is read through OPC UA, and the gateway republishes both to the broker over MQTT with TLS. Business software reads from the broker, never from the machine.
Keep write access out of the first version. Reading is safe to test on a live line. Writing a setpoint is a change to the process and needs a signed-off procedure.
Before you buy anything, list every device with its make, model, protocol, port and register map or node list. That one sheet shows which links need a converter and which need nothing.
Protocol link register
Each device gets its own line on a single printed page. Columns: tag, make and model, location, protocol, address or port, register or node list reference, poll interval, plant owner, reading gateway and MQTT topic. A second block records broker address, TLS status and payload format.
Open a blank worksheet to printQuestions owners ask
Can MQTT replace Modbus?
No. MQTT moves messages between programs, while Modbus reads registers from a device. A gateway usually reads the device by Modbus and then publishes the result over MQTT.
Do all PLCs support OPC UA?
No. Many recent models include a server, older ones do not, and some need a licence or firmware update. Check the controller’s manual before you plan around it.
Is Modbus safe to leave on an open network?
No. It has no authentication or encryption. Keep it on a separate segment or serial line and let only the gateway talk to it.
Which one should a small plant start with?
Start with whatever your existing devices already offer. For most small plants that means Modbus on meters and drives, with the gateway publishing to a broker over MQTT.
