Simple OPCUA Device Integration

OPUCA Device Integration

Have you encountered OPCUA devices? Wondering how to connect them to Cumulocity ? Then, this blog is for you !!!

This blog covers Simple OPCUA Device Integration. Let’s jump into the topic!


All the information and screenshots provided in the blog is from Cumulocity version 10.14. Any version between 10.10 - 10.17 should also follow same process unless there is some breaking changes in the later versions.


Jave 11
OPCUA Server
OPCUA Gateway Agent
OPCUA Microservice - opcua-mgmt-service

Pre-requisites are detailed below:

Java 11 - For cumulocity version 10.10 onwards
OPCUA Server - A real one or simulation server.
OPCUA Gateway Agent - It is a jar file. Download agent of your tenant version from here. If you do not find agent of your tenant version, you can use version close to your tenant version from previous subversions.
OPCUA Microservice - opcua-mgmt-service should be subscribed. Request support to subscribe it to your tenant.

Note: Only after Pre-requisites are fulfilled, you can proceed to the next step.

To integrate OPCUA device to Cumulocity, there are 3 steps to be followed.

Step 1: Register the Gateway agent

First step is to register the Gateway Agent to the platform. Gateway serves as integration software where OPCUA server connection is established. Place the agent jar file in your desired location. Here since I’m using linux platform, i will place it in the following location - /etc/opcua

To Register the Gateway Agent we need to have a java property file from which OPCUA Gateway metadata details are read. So let’s create a property file in the same location where we placed the jar file, with the following file name - application-<<Profile_name>>.yaml and below content.

baseUrl: https://{{yourTenant}}
identifier: OPCUA_Gateway_Device
name: OPCUA Gateway device
#The gateway uses the local database to store platform credentials and local cache. This parameter shows the location in which the local data should be stored.
baseDir: C:/Users/{{userName}}/.opcua/data


Now we are ready to register the agent to Cumulocity. To do that, login to your tenant and go to Device management application and click on Registration options
Click on Register Device

Next, Click on General device registration and add device identifier name which was given in the java properties file earlier.

Click on Next and Complete. Now you see the device registration is waiting state.

Now we need to start the OPCUA Gateway Agent jar using the following command -
java -jar opcua-device-gateway-1014.0.408-SNAPSHOT.jar,development

Run the command in the directory when jar and property file is placed.

Once the agent is successfully started, you will see the device you want to register needs your approval. If any code or token is asked, provide something and Click on Accept.

On successful registration, device is created and shown in the All devices.

Now, you have successfully finished one step in integration.

Step 2: Connecting Gateway to OPCUA server

Click on the registered Gateway device and Navigate to OPC UA Server tab. Add OPCUA server details to connect gateway to OPCUA server. Specify details mentioned according to the number in the below screenshot and Save.

On Successful save, device will be created with the Server name you specified while adding server. Click on Child devices tab and you see the server device.

Click on the server device and navigate to Control page. You will that operation will be created automatically to scan the Address space. Depending on the size of the address space of the server and its response time, time taken to complete the operation depends.

Wait until the Scanning operation finishes. After the scanning is completed, verify in the Address space tab that you can see the tags.

Now you have successfully completed the step 2.

Step 3: Connect the device and its datapoints using Device protocols

Navigate to Device protocols and click Add device protocol and enter device name, description and select reference server and click Create.

In creation page, enable the protocol and add Variables as many as you want. Ideally you need to select the datapoints that belong to the device and decide how that datapoint is written to Cumulocity and select the functionality. In this example, I have selected to write the data as measurement. Click Save

Then, In Data reporting section, Mechanism will be none by default. Select Subscription, which subscribes to the mapped node. And specify the Sampling interval - This is the rate at which the server checks the data source for changes. Specify the Queue size - The size of the queue where it holds the samples before reporting. Select the Discard value. By default oldest will be selected. Select the Data change trigger - Triggers notification if node’s status, value or timestamp has changed. Select Deadband filter. By default it wil be none.

In Auto apply constraints section, select Limit device protocol to a set of servers and select the created server device. And finally, click Save.

Now the device protocol is created. After a minute or so (in the background, platform is checked if device is created or if there are any newly added device protocol or any update in the device protocol) then device gets created from the device protocol along with the measurement added in the Variable section. If alarms were mapped then alarms get created based on the values. If events were mapped then events get created.

Verify, If you are able to see the device created from device protocol and its measurement, if yes then you have successfully integrated the OPCUA server and its device to Cumulocity.


Note: If you want to integrate more devices then follow step 3 for each of the devices separately.

This blog covers simple and precise OPCUA Integration with Cumulocity. You can try out different configuration available once you are able to achieve the simple one. For more and detailed info of the configurations, visit - Official Cumulocity documentation on OPCUA

Bulk OPCUA Device Integration

The above approach of creating devices using device protocol configuration makes sense when we are integrating 1 to 5 devices or small number of devices. But just think what if we have to create more than 100 or 1000 or perhaps 5000 devices!!! :thinking: We have to create 5000 device protocols. :scream: :sweat: Just imagine how much time and patience would be required to create that number of device protocol with the above approach. :sob: It is nearly impossible for any ordinary human or even extra ordinary ones starts loosing patience. What do we do in this case?? :thinking:


No problem!! There is always a solution to a problem. This problem led to a solution using which you can integrate any number of devices and datapoints in minutes (Speed of device protocol creation depends on your network and cumulocity tenant response). Here is the link to the solution.

Smiling Leo Perfect GIF

1 Like