OPCUA+MQTT builds a general framework for the Internet of Things

Write in front:

In order to cope with the trend of standardization and cross-platform, to better promote OPC, the OPC Foundation has launched a new OPC standard-OPC UA based on the successful application of OPCDA. OPCUA is no longer based on the Distributed Component Object Model (DCOM). It is based on a service-oriented architecture (SOA). Therefore, in the next few years, OPCUA will gradually replace OPCDA and become a new generation of OPC standard to help Industry 4.0.

When it comes to MQTT, perhaps everyone is a bit unfamiliar. MQTT is a client-server based message publish/subscribe transmission protocol. It has the characteristics of light weight, simplicity, openness and easy implementation, especially in the field of Internet of Things (IoT).

The Internet of Things has always been a very hot topic, and data on the cloud is also a very common demand in the industry. As for how to achieve it, various manufacturers have provided a variety of different solutions, regardless of good or bad, the most suitable is the best. This article is mainly based on OPCUA and MQTT to construct a general framework of the Internet of Things to realize remote data transmission.

Overall network architecture

Many times, our needs are like this: There are N different devices or systems on site, and the protocol of each device or system is different. We hope that we can use a common and simple method to transfer these data to the cloud. , Realize remote access.

Such a requirement is actually one of the most typical applications of the Internet of Things, so OPCUA+MQTT may be a good choice. The overall framework design is as follows:

                                                                                     Figure 1 Overall network architecture

In order to realize the overall function, the device layer here uses Modbus Slave, which is based on Modbus TCP protocol to do simulation test. 5 variables are added, divided into pressure 1-pressure 5, corresponding addresses are 40001-40010, and the data type is floating point , The simulation results of running Modbus Slave are as follows:

                                                                             Chart 2 ModbusTCP server

Service layer

As for the service layer, it is mainly the development and application of the OPCUA server. Here we have two choices. One is to use third-party OPC software, such as products from companies such as Kepware, Knight, and Matrikon. This is relatively easy, just make the relevant configuration. However, another way is to develop it yourself, which is relatively more difficult.

Here I use a software developed by myself—CMS configuration integrated software. Through simple configuration, I realized ModbusTCP client data communication within 10 seconds. The results are as follows:

                                                                       Chart 3 ModbusTCPClient communication test

However, this part only realizes the function of ModbusTCP client. If you want to realize the function of OPCUA server, you need to activate the OPCUA server and add an OPCUA server under the server node. After the addition is complete, save and run again. The result is as follows :

                                                                            Chart 4 Open OPCUAServer

In order to test whether the OPCUA server is successfully started, a test is required. You can use the official software UAExpert to test it:

                                                                       Chart 5 OPCUAClient communication test

Data layer

(1) Before realizing the data layer function, you need to create an MQTT server. Here, an MQTT server program based on .NET CORE is used and deployed and run in Alibaba Cloud server (pay attention to the open port 1883 here), and the operation effect as follows:

                                                                                    Chart 6 MQTT server

(2) After the MQTT server is created, reopen a CMS configuration software to test the function of OPCUAClient. The UAExpert in the previous section is the official OPCUA client software, which is only used for testing. The CMS configuration software used here OPCUAClient is a client program developed by itself. After configuration, the running results are as follows:

                                                                                   Chart 7 OPCUAClient

(3) In the server node of the CMS configuration person, right-click to add an MQTTClient, and configure the relevant IP, user, password, subject and update time according to the MQTT server, as follows:

                                                                               Chart 8 MQTT client configuration

(4) After the configuration is complete, click the start button. After the overall operation, you can see that the MQTT connection is successful, and the latest data will be published to the specified topic according to the set cycle. The effect is as follows:

                                                                            Figure 9 Start MQTT client

(5) Open the MQTT server, and you can see that data is constantly being released. Here, in order to facilitate the observation of the results, the data of pressure 1 is simulated to increase by 1 per second, and the data received by the MQTT server is as follows:

                                                                      Chart 10 MQTT server data receiving

Application layer

Through the above related deployments, the entire OPCUA+MQTT can be realized. In actual applications, you only need to open an MQTT client, connect to the specified MQTT server, and subscribe to the corresponding topic to obtain real-time data at the device layer. Here is a commonly used MQTT client software, namely MQTT.fx:

                                                                                   Chart 11 MQTT.fx communication test

 

Written at the end:

This article aims to combine the current mainstream OPCUA unified architecture and MQTT communication protocol to realize a way of data to the cloud. For engineers in the automation industry, it can expand everyone's thinking. The future is more of a trend of combining IT and OT. Therefore, as every industrial control technician, we must always maintain a sense of crisis, continue to learn, and make continuous progress, so as to better face the rapid development of the future industry.

 

Guess you like

Origin blog.csdn.net/xiketangAndy/article/details/106338946