Connecting OPC UA to Azure - Weather Station Demo
Cloud services and IoT solutions are becoming increasingly popular. OPC UA technology and our OPC UA Java SDK fit well in this development, enabling secure and standardized communications with devices and systems from different vendors.
We experimented with presenting OPC UA data in Azure by creating a simple Azure web site where we are able to monitor the climate in our office. The system architecture is presented in the picture below.
Measurement device level
At the low level there is a Raspberry Pi Weather Station demo device that hosts an OPC UA Server application running with Prosys OPC UA Java SDK. The station measures temperature, pressure and humidity which are then provided on the OPC UA Server for OPC UA Clients to read. Unfortunately, the only humidity sensor of our station is placed inside the weather station. Thus, the measured humidity is hugely affected by the electronics, staying constantly very low and not representing the actual office humidity at all. We found ourselves happier with the temperature and pressure measurements, even though the temperature value has regular false spikes at 40 °C.
Data processing and Azure
In the middle there’s a customized OPC UA Client .NET implementation based on Microsoft’s OPC UA Publisher Module for the Azure IoT Gateway SDK (link). In this solution the Publisher module plays a key role in connecting between OPC UA and Azure. First, it uses OPC Foundation’s Standard Library Stack for connecting to the Weather Station OPC UA Server and reading the data of interest in the server, in this case the temperature and pressure values. Next, the received data is processed according to need: we filter out the received temperature spikes and perform some average calculations for both the temperature and pressure values to make the value changes look more gradual in the graphs. The resulting values are encoded into JSON format, after which the Azure IoT Gateway SDK is used for composing an IoT Hub compatible AMQP message and sending it to our IoT Hub in Azure.
In another possible solution we would not have included a Publisher module in an additional OPC UA Client application, instead a Publisher would have become a part of the Weather Station OPC UA Server application. This kind of solution would allow direct connection from an OPC UA Server to Azure and expectedly be the ideal solution for a majority of OPC UA to Azure use cases. We preferred our reliable Weather Station to stay unmodified and implementing a Client layer also has its own advantages. For example, if data from multiple existing OPC UA Servers is wanted in Azure, it can be easier to implement a single OCP UA Client program that collects the wanted information from all servers and sends it to Azure, as opposed to modifying each of the existing Server applications separately.
In the near future, an upcoming release of OPC UA PubSub (Publisher/Subscriber) specification will include means for OPC UA applications to connect themselves directly with cloud services, such as Azure, using protocols like AMQP or MQTT. This will make development of OPC UA to Azure applications easier and more flexible, which is why we at Prosys are already developing a PubSub implementation in Java. So stay tuned!
Do you want to know more?
If you are interested in developing your own Azure or other cloud based system with OPC UA connectivity, feel free to contact us. We can provide you software tools and professional services that enable fast development in this rapidly growing new market.
You can send us email (firstname.lastname@example.org) or use the contact form.
Expertise and responsibility areas: OPC & OPC UA product development and project work
Prosys is a leading provider of professional OPC software and services with over 10 years of experience in the field. OPC and OPC UA (Unified Architecture) are communications standards used especially by industrial and high-tech companies.
Newest blog posts
This blog post intends to document DCOM issues in recent Windows 10 updates.
Season's Greetings from Prosys
Industry 4.0, Industrial Internet Consortium, Made in China 2025, etc. are adopting OPC UA as the Communication Protocol of Choice.