Comparison
OPC UA vs MQTT Sparkplug from a controller to SCADA
Short answer
Pick OPC UA when the controller and the SCADA host share one plant LAN you control: the host subscribes inbound to the controller's browsable server. Pick MQTT Sparkplug B when the controller sits behind NAT, on cellular or at a remote site, or when several consumers need the same tags: outbound-only connections plus birth and death certificates give automatic tag discovery and stale detection.
On this page
Route controller data to SCADA over OPC UA when the controller and the SCADA host share one plant LAN you control: the host connects inbound to the controller's server, browses the address space and subscribes to what it needs. Route it over MQTT with Sparkplug B when the controller sits behind NAT, on a cellular link or at a remote site, or when more than one consumer needs the same tags: the controller opens a single outbound connection to a broker, and birth and death certificates hand every subscriber a discovered tag list with automatic stale detection. Both transports report by exception; what differs is who dials to whom, who owns the tag model, and what a dropped link looks like at the host.
The comparison at a glance #
The table is the whole decision; the sections below justify the rows and end with the commitment per case.
| Attribute | OPC UA (controller as server) | MQTT Sparkplug B (controller as publisher) |
|---|---|---|
| Governing spec | IEC 62541, the OPC Foundation's UA service set | Eclipse Sparkplug B specification layered on MQTT |
| Connection direction | SCADA host dials in to the controller | Controller dials out to the broker; the host dials out too |
| NAT or cellular site | Needs an inbound port forward per controller | Outbound only; no inbound rule at the controller |
| Tag discovery | Host browses the address space; only exported symbols appear | NBIRTH and DBIRTH payloads create the tag list on connect |
| Stale detection | Subscription keep-alive and lifetime counts | One NDEATH last will marks the whole node stale |
| Many consumers | One session and subscription per client, all loaded on the controller | The broker fans one stream out to every subscriber |
| Write-back | Native UA writes, gated by user and symbol rights | NCMD and DCMD command messages |
| Typical first failure | Rejected certificate or wrong endpoint URL | Broker authentication failure or a duplicate edge node ID |
What each standard actually defines #
OPC UA is standardized as IEC 62541 and published by the OPC Foundation. The controller runs a server exposing an address space of nodes; the SCADA host is the client that browses that space and reads or writes nodes. Data moves by subscription: the host creates a subscription, adds monitored items with a sampling interval and an optional deadband, and the server pushes changes only at the publishing interval. The publishing interval is also the basis for the subscription's keep-alive and lifetime counts, which is what turns a silent link failure into a detectable event. Sessions run under a security policy, so signing and encryption are negotiated before the first value moves.
Sparkplug B is a specification layered on top of MQTT. It defines a topic namespace built from the Sparkplug version, a group ID, a message type and the edge node and device IDs; a protobuf payload that carries a data type and a timestamp with every metric; and nine message types covering the whole lifecycle: NBIRTH, DBIRTH, NDATA, DDATA, NCMD, DCMD, NDEATH, DDEATH and STATE. The birth and death certificates are the load-bearing idea: every publisher declares its complete metric list at connect and registers its own death message as the MQTT last will, and every message carries an incrementing sequence number so a consumer can detect a gap and demand a republish.
Connection direction decides the NAT problem #
An OPC UA link points the wrong way for a remote controller. The SCADA host must reach the controller, so each controller needs an inbound firewall rule and, behind NAT, a port forward; on a cellular router there is no public address to forward to at all. MQTT turns the arrows around: the controller opens the only TCP connection at its site, out to the broker, and the SCADA host opens its own outbound connection to the same broker, so no inbound rule ever exists at the controller. That is the same outbound-only pattern that remote SCADA access through firewalls and proxies depends on. Commit to it: a controller behind NAT or on cellular publishes Sparkplug to a broker sitting at a fixed address, and the OPC UA path is off the table unless you terminate a VPN first.
Discovery: browse versus birth certificate #
Over OPC UA, discovery is manual and deliberate. The host browses the server's address space and pulls the nodes it wants into a tag provider. Controller runtimes expose only what you mark: variables left out of the symbol export never appear in the browse tree, no matter what the server's status page claims. Export symbols read-only wherever the SCADA host has no business writing.
Over Sparkplug B, discovery is automatic. On connect the publisher sends NBIRTH for the node and DBIRTH for each device, and the host's Sparkplug module, MQTT Engine on an Ignition gateway, creates the tags under a Sparkplug tag provider with names, types and timestamps taken from the payload. When the controller's runtime cannot publish Sparkplug itself, put a bridge between the two: OPC UA on the short cable hop to an edge box, MQTT from there to the broker. On the controller side that bridge is typically a fanless mini PC at the cell, and wiring that bridge is the subject of bridging OPC UA PLC data to MQTT with an edge PC.
Worked example: how fast the host sees a dead device #
Take one failure: the controller loses power mid-shift and the link dies silently, so no TCP reset reaches the host. Both transports turn that into stale tags on a timer, and the timers are arithmetic.
OPC UA side: illustrative inputs are a 1000 ms publishing interval, keep-alive count 10 and lifetime count 30; the server revises those counts from the publishing interval you request. The host expects a notification or a keep-alive every 10 × 1000 ms = 10 s, and with a lifetime count of 30 the link is written off after 30 × 1000 ms = 30 s, three missed keep-alives, at which point the subscription's items go bad. Worst case: about 30 s from silent death to bad tags.
Sparkplug side: the publisher declares a 30 s keep-alive at connect and registers NDEATH as its last will. MQTT puts the threshold at one and a half times the keep-alive, so the broker publishes the will after 1.5 × 30 s = 45 s without a packet, and the host marks every tag on that node stale. Worst case: about 45 s. A clean disconnect is faster on both paths, because a socket close or reset triggers immediate notification instead of the timer.
With these example inputs the paths land within half a minute of each other, so detection speed does not decide between them; connection direction does. Rescale the numbers with the same two multiplications for your own intervals. Stale tags that persist while the publisher is alive are a different failure with its own causes; resolving Ignition stale tags from Sparkplug B clients walks that case.
Security setup on each path #
Pick an OPC UA security policy that signs and encrypts, Basic256Sha256 being the common choice on current controllers, and leave the None policy for isolated networks only. Expect the first connection attempt to fail by design: the controller holds the host's client certificate as untrusted and the host holds the controller's server certificate the same way. Connect once, trust each side's certificate in its own certificate store, then reconnect. Create a dedicated OPC UA user for the SCADA host instead of reusing the controller's administrator account, with read-only rights where writes have no business happening. Where an edge box runs the OPC UA server in front of the controller, harden it like any server that exposes PLC tags, as described for an OPC UA server exposing PLC tags.
On the MQTT side, put TLS on the broker listener, give every publisher and subscriber its own credentials, and never run an anonymous broker on a routable network. The classic publisher-side handshake failure is peer verification: the runtime rejects the broker's certificate chain, and the fix is to trust the broker's issuing certificate authority, not to switch verification off, as covered for MQTT TLS peer verification handshake failures. Because the broker relays death certificates, commands and discovery, it is production infrastructure: monitor its process, back up its configuration, and treat its restart as an event the plant will notice.
Writes, buffering and fan-out #
Write-back differs in shape. OPC UA writes are native: the host writes a node and the controller's user model and symbol rights accept or refuse it. Sparkplug B carries writes as NCMD and DCMD commands: the host publishes the command, the device applies it and reports the result in its next data message, and that command handling must be implemented on the device; it is not automatic. When Sparkplug data arrives but SCADA commands never take effect, work the command path on its own, beginning with Sparkplug B data arriving with no SCADA commands received.
Across an outage, the paths differ in what the publisher can do. An OPC UA subscription forgets the changes that happened while the link was down unless the controller buffers them itself. A Sparkplug publisher can buffer metrics during the outage and replay them under their sequence numbers, and a host that spots a sequence gap can command a rebirth; whether it does depends on the publisher's buffering feature set, so verify that on your runtime before relying on it.
Fan-out is the second decisive difference. Every OPC UA consumer holds its own session and subscription on the controller, so ten consumers load the controller ten times over. A Sparkplug publisher sends once to the broker and the broker fans the stream out to every subscriber at no extra controller load. For one controller with many readers, Sparkplug wins on both controller CPU and bandwidth.
The decision #
Commit per case:
- Controller and SCADA host on one plant LAN you control, one consumer: OPC UA. The host subscribes inbound and browses only what you export; a 1 s publishing interval for trended values and a slower one for setpoints is a sane starting discipline.
- Controller behind NAT, on cellular or at a remote site: MQTT Sparkplug B, outbound-only, with the broker at a fixed address.
- Several consumers need the same tags: Sparkplug B through the broker, and the controller publishes once.
- The runtime cannot publish Sparkplug: OPC UA to a local edge box on the short hop, Sparkplug from the box to the broker on the long haul.
- Both worlds at once: run both transports side by side; they coexist, and many runtimes serve both from one controller.
A transport is not a safety function: any command that can move a machine still has to pass the controller's own interlocks and stop functions, whichever path it arrives on.
Questions asked
Can a controller run OPC UA and MQTT Sparkplug at the same time?
Yes, when the runtime offers both. The OPC UA server keeps serving the local SCADA host while an MQTT client publishes Sparkplug to the broker, and the two do not interfere. The cost is controller CPU: every subscription and every published metric consumes task time on an embedded controller, so start both paths at about 1 s rates, watch the control task cycle time, and tighten rates only after the load is proven acceptable.
What happens to a Sparkplug link when the broker goes down?
Everything stops. Publishers cannot deliver data, death certificates cannot be processed and hosts cannot discover tags, because the broker mediates every message. Treat the broker as production infrastructure: run it on a redundant pair, require TLS and per-client credentials, monitor its process and disk, and document its restart. An OPC UA link degrades more gently, because one dead client session does not affect the other subscribers.
What keep-alive should a Sparkplug publisher declare?
Set it from how fast you need staleness. The broker declares the client dead after one and a half times the keep-alive, so 10 s gives roughly 15 s detection and 30 s gives 45 s. Use about 30 s on cellular or NAT links, where reconnect churn otherwise produces false deaths, and 10 to 20 s on a stable plant LAN. Always register the death certificate as the last will so the host learns of the death.
How do I keep small signal fluctuations from flooding the link?
Filter at the source. An OPC UA monitored item takes a deadband filter, so the server reports a value only when it moves beyond the band you set. Sparkplug B carries no deadband on the wire, so the publisher applies any deadband before it publishes; whether that knob exists depends on the runtime. Set the band above the signal's noise floor, or every real change drowns in chatter about noise.