What is OPC UA? MQTT & OPC UA

July 02, 2024

In the broad world of the IoT, communication that works well and seamlessly is essential. IoT protocols have become essential as industries move toward increasingly intelligent and networked devices. Two prominent protocols that are advancing the industrial and automation sectors are MQTT (Message Queuing Telemetry Transport) and OPC UA (Open Platform Communications Unified Architecture). They belong to the current IoT environment because of their dependability, flexibility, and security.

Each protocol is covered in detail in this article, along with its importance, differences, and reasons for being essential to IoT connections.

What is OPC UA?

OPC UA is a service-oriented, platform-independent communication architecture that guarantees safe, dependable, and open data transmission between different vendors' industrial automation systems, software, and devices. It establishes uniform formats and codes for data interchange via various transport protocols.

OPC UA is a major improvement over Open Platform Communications (OPC), even if it builds upon it. Although the same organization created both, OPC UA offers more flexibility and interoperability than the original OPC standard and is constantly being improved to meet the changing needs of industrial automation.

OPC UA developing history

OPC UA developing history

Industry vendors, end users, and software developers worked together to build a set of specifications for specifying industrial process data, alarms, and historical data before the publication of the OPC UA communication specification. These specifications, originally released in 1995 under the name OPC Classic, were built upon the Microsoft Windows COM/DCOM technology stack.

Although OPC Classic has a reputation for performing well in process control, it is no longer adequate due to improvements in technology and changing needs. In 2006, the OPC Foundation launched the OPC UA protocol to get around these restrictions. Cross-platform data transfer, improved data security, and better management of massive data volumes are all provided by this innovative technology. OPC UA fixes the flaws of OPC Classic while integrating its functionality.

The most recent version of the OPC UA protocol is 1.05 at the moment. OPC UA has a Pub-Sub method that enables the transmission of JSON specifications or the standard-defined binary specification (UADP) across UDP, MQTT, or AMQP protocols in addition to the Client-Server (Subscriptions) paradigm.

How does the OPC UA server work?

Hardware manufacturers can either offer software on a PC that collects data using a proprietary protocol and then exposes it to other platforms by OPC UA communication, or they can embed an OPC UA server directly into the device. For example, Siemens S7-1200/1500 and other mid-range and high-end PLCs include inbuilt OPC UA servers. Additionally, Siemens provides software such as WINCC, which uses OPC/OPC UA to indirectly provide third parties with data from other devices.

The OPC UA protocol has two ways for accessing data: publish/subscribe and request/response. These modes can be used to access data that has been made available through the OPC UA server. Creating a session channel between the client and server is the first step in this process. When using the session channel in Request/Response mode, the client application can ask the server for common services. A few of the functions offered by these services are calling remote methods, publishing data to a node, and receiving raw data from a node.

When the server's node data changes, notification messages are immediately transmitted to the client. In publish/subscribe mode, any client can create an unlimited number of server subscriptions.

OPC UA protocol features

OPC UA protocol features

Cross-platform compatibility

OPC UA clients can function on various operating systems, including Linux, Windows, Mac, iOS, and Android because OPC UA communication uses standard TCP/IP. Platform independence guarantees compatibility between various devices and systems, enabling smooth integration in various industrial settings. Furthermore, OPC UA communication is highly configurable to diverse requirements because it supports a wide range of transport protocols and data encoding types.

Information modeling

The OPC UA information model defines the codes and formats for exchanging data across various transport protocols. It facilitates semantic data definition and offers an extensive data type system.

Publish-subscribe mechanism

OPC UA server has a Pub-Sub (Publish-Subscribe) method in addition to the conventional Client-Server (Subscriptions) model. This feature makes it possible to push data across protocols such as AMQP, MQTT, or UDP, which makes communication in a variety of IoT contexts more efficient.

Tag structure

Upon connecting, the OPC UA protocol sends all accessible tags, giving users complete data visibility. This method improves the usability and efficiency of industrial automation and control systems by doing away with the requirement for address memorization and enabling simple browsing and access to pertinent information.

Use cases of OPC UA by industries

Numerous industries use OPC UA extensively, but IoT and industrial automation are two areas where it is most useful. Many activities are made easier by its adaptability, including access to past data, remote monitoring, seamless device integration, and data gathering.

Utilities

To guarantee consistent water quality and supply, the OPC UA protocol is used to monitor water treatment machinery, pumping stations, and water supply systems. OPC UA allows remote power equipment operation, fault detection, and monitoring in power systems.

Manufacturing

OPC UA streamlines data gathering and real-time equipment and production line monitoring in the manufacturing industry. Continuously monitoring the production process helps businesses maximize productivity.

Furthermore, OPC UA makes it easier to integrate devices from robots to sensors from different manufacturers smoothly and efficiently. 

Oil and gas

OPC UA reduces the need for manual intervention by enabling remote monitoring and control of equipment in pipelines, refineries, and oilfields. Furthermore, OPC UA's historical data access functionality makes it simpler to assess and optimize performance by allowing the recording of equipment operational data.

Renewable energy

To facilitate remote control and troubleshooting, OPC UA is used to monitor the operational condition of wind and solar farms. OPC UA offers grid managers the dependable communication channel needed for the real-time data sharing involved in controlling access to renewable energy sources and system functions.

OPC UA Node types

The classes that specify the composition and actions of nodes inside the OPC UA server address space are included in the OPC UA Node types. Among these node kinds are:

1. Object nodes: Represent physical entities such as hardware, software, or systems by assembling variables, functions, and other elements into groups.

2. Variable nodes: Value is represented by a variable node. The variable determines the value's data type. The customer can subscribe to the value, read, and write.

3. Method nodes: A server method that the client calls and returns a result from is represented by the method node. The method node's variables represent the input parameters and the output result. After the call, the client provides the input parameters and receives the output result.

Node-RED OPC UA

The Node-RED OPC UA capabilities integrated into the Node-RED platform are referred to as OPC UA. Data interchange across various hardware and software types is made easier by the widely used OPC UA communication protocol. For IoT applications, on the other hand, users can construct visual programming flows with the low-code platform Node-RED.

OPC UA integration allows users to construct OPC clients to consume data from PLCs (Programmable Logic Controllers) and other industrial automation devices that support OPC servers within the Node-RED environment. Users can connect to OPC servers, read and write data, subscribe to changes in data, and visualize this data in the flow-based programming environment of Node-RED by leveraging OPC UA nodes within Node-RED.

A user-friendly and adaptable method of interacting with industrial data is made possible by the combination of Node-RED and OPC UA. This allows for the development of unique applications, dashboards, and automation procedures that take advantage of OPC UA's capabilities to facilitate smooth communication with industrial systems and devices.

Meaning of MQTT

MQTT uses a publish/subscribe messaging paradigm, with all message transmissions being supervised by a central broker. Clients establish a connection with this broker and can act as publishers or subscribers. Publishers tag messages with specific topics and transmit them to the broker. After subscribing to the pertinent topics, subscribers receive these communications.

The broker, which is in charge of collecting all messages, screening them, determining which customers are interested, and then publishing the messages to those subscribers, is at the heart of the MQTT architecture. It is possible to scale effectively over multiple dispersed systems because of the separation of publishers and subscribers.

MQTT has been used in sectors such as manufacturing and healthcare to improve operational efficiency and enhance patient care. For example, MQTT is used to manage medical equipment assets in the healthcare industry to monitor machinery and anticipate maintenance needs in manufacturing.

OPC UA server with MQTT

Despite many functional similarities, OPC UA and MQTT are intended for various scenarios and have different strengths.

A communication protocol designed specifically for industrial settings, OPC UA allows systems and equipment from different manufacturers to communicate with each other seamlessly by using a common vocabulary. In intricate industrial systems, it guarantees strong data interchange and interoperability.

MQTT, on the other hand, is an IoT protocol that is tailored for Internet-based data transmission from sensors and made to work well on networks with inconsistent bandwidth. It is perfect for sensor networks because of the publish/subscribe method, which enables flexible, continuous real-time data handling. 

A Pub-Sub model included in the most recent OPC UA specification released by the OPC Foundation enables data updates to be delivered to subscribers using an MQTT Broker. Compared to the conventional client/server architecture, the Pub-Sub approach adds a more sophisticated security model, and the specification provides less detail.

SSL/TLS is the main security mechanism in a MQTT network. However, the broker can also enforce application-level authentication in addition to SSL/TLS for safe transit. On the other hand, most security protocols are generally applicable to all network subscribers and publishers.

MQTT vs OPC UA

The main features, benefits, and common use cases of MQTT and OPC UA are compared in detail and shown in a tabular manner below to help you understand when and why one might be more suited to certain IoT scenarios.

Feature MQTT OPC UA
Architecture Publish/Subscribe model Client/Server model with sophisticated data modeling
Complexity Low complexity, minimal data overhead High complexity, detailed structure for industrial applications
Security Basic security with SSL/TLS encryption Sophisticated security features user control, including user authentication
Performance Excellent message transmission efficiency in low-bandwidth scenarios Designed to facilitate consistent and dependable performance
Compliance with standards Adheres to IoT-focused standards like LwM2M Complies with industrial automation standards
Service quality Quality of Service (QoS) levels to ensure message delivery High-quality service levels for reliability and security
Use cases Best for lightweight IoT applications Best for complex industrial automation systems

It's important to take into account the unique requirements of your application when choosing a protocol, including data complexity, necessary security levels, network stability, and scalability requirements. Make an informed choice that fits the goals and technical specifications of your IoT or Industrial IoT deployment by using this comparison as a reference.

Conclusion

The specific needs of your industrial or IoT application will choose which OPC UA and MQTT to use. OPC UA is perfect for complicated industrial environments because of its extensive data modeling and strong interoperability. In contrast, MQTT operates well on high-latency, low-bandwidth networks, offering effective and adaptable real-time data handling appropriate for IoT sensor networks. Through comprehension of the advantages and suitable applications of every protocol, as well as the possibility of using them in tandem, you may formulate a communication plan that guarantees scalable, secure, and effective data sharing. By using a well-informed strategy, you may improve the performance of your IoT or IIoT implementation and meet your technical objectives.