How-to
Bridging OPC UA PLC data to MQTT with an edge PC
Short answer
Keep the OPC UA server on the PLC side and give MQTT publishing its own role on a separate edge PC that acts as the OPC UA client and MQTT publisher. Commission the two links independently — first a verified tag read, then a verified subscriber message — and only then widen the tag set.
On this page
Bridge PLC data to MQTT with two roles, not one box doing both: the OPC UA server in the PLC or its communication module exposes the tags, and a separate edge PC runs the OPC UA client plus the MQTT publisher that forwards them to a broker. Do not design around MQTT inside the PLC's OPC UA server — serving OPC UA clients is what a server module does, and an announced feature is not a shipped one. Commission in a fixed order and gate each step on evidence: first a tag read at the edge client that matches the controller, then a subscriber payload that matches that read.
Split the roles, then the work follows #
OPC UA, standardized as the IEC 62541 series, is a client/server protocol: the server in the PLC exposes variables, and clients connect, browse, and read or write them. MQTT, standardized as ISO/IEC 20922, is publish/subscribe: publishers send messages to a broker, and any number of subscribers receive whatever their topic filters match, at one of three delivery levels (QoS 0, 1, or 2). The two models do not merge into one setting on the PLC. The edge PC is the bridge because it can hold both roles at once: OPC UA client toward the PLC, MQTT publisher toward the broker.
The split also protects what already works. Existing SCADA and historian clients keep reading the same OPC UA server they use today; the edge PC adds the MQTT path beside them without touching the server configuration.
| Requirement | Component that owns it | Commissioning check |
|---|---|---|
| Expose PLC tags on the network | OPC UA server in the PLC or its communication module | A compliant OPC UA client connects, browses, and reads the selected variables |
| Read those tags at the edge | OPC UA client on the edge PC | Every selected tag returns the live controller value, checked against the programming tool |
| Deliver values to consumers | MQTT publisher on the edge PC and a broker | A test subscriber receives the agreed topic and payload for the agreed tags |
| Keep the roles separate | The design itself | Nothing in the design expects MQTT from the PLC's OPC UA server |
Choose the edge platform #
The bridge is light duty, and it runs comfortably on a fanless industrial mini PC bolted into the cabinet next to the PLC or the broker. For software, a Node-RED flow with an OPC UA client node feeding an MQTT output node is the most common pattern; start from installing Node-RED natively on a Linux edge computer if that is your base. Standalone gateway software that connects OPC UA servers and MQTT brokers in one process is an alternative; it changes the tool, not the architecture.
One caution when the platform is an appliance rather than a general-purpose PC: embedded edge boxes often run a vendor's purpose-built Linux rather than a desktop distribution, so confirm the supported runtimes and package sources before assuming a workflow written for another platform transfers unchanged.
Size the stream before you publish #
A calculated example with illustrative inputs: 150 tags, published as one JSON document, at 60 bytes per entry for key, value, and punctuation.
- 150 tags × 60 B = 9,000 B ≈ 8.8 kB per document
- 9,000 B ÷ 5 s period = 1,800 B/s; × 8 bit/B = 14,400 bit/s ≈ 14 kbit/s
- At a 1 s period: 9,000 B/s × 8 = 72 kbit/s, which is 72 ÷ 100,000 ≈ 0.07 % of a 100 Mbit/s link
The decision: bandwidth is never the constraint at plant scale — the tag list and the update period are. The compute load is equally light; this is protocol handling, not number crunching. If the broker feeds a self-hosted historian on the same host, the storage it needs dwarfs anything the network notices, so size that storage for the arrival rate as covered in sizing a self-hosted Node-RED InfluxDB Grafana historian.
Commission the bridge in five gated steps #
- Approve the tag list first. For each tag, record the identifier, its meaning, data type, update behavior, and the consuming application. Do not publish the whole controller namespace by default: it hands the data model to whoever reaches the broker, and internal and scaling tags have no consumer.
- Agree the message contract before anything runs: topic, payload format (for example JSON carrying tag name, value, quality, and timestamp), update rate, and QoS. Configure publisher and subscriber to the same contract.
- Commission the OPC UA link. Point the edge OPC UA client at the server endpoint exactly as the installed system's configuration records it — never an address copied from another installation. Browse, then verify at least one tag of each data type against the live controller value. Gate: the client's value equals the controller's for every selected tag.
- Commission the MQTT link. Configure the publisher's broker connection and one test subscriber, publish the agreed tags only, and trace one tag from the edge input node to the subscriber payload. Gate: the subscriber shows the same value the client read.
- Widen the tag set, then lock it down. Re-run both gates after each addition. Before production, enable the OPC UA security policy and user authentication the server supports, require credentials and TLS on the broker listener, and keep the broker off the open internet.
Diagnose by layer #
| Symptom | Layer to check first | Next diagnostic |
|---|---|---|
| Client connects but a needed tag is missing or wrong | Variable exposure or selection | Compare the browsed node with the approved tag list and the live controller value |
| OPC UA reads are good but no MQTT message arrives | Edge mapping or broker path | Trace one tag from the edge input to the publisher; check the broker connection and the subscriber's topic filter |
| Values arrive but disagree with the PLC | Data types, scaling, or encoding | Compare types and engineering units at the edge against the message contract |
| The stream stops after hours | Session and keep-alive handling | Review the OPC UA subscription and the MQTT keep-alive settings, and read the broker logs for disconnects |
When OPC UA PubSub replaces the custom bridge #
Part 14 of IEC 62541, OPC UA PubSub, defines publishing datasets over MQTT with standard topic conventions and JSON or binary UADP encodings — the standard replaces your hand-written message contract. Use it when the PLC-side stack and every consumer document that support. In practice, PLC-side OPC UA server modules overwhelmingly implement the client/server profile, so treat PubSub as available only where the documentation names it; otherwise the edge PC bridge reading the server is the design you deploy, and the five gates above are how you prove it.
Questions asked
Can OPC UA and MQTT run on the same edge device?
Yes, provided the installed software supports both roles and the host has the memory and CPU headroom for them. The separation that matters is between roles, not boxes: one device runs an OPC UA client toward the PLC and an MQTT publisher toward the broker at the same time. The bridge load itself is light, so a modest fanless PC handles it.
Which MQTT QoS should PLC tag data use?
QoS 1, at-least-once delivery, for periodic tag values: a duplicate message is harmless when the payload carries a timestamp, but a silently dropped one is not. QoS 2 adds an exactly-once handshake that stream data rarely needs. QoS 0 is acceptable only for values refreshed faster than any consumer would miss one.
Can the MQTT broker run on the same edge PC?
Yes, for plant-local use. A broker on the same fanless PC serves every subscriber on that segment, and the QoS levels of ISO/IEC 20922 behave the same regardless of where the broker runs. When several sites or IT-side consumers subscribe, move the broker to a host you can patch on a schedule and reach only through a controlled path, still with credentials and TLS.
Should I publish the whole PLC namespace to the broker?
No. Publish the approved tag list only. The whole namespace exposes the controller's data model — internal states, scaling values, tag names — to anyone who reaches the broker, and it multiplies message churn for tags that have no consumer. Re-run both commissioning gates whenever the approved list grows.