Send OPC UA Data to Azure With HiveMQ and MQTT
It is often said that manufacturing organizations are data rich but information poor. I couldn’t agree more, as large amounts of data that could help manufacturers improve the productivity of their plants and personnel, and the quality of the goods they produce, remain trapped in production assets such as PLCs, industrial equipment, Supervisory Control, and Data Acquisition Systems (SCADA), Manufacturing Execution System (MES) and Process Historians.
In order to extract insights that could positively and significantly impact their industrial and business processes, manufacturers need to integrate real-time and historical data from those systems that are already operating on the factory floor, into platforms with powerful analytics software such as Azure Cloud.
The question is, how do you technically collect data from these factory floor systems and forward it to Azure Cloud?
A typical feature of most production systems is that they embed an OPC UA Server that exposes production-related data. And while it’s entirely possible to host an OPC UA Client on Azure to consume this data, the resulting system would be complex as it would require components such as OPC Twin, OPC publisher, and OPC Discovery on the edge within the plant, and OPC Twin, OPC Registry, OPC vault in the cloud for a robust solution.
Further, it would also be difficult to scale such a system due to inefficiencies inherent in the client-server communication pattern. On the other hand, using a publish-subscribe communication pattern to collect the OPC UA based telemetry data would result in a system that is scalable, future-proof, and easy to implement.
In the video below, I demonstrate how to use MQTT, a pub-sub communication protocol, to collect and send OPC UA data to Azure with HiveMQ MQTT broker for analytics using Azure Time-Series Insights analytics software. It’s also important to note here that the demo doesn’t use Azure IoT Hub for coordinating MQTT messages as it is not a 100% MQTT compliant broker.
Here’s the outline of the demo:
System Architecture
Deploying HiveMQ MQTT Broker Cluster on Azure Cloud
Configuring HiveMQ Kafka Extension for forwarding MQTT messages to Azure Event Hubs Service
Creating and configuring Azure Event Hubs service
Configuring KepserverEX OPC UA Server to expose factory floor data
Building a DotNet application to collect OPC UA data and publish it to HiveMQ broker on Azure
Visualizing the information using Azure Time-Series Insights
Chapters
- 11:08 - Get the connection string.
- 12:02 - Include the three parameters in Kafka extension configuration file.
- 12:51 - Start publishing messages to HiveMQ cluster on Azure.
- 13:39 - Get OPC UA server address to connect to it.
- 15:39 - Go to Visual studio to start creating application for reading data from OPC UA server.
- 17:05 - Add MQTT package.
- 18:03 - Generate a MQTT client id.
- 18:55 - Initialise OPC UA application instance.
- 20:16 - Run OPC UA to MQTT Gateway.
- 20:55 - Use a utility code MQTT.fx to test it.
- 22:12 - Create a dedicated consumer group in Azure event hub service.
- 23:04 - Create a resource.
- 23:46 - Create a time series id.
- 26:26 - Select Ramp 2 & then click add to start visualising it.
Kudzai Manditereza
Kudzai is a tech influencer and electronic engineer based in Germany. As a Sr. Industry Solutions Advocate at HiveMQ, he helps developers and architects adopt MQTT and HiveMQ for their IIoT projects. Kudzai runs a popular YouTube channel focused on IIoT and Smart Manufacturing technologies and he has been recognized as one of the Top 100 global influencers talking about Industry 4.0 online.