Anyone who wants to get data out of machines on the shop floor quickly comes across two terms: OPC UA and MQTT. In quotes and forums they are often pitted against each other. In practice, however, they answer different questions. This article shows where each protocol shines and how to combine them sensibly.
OPC UA in one sentence
OPC UA is an industrial standard for exchanging data with meaning: a server (e.g. in the controller) provides not only values but also their structure, data type, unit and context in the so-called information model.
- Self-describing: A client can browse the address space and find axes, spindles or program states without knowing a list of addresses in advance.
- Companion specifications: Industry models such as OPC UA for Machine Tools or umati make machines from different manufacturers look the same.
- Built-in security: Certificates, encryption and user permissions are part of the standard.
- Read, write, call methods: OPC UA is also suitable for a return channel, for example handing over jobs to a machine.
Many controllers come with an OPC UA server or can be retrofitted with one, for example SINUMERIK controllers via an option or SIMATIC S7-1500 directly in TIA Portal.
MQTT in one sentence
MQTT is a lightweight publish/subscribe protocol: devices send messages to a central broker, and everyone who has subscribed to a topic receives them.
- Lightweight: Little overhead, works even over unstable or slow connections.
- Decoupled: Senders and receivers do not know each other. New consumers (dashboard, database, cloud) can be added without touching the machine.
- Scalable: One broker distributes data from hundreds of machines to any number of systems.
- But: MQTT only defines the transport. What the message contains and how it is structured is up to you, for example with Sparkplug B or your own JSON schema.
Side-by-side comparison
| Criterion | OPC UA | MQTT |
|---|---|---|
| Principle | Client/server (PubSub also possible) | Publish/subscribe via broker |
| Data model | Comprehensive, standardised | None – free-form or via Sparkplug B |
| Typical place | Machine ↔ host computer, MES | Shop floor ↔ IT, cloud, dashboards |
| Return channel / control | Very good (write, methods) | Possible, but up to you |
| Effort to get started | Higher (model, certificates) | Low |
| Many consumers | Every client connects to the machine | Broker distributes, machine stays unburdened |
When OPC UA is the better choice
- You need structured machine data with context, such as program status, tool data or alarms, and don't want to model it yourself.
- An MES or host computer should hand over jobs, programs or parameters to the machine.
- The customer or industry requires a vendor-independent standard such as umati.
When MQTT is the better choice
- Data should go to several systems at once: dashboard, database, maintenance, cloud.
- The connection is unreliable, for example on mobile equipment or distributed sites.
- You are building a Unified Namespace, i.e. a central data hub for the entire plant.
In practice: combine both
In most projects the decision is not either-or. A proven pattern:
- OPC UA at the machine: A gateway (edge PC, custom Java application or off-the-shelf product) reads the data from the controller via OPC UA.
- MQTT in the plant: The gateway publishes the processed values in a structured way to an MQTT broker.
- Consumers subscribe: Dashboard, database and ERP take what they need without putting additional load on the controller.
This way the controller is relieved with exactly one connection, the data keeps its meaning, and new applications can be connected at any time.
What to watch out for during implementation
- Security from the start: Run OPC UA with certificates and encryption, MQTT only over TLS and with user authentication. The controller does not belong directly in the office network.
- Plan the data volume: Don't poll every value every 10 ms. Subscriptions with sensible sampling rates and deadbands reduce the load on controller and network.
- Define names: A clear topic structure (e.g.
plant/hall/line/machine/value) saves a lot of rework later. - Start small: One machine, three meaningful values, one dashboard. Then scale.
Conclusion
OPC UA is strong when it comes to meaning and control at the machine. MQTT is strong when data needs to be distributed efficiently to many consumers. Using both in the right place gives you a data connection that grows with your operation.