Evaluate the AutomationView desktop suite free for 30 days. No credit card required. Claim trial key →
arrow_back Back to Articles

Mastering OPC UA PubSub over MQTT: A Practical Guide

calendar_month
person Carvalho Raphael

Mastering OPC UA PubSub over MQTT: A Practical Guide

Learning
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
flowchart LR
    subgraph ot_network ["OT Network"]
        PLC["Legacy PLC"]:::blue
        Edge["Edge Gateway"]:::green
    end
    subgraph it_network ["IT Network"]
        Broker["MQTT Broker"]:::red
        Cloud["Cloud Analytics"]:::blue
    end

    PLC -->|Modbus/TCP| Edge
    Edge -->|"OPC UA PubSub over MQTT"| Broker
    Broker -->|Subscribe| Cloud

    classDef blue fill:#2563eb,stroke:#fff,stroke-width:2px,color:#fff;
    classDef green fill:#16a34a,stroke:#fff,stroke-width:2px,color:#fff;
    classDef red fill:#dc2626,stroke:#fff,stroke-width:2px,color:#fff;
AutomationView Icon AutomationView

The gap between the plant floor and the cloud is closing, but moving data reliably remains a core challenge. Integrating OPC UA PubSub over MQTT offers a powerful solution, combining the structured data modeling of OPC UA with the scalable, event-driven messaging of MQTT. This architecture is quickly becoming the backbone of modern IIoT implementations.

Key Takeaways

  • Understand the difference between Gateway and Native integration approaches.
  • Learn how to map OPC UA datasets to MQTT topics.
  • Discover the best data formats for bandwidth-constrained environments.

The Shift from Client/Server to PubSub

Traditional OPC UA relies on a Client/Server polling mechanism. While excellent for deterministic, point-to-point SCADA communication, it struggles to scale across thousands of distributed IoT nodes. Enter OPC UA Part 14: PubSub. By decoupling the publisher from the subscriber, and using MQTT as the transport layer, systems can broadcast state changes instantly to any authorized listener without bogging down the controller’s CPU.

flowchart TD
    subgraph architecture ["PubSub Architecture"]
        Publisher["OPC UA Publisher"]:::blue
        Broker["MQTT Broker (e.g. Mosquitto)"]:::red
        Subscriber1["SCADA Subscriber"]:::green
        Subscriber2["MES Subscriber"]:::green
    end

    Publisher -.->|"Publish Dataset"| Broker
    Broker -.->|"Distribute"| Subscriber1
    Broker -.->|"Distribute"| Subscriber2

    classDef blue fill:#2563eb,stroke:#fff,stroke-width:2px,color:#fff;
    classDef red fill:#dc2626,stroke:#fff,stroke-width:2px,color:#fff;
    classDef green fill:#16a34a,stroke:#fff,stroke-width:2px,color:#fff;

Two Paths to Integration

Automation engineers typically face two scenarios when implementing this architecture: brownfield retrofits and greenfield installations.

1. Gateway Integration (Brownfield)

Most existing PLCs do not natively support OPC UA PubSub. In these cases, an Edge Gateway acts as a middleman. The gateway polls the legacy PLC using standard protocols (Modbus, Ethernet/IP, or classic OPC UA Client/Server), translates the data into an OPC UA DataSet, and publishes it via MQTT.

2. Native OPC UA Publisher (Greenfield)

For new installations, modern controllers often include a native OPC UA Publisher. The device directly encodes data and sends it over the MQTT transport, eliminating the need for intermediary gateways and reducing points of failure.

Implementation: A Practical Workflow

Setting up your OPC UA PubSub over MQTT architecture involves several critical decisions, particularly around payload formatting and topic structure.

Data Format Pros Cons
JSON Human-readable, instantly compatible with IT and Cloud analytics platforms. Larger payload size, increasing bandwidth usage on constrained networks.
UADP (UA Binary) Highly efficient, compact payload ideal for cellular or high-frequency data. Requires the subscriber to natively understand and decode the OPC UA binary format.

Mapping Datasets to Topics

When configuring the publisher, you must define the DataSet (the specific tags to be monitored). Crucially, map these tags to a logical MQTT topic structure. A best practice is to adopt a Unified Namespace (UNS) hierarchy, such as Enterprise/Site/Area/Line/Cell, ensuring that data is self-descriptive regardless of the consuming application.

Real-World Field Considerations

In practice, integrating OPC UA PubSub over MQTT isn’t just about protocol translation. Engineers must navigate network segmentation (OT/IT DMZs), ensure MQTTS (TLS/SSL) encryption is strictly enforced, and manage the complexity of certificate exchange between the publisher and the MQTT broker. Without proper security, broadcasting process variables over MQTT poses a severe risk.

FAQ

Can I use any MQTT Broker?

Yes, any standard MQTT 3.1.1 or MQTT 5 broker (like Mosquitto, HiveMQ, or AWS IoT) will work as the transport layer.

Do I lose OPC UA Information Models?

No. The PubSub specification is designed to encapsulate the rich metadata and security context of OPC UA inside the message payload.

For more tools to optimize your plant floor architecture, explore the AutomationView Store.

Share this article

Stay Updated with Learning

Get the latest articles and news delivered directly to your inbox.

Log in to Subscribe

You must be registered and logged in to manage subscriptions.

Recommended for you

Inside NAMUR Open Architecture: Unlocking Field Data with a Second Channel

Learning
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
flowchart LR
  A["Field Devices"]:::blue --> B["Second Channel"]:::green
  B --> C["NOA Gateway"]:::red
  C --> D["M+O Domain"]:::blue
  style A fill:#2563eb,color:#ffffff
  style B fill:#16a34a,color:#ffffff
  style C fill:#dc2626,color:#ffffff
  style D fill:#2563eb,color:#ffffff
AutomationView Icon AutomationView
calendar_month

Inside NAMUR Open Architecture: Unlocking Field Data with a Second Channel

Process plants generate vast amounts of diagnostic and secondary process data at the field level. Most of this data never leaves the instrument. HART-enabled devices, for example, transmit up to 35 additional variables beyond the primary process value, yet legacy DCS architectures typically ignore them. NAMUR Open Architecture (NOA) provides a standardized method to access […]

Read Article arrow_forward

How IEC 63303 Redefines State-Based HMI Display Strategies

HMI
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
flowchart LR
    A["IEC 63303"]:::blue --> B["HMI Philosophy"]:::green
    B --> C["4-Level Hierarchy"]:::blue
    C --> D["State-Based Displays"]:::green
    D --> E["Faster Response"]:::red
    classDef blue fill:#2563eb,color:#ffffff
    classDef green fill:#16a34a,color:#ffffff
    classDef red fill:#dc2626,color:#ffffff
AutomationView Icon AutomationView
calendar_month

How IEC 63303 Redefines State-Based HMI Display Strategies

When an operator stares at 400+ process variables during an abnormal event, response time depends entirely on how the HMI presents information. IEC 63303:2024, published by IEC Technical Committee 65 in August 2024, provides the first international normative framework for IEC 63303 HMI design in process automation. It builds upon the established ANSI/ISA-101.01-2015 methodology while […]

Read Article arrow_forward