Set up the OPC UA Connector for Easy Integration

Set up the OPC UA Connector for Easy Integration

October 9, 2020
TeamViewer IoT Documentation

It is effortless to monitor your sensor network via TeamViewer IoT. This article describes the integration approach to monitor OPC UA server node values. For more about OPC UA reference the OPC Foundation (see https://opcfoundation.org/).

The setup contains three basic steps. Follow the sections in this article:

  1. Install software dependencies
  2. Download and extract the OPC UA Connector
  3. Integrate the OPC UA Monitoring Script with the TeamViewer IoT Agent

What you will need

Make sure that you have prepared the following points:

Install software dependencies

  1. Access the edge device remotely (Access the Edge Device via Remote Terminal).
  2. Install Python 2 or Python 3 (see https://www.python.org/downloads/).
We recommend installing Python 3.
  1. Update the python libraries pip, setuptools and wheels. In the terminal type in the following command and press return.
python -m pip install --upgrade pip setuptools wheel
  1. Install the python library freeopcua. In the terminal type in the following command and press return.
pip install freeopcua

Download and extract the OPC UA Connector

  1. Access the edge device remotely (Access the Edge Device via Remote Terminal).
  2. Download the connector. In the terminal type in the following command and press return.
wget https://download.teamviewer-iot.com/connectors/teamviewer-iot-opcua/1.0.0/teamviewer_iot_opcua-1.0.0.tar.gz
  1. Create a new folder and extract the downloaded connector. In the terminal type in the following commands and press return. Record the path (PATH) where you extracted the connector.
sudo mkdir -p /usr/local/teamviewer-iot-agent/monitoring/
tar -xzvf teamviewer_iot_opcua-1.0.0.tar.gz -C /usr/local/teamviewer-iot-agent/monitoring/opc-ua

Integrate the OPC UA Monitoring Script with the TeamViewer IoT Agent

The TeamViewer IoT Agent includes its system Monitoring Configuration File (see JSON Schema for Custom Plugin Connector). Extend the configuration file to include the OPC UA monitoring script.

The Monitoring Configuration File is located at: /var/lib/teamviewer-iot-agent/system_monitors.conf.

To avoid data loss. Before editing the configuration file, create a backup.
  1. Access the edge device remotely (Access the Edge Device via Remote Terminal).
  2. Open the Monitoring Configuration File with the editor nano. In the terminal type in the following command and press return.
sudo nano /var/lib/teamviewer-iot-agent/system_monitors.conf

For each OPC UA sensor you want to integrate, append its registration information to the configuration file. Reference the example file below and replace the placeholders with your OPC UA node details.

Make sure to replace the value of monitoringService with the path (PATH) from the of the extracted connector from step Integrate the OPC UA Monitoring Script with the TeamViewer IoT Agent.

  1. Save the file and close the nano editor.
  2. Restart the TeamViewer IoT Agent to reload the configuration file. In the terminal type in the following command and press return.
teamviewer-iot-agent restart
  1. To log in to the IoT Management Console, open https://teamviewer-iot.com and use your TeamViewer account credentials.
  2. From the IoT Management Console navigate to Metrics and verify the newly integrated sensors and metrics are updated.
  3. Optional: From the IoT Management Console navigate to Metrics and pin the two metrics to the dashboard (See Add A Widget).

Example Monitoring Configuration File

{
    "sensors": [
        {
            "name": "opcua_node_aa",
            "monitoringService": "python /usr/local/teamviewer-iot-agent/monitoring/opc-ua/opc_ua_connect.py",
            "monitoringParams": "--url opc.tcp://myopcuahost:26543 --nodeId "opcua_node_id" --frequency 2",
            "metrics": [
                {
                    "name": "opcua_node_id",
                    "key": "opcua_node_id",
                    "valueType": "double",
                    "valueAnnotation": ""
                }
            ]
        },
        ...
    ]
}

For more information about the schema of the Monitoring Configuration File see JSON Schema for Custom Plugin Connector.

Related posts

Want more? Exclusive deals, the latest news: Our Newsletter!