OPC-UA Integration with Cumulocity

OPC UA connectivity

OPC UA connectivity 


  1. You have a Cumulocity Tenant and user credentials to log in.
  2. Tenant should have "Feature-fieldbus4" enabled. Trial accounts do not have this feature enabled by default. 

This section explains how to connect devices to Cumulocity IoT platform via OPC UA. OPC UA is a machine to a machine communication protocol for industrial automation. It was developed and released by the OPC foundation in 2006. 

OPC UA supports two protocols, a binary TCP and web service (SOAP) protocol. The protocol is distinguishable by the URL. The binary protocol uses opc.tcp://host while the web service protocol uses http://host

Set up the OPC UA Simulation Server:   

This use case uses OPC UA simulation server by Prosys. Download and install the OPC UA Simulation server from https://www.prosysopc.com/products/opc-ua-simulation-server/. Once the installation is successful, user should see the below Figure 1. The Status tab should show a Connection Address for both TCP and HTTP access.

Figure 1

Now switch to the Simulation Tab. Make sure that OPC UA server generates random values for different signals as shown in Figure 2. Use can also create their own signal, if they want. 

Figure 2

Switch to the Address Space tab. The left side of the window shows the hierarchical structure of nodes that are available in your OPC UA server. Expand till Simulation node. User can see the signals like the Simulation tab as shown in Figure 3.  On clicking any signal under the Simulation node, attributes of the corresponding signals should be shown on the right-hand side. 

Figure 3

Device Connectivity: 

This section explains about how to register a new gateway device in the platform. This gateway device will connect to the OPC UA server and send measurements to the platform. 

Go to Device Management app and navigate to Registration in the main menu. Click on Register Device. Choose the General device registration and enter an arbitrary identifier for you gateway device for e.g., opcua-demo.

Figure 4

Newly registered device should now be in status WAITING FOR CONNECTION.

Run the OPC UA Gateway: 

In this section, we will connect OPC UA server to the Cumulocity platform. Use the attached OPC UA gateway for this purpose. To run the OPC UA Java gateway, execute the following command in a terminal: 

java -jar cumulocity-opcua-agent.jar --gateway.identifier=opcua-demo -platform.url=https://siqa.staging-latest.c8y.io/ 

The OPC UA Java Gateway now starts and connects to your tenant: 

Figure 5

Now user can go to Device management App. The newly registered device should now be in status PENDING ACCEPTANCE. Click on Accept button. A new device should appear in the Device management as shown in Figure 6.  

Figure 6

Configure the OPC UA Gateway: 

Before we can connect the OPC UA Gateway to our OPC UA server, we must define the device type, so that the platform knows what signals you want to read from the OPC UA server.  

Navigate to the Device Protocols under Device Types in the Device Management application (not visible if Feature-fieldbus4 is not enabled). In the upper right corner click on Add Device protocol. Select OPCUA from the available options and enter Simulation as name. Now click the Add button to add Variables to the device type. We will add the Counter1 signal from our OPC UA server first. Proceed as follows: 

  • Counter as name.
  • 5:Counter as Browse Path 

Note: this is the browse Name of the signal below the device node in the OPC UA address space. If you have nested nodes below your device node in the OPC UA server, you have to provide the full path to the signal including all parent nodes up until the device node. The nodes are separated with a slash-sign (e.g. 5:subnode1/5:subnode2/5:Counter1). Do not include the device node itself in the Browse Path. 

  • Select Show status (read-only access) under functionalities 

Repeat the same step for the Expression1 signal. For all other signals select Send measurement under the functionalities section and provide: 

  • SimulationMeasurement as measurement type
  • <name of the signal> as measurement series 

Your final result should look like as shown in Figure 7. 

Figure 7

Configure the OPC UA Connection: 

Now we can connect the gateway to the OPC UA Server. Go back to the Device Management and Click on the gateway device. Notice the tab OPCUA on the left side and navigate to it. 

  1. From the OPC UA Simulation Server status tab, copy the TCP Connection Address (opc.tcp://…) and paste it to the URL field.
  2. Set transmition Rate to 2 seconds
  3. Set polling rate to 2 seconds
  4. Click the Add OPCUA device link
  5. Enter Simulation as name
  6. Enter 5:Simulation as directory path
  7. Select SimulationType as device type 
  8. Click the Add button
  9. Click the Save changes button 

Show Measurements : 

The connection between the OPC UA gateway, the OPC UA server, and the Cumulocity platform should work seamlessly now. Go to the Device management. Click on Gateway Device. A new tab named child devices should show up in the device navigation. Click on it. There should be one child device named Simulation in the list. Click on the Simulation child device and select the Measurement tab. 

1 Like