OPC UA Server to cloud for visualization
In this example, a sensor is providing temperature and humidity data as an OPC UA Server. Temperature data is displayed at the node while humidity data is presented at the Management System. Data is visualized with the visualization element of the Data Services.
The instructions below cover the following steps:
- Provisioning an OPC UA Server demo sensor as a Docker workload
- Deploying the provisioned Docker workload to the target node
- Configuring the Data Services Gateway on the node
- Local data visualization at the node
- Configuring the Data Services Gateway in the Management System
- Central data visualization in the Management System
Provisioning and deploying an OPC UA Server at the node
First, the temperature sensor simulation OPC UA Server must be deployed to the node as a Docker workload. Download the Data Services OPC UA demo sensor found under Example Applications from the Nerve Software Center. This is the Docker image that is required for provisioning the demo sensor as a Docker workload.
- Log in to the Management System. Make sure that the user has the permissions to access the Data Services.
-
Provision a Docker workload by following Provisioning a Docker workload. This example uses TTTech OPC UA Server - demoSensor as the workload name. Use the following workload version settings:
Setting Value Name Enter any name for the workload version. Release name Enter any release name. DOCKER IMAGE Select Upload to add the Docker image of the sensor simulation that has been downloaded before. DOCKER SPECIFIC INFO Select New port and enter the following settings: - Protocol: TCP
- Host Port: 4848
- Container Port: 4848
Container name tttech-opcua-server-demosensor
Network name bridge
-
Deploy the provisioned Docker workload by following Deploying a workload.
Note
Remember the node name and serial number of the target node. They are needed for the JSON configuration.
Configuring the Data Services Gateway on the node
With the OPC UA Server deployed, the Gateway instance on the node must be configured next.
-
Access the Local UI on the node. This is Nerve Device specific. Refer to the table below for device specific links to the Local UI. The initial login credentials to the Local UI can be found in the customer profile.
Nerve Device Physical port Local UI MFN 100 P1 http://172.20.2.1:3333 Kontron KBox A-150-APL LAN 1 <wanip>:3333
To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Kontron KBox A-150-APL chapter of the device guide.Kontron KBox A-250 ETH 2 <wanip>:3333
To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Kontron KBox A-250 chapter of the device guide.Maxtang AXWL10 LAN1 <wanip>:3333
To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Maxtang AXWL10 chapter of the device guide.Siemens SIMATIC IPC127E X1 P1 http://172.20.2.1:3333 Siemens SIMATIC IPC427E X1 P1 http://172.20.2.1:3333 Supermicro SuperServer E100-9AP-IA LAN1 <wanip>:3333
To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Supermicro SuperServer E100-9AP-IA chapter of the device guide.Supermicro SuperServer 1019D-16C-FHN13TP LAN3 http://172.20.2.1:3333 Supermicro SuperServer 5029C-T LAN1 <wanip>:3333
To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Supermicro SuperServer 5029C-T chapter of the device guide.Vecow SPC-5600-i5-8500 LAN 1 http://172.20.2.1:3333 Winmate EACIL20 LAN1 <wanip>:3333
To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Winmate EACIL20 chapter of the device guide. -
Select Data in the navigation on the left.
-
Select CONFIGURATION.
-
Enter the following configuration into the configuration editor of the Gateway:
{ "inputs": [ { "name": "client_demo_sensor", "type": "OPC_UA_CLIENT", "serverUrl": "opc.tcp://localhost:4848", "pollingInterval_ms": 1000, "connectors": [ { "name": "poll", "accessType": "polling", "nodes": [ "ns=2;i=2" ] }, { "name": "subs", "accessType": "subscription", "publishingIntervalAtServer_ms": 1000, "samplingIntervalAtServer_ms": 1000, "nodes": [ "ns=2;i=4" ] } ] } ], "outputs": [ { "name": "local_timescale", "type": "DB_TIMESCALE", "url": "<LOCAL>" }, { "name": "mqtt_pub_to_mgmtsys", "type": "MQTT_PUBLISHER", "serverUrl": "<MS-MQTT-BROKER>", "username": "<SN>", "password": "<SID>", "keepAliveInterval_s": 20, "qos": 0, "sslOptions": { "serverAuthRequired": false }, "cleanSession": true, "connectors": [ { "name": "demo_sensor_topic_0_to_mgmtsys", "topic": "demo_sensor_topic_0", "timestampFormat": "iso", "timestampRequired": true } ] } ], "connections": [ { "name": "demo_sensor_to_local_db", "input": { "index": 0, "connector": 0 }, "output": { "index": 0, "connector": 0 } }, { "input": { "index": 0, "connector": 1 }, "name": "demo_sensor_to_mgmtsys", "output": { "index": 1, "connector": 0 } } ] }
-
Select Apply to save the Gateway configuration. The Gateway will restart automatically.
The configuration defines the OPC UA Server demo sensor that was deployed earlier as a data input. The local TimescaleDB storage and the MQTT broker in the Management System are defined as data outputs. An OPC UA Client connects to the OPC UA Server demo sensor and periodically reads the value of temperature and humidity. Temperature values are forwarded to the storage on the node and humidity values are sent to the Management System via MQTT.
A success notification pops up in the upper-right to confirm that the Gateway has accepted the configuration and everything works as expected. Select the Logs tab to view the Gateway logs for more information.
To verify if data is stored in the database, select Database in the navigation on the left. Select the serial number of the node under Database and demo_sensor_to_local_db under Table. Select Preview to display the data stored in the database as a table.
Local data visualization at the node
To visualize temperature data at the node, open the local data visualization element through the Data Services UI on the node.
-
Select Visualization in the navigation on the left. The Grafana UI will open.
-
Select + > Dashboard in the navigation on the left. A box will appear.
-
Select Add Query in the New Panel box.
-
Select the data source from the drop-down menu. The name of the data source is the serial number of the node.
-
Fill in the following query information:
Setting Value FROM demo_sensor_to_local_db
Time column: "timestamp"SELECT Column: temperature Format as Time series -
Select the save icon in the upper-right corner to save the dashboard.
The dashboard can be accessed from the Grafana home menu.
Configuring the Data Services Gateway in the Management System
At this point the Gateway of the node is handling two data flows:
- Temperature data from the demo sensor to the TimescaleDB at the node.
- Humidity data to the MQTT broker of the Management System.
The next step is collecting and visualizing humidity data at the Management System. The example configuration in the instructions below connects the input of the Management System Gateway to the MQTT broker of the Management System, and transfers data through its output into the TimescaleDB in the Management System.
- Log in to the Management System
- Select Data in the navigation on the left. Make sure that the user has the necessary permissions to access the Data Services.
-
Select CONFIGURATION to access the Data Services UI.
-
Enter the following configuration into the configuration editor of the Gateway. Replace
<nodename>
in the configuration below with the name of the node that the Docker workload has been deployed to earlier.{ "inputs": [ { "name": "ms_mqtt_broker", "type": "MQTT_SUBSCRIBER", "serverUrl": "<MS-MQTT-BROKER>", "keepAliveInterval_s": 20, "qos": 1, "cleanSession": true, "connectors": [ { "name": "demo_sensor_topic_0_from_broker", "topic": "demo_sensor_topic_0", "variables": [ { "name": "humidity", "type": "uint64" } ] } ] } ], "outputs": [ { "name": "cloud_timescale", "type": "DB_TIMESCALE", "url": "localhost", "port": 5432, "connectors": [ { "name": "<nodename>", "dbName": "<SN:<nodename>>" } ] } ], "connections": [ { "name": "ms_mqtt_broker_to_cloud_timescale_db", "input": { "index": 0, "connector": 0 }, "output": { "index": 0, "connector": 0 } } ] }
-
Select Apply to save the Gateway configuration. The Gateway will restart automatically.
A success notification pops up in the upper-right to confirm that the Gateway has accepted the configuration and everything works as expected. Select the Logs tab to view the Gateway logs for more information.
To verify if data is stored in the database, select Database in the navigation on the left. Select the serial number of the node under Database and ms_mqtt_broker_to_cloud_timescale_db under Table. Select Preview to display the data stored in the database as a table.
Central data visualization in the Management System
To visualize humidity data in the Management System, open the central visualization element through the Data Services UI in the Management System.
-
Select Visualization in the navigation on the left. The Grafana UI will open.
-
Select + > Dashboard in the navigation on the left. A box will appear.
-
Select Add Query in the New Panel box.
-
Select the data source from the drop-down menu. The name of the data source is the name and serial number of the node, formatted as
<nodename> (<serialnumber>)
.Note
Note that multiple data sources can be selected in the Grafana instance of the Management System, depending on the number of nodes that are registered. Make sure to remember the serial number of the node that was used for workload deployment before.
-
Fill in the following query information:
Setting Value FROM ms_mqtt_broker_to_cloud_timescale_db
Time column: "timestamp"SELECT Column: humidity Format as Time series -
Select the save icon in the upper-right corner to save the dashboard.