How to connect a OPC-UA device to SAP Asset Performance Management

This article has been originally posted here: How to Connect a OPC-UA Device to SAP Asset Performance Management - SAP Community

Introduction

New month, new big release! With version 2511 of SAP Asset Performance Management (APM), the Embedded IoT capabilities powered by Cumulocity reached General Availability (GA) status. In this post from the APM product team, you can get an overview of the 4 IoT applications that are now available to SAP Asset Performance Management customers.

To celebrate this next milestone, we wanted to share our next guide with you as a follow-up on our post where we showed how you can easily connect your smartphone to get started quickly.

Overview

To get started with SAP Asset Performance Management and connect real-world machines, you can leverage existing device protocols like OPC-UA. In this guide, we demonstrate how to use the Embedded IoT platform (powered by Cumulocity) to connect physical devices via OPC-UA and correlate them with assets provided by SAP APM.

We will leverage multiple components in this scenario:

  • Simulated pumps with an OPC-UA client
  • thin-edge.io running an OPC-UA Server and the Cumulocity OPC-UA Gateway to transfer the data to Cumulocity
  • Cumulocity as an embedded IoT cloud system and capabilities like
    • Device Management
      • OPC-UA Remote Management
      • Software Management
      • Cloud OT Protocol Mapping using Device Protocols
    • Cockpit
      • Dashboarding
    • Digital Twin Manager
      • Mapping & Correlating Device data to Asset data in SAP APM
    • SAP Asset Performance Management
      • Asset Data Management
      • Maintenance Rules & Alert Management

Let’s get started!

Prerequisites

To follow this guide, the following prerequisites must be fulfilled:

  • You have access to an SAP APM instance including Embedded IoT platform.
  • You have Docker and Docker Compose installed on your machine. We will use them to simulate a device, including an OPC-UA simulation server.

Step-by-Step Guide

1. Start thin-edge.io demo container

To simulate a device that runs an OPC-UA + simulation server, we leverage thin-edge.io, which is a powerful open-source edge framework that can connect with ease to the embedded IoT platform Cumulocity. For demonstration purposes, there is a demo container available that installs thin-edge with tons of pre-installed and configured plugins that let us manage the device fully remotely, showcasing the power of the Cumulocity platform.

First of all, you need to download a docker compose file:

curl -LSs https://raw.githubusercontent.com/thin-edge/tedge-demo-container/main/demos/docker-compose/device/docker-compose.yaml > docker-compose.yaml

Or using wget:

wget https://raw.githubusercontent.com/thin-edge/tedge-demo-container/main/demos/docker-compose/device/docker-compose.yaml

Before we start the container, we need to register it in Cumulocity. From within SAP Asset Performance Management launchpad, navigate to the “Manage Devices” application to sign-in to the Embedded IoT platform.

Within “Device Management” navigate to “Management” → “Trusted Certificates”. Here click on “Add CA Certificate” in the top right toolbar which will add the CA certificate to the tenant which is used to issue new device certificates. Please note: If you already have the CA certificate added, the button “Add CA certificate” is disabled and you can proceed.

Navigate to “Devices” → “Registration”. Please remember & save your tenant URL from your browser address bar. You need to provide it in some steps below, e.g. https://<Your Cumulocity Tenant URL, ending with *.iot.sap>/apps/devicemanagement/index.html#/deviceregistration

Click on “Register device” → “General”.

Toggle to create device certificate during device registration and enter the following:

  • Device ID: ThinEdge-cooling-line3
  • One-time password: in4mU32icNVjj3c

! Important !: This password here is just for demonstration purposes. Replace this with any secret token of your choice)

Click on “Next” to create the device registration.

Next you can start the demo container with the following command in the folder where you have downloaded the docker-compose.yaml to:

docker compose up -d

Afterwards we need to bootstrap it with the following commands (take the domain for the saved tenant URL).

docker compose exec tedge tedge config set c8y.url <Your Cumulocity Tenant domain without https://>

And (replace the one-time password with your selected password)

docker compose exec tedge tedge cert download c8y --device-id ThinEdge-cooling-line3 --one-time-password in4mU32icNVjj3c

Finally we need to connect thin-edge:

docker compose exec tedge tedge connect c8y

In the „Device Management“ application, you should now see the thin-edge device with the Name “ThinEdge-cooling-line-3”.

2. Make OPC-UA Gateway & OPC-UA Simulation Server available via Software Repository

Great, thin-edge devices are up and running! As a next step, we want to create a Cumulocity OPC-UA gateway within the demo container that allows us to establish a connection to an OPC-UA server.

Cumulocity in combination with thin-edge allows to remotely deploy and run Docker containers directly from the Cumulocity Device Management application in your browser. Therefore, there is no need to go to any console, do a Docker pull or run; it can be all done within the Device Management App of Cumulocity. To do this, we need to create so-called software artifacts, which contain a docker-compose.yml file.

Luckily, there is another thin-edge repository that does the job for us: https://github.com/thin-edge/opcua-device-gateway-container

For our purpose, we can use the following Docker Compose file: https://raw.githubusercontent.com/thin-edge/opcua-solution-blueprint/refs/heads/main/software/docker-compose-opcua-device-gateway-demo-container.yml

Within SAP Asset Performance Management, navigate to the “Manage Devices” application → Management → Software Repository.

Click on “Add Software” and provide the following information. Select “Upload File” and select the docker-compose.yml file you created in the previous step.

Repeat the step for adding an OPC-Server that simulates data but using the following Docker Compose file and details:

In the end, you should have two software entries added in the Software Repository:

3. Install Cumulocity OPC-UA Gateway & OPC-UA Simulation Server

With the software artifacts for the Cumulocity OPC-UA Gateway and the OPC-UA Simulation Server created successfully, we want to install them in our thin-edge demo container by using the Device Management capabilities.

Within “Manage Devices”, navigate to “Devices” → “All devices” and search for “ThinEdge-cooling-line3,” which should return our thin-edge demo container.

When clicking on the device, we see all the capabilities. One capability of the thin-edge demo container is to install software remotely via the “Software” Tab. At the bottom, click on “Install software.” In the opened windows, you should see the opc-ua gateway & opc-ua simulator. Select for both the version “1.0.0” and click on “Install.”

Finally, start the installation process by clicking on “Apply changes.”
After a short time, you should see that both components were successfully installed.
You can confirm success by selecting the “Services” Tab. The opc-ua demo server and opc-ua gateway should be listed there.

4. Configure the OPC-UA Server

Now that both components are installed and running in our thin-edge demo container, we need to configure them. Continuing on the “ThinEdge-cooling-line3” device, navigate to “Child devices.” You should see a new child device named “OPCUAGateway”, please select it.

There, you can find a Tab called “OPC UA server.” Click on “Add server” and provide the following information:

  • Server name: OPC-UA Demo Server
  • Server URL: opc.tcp://opcserver:4840

Keep all other settings to default and “Save” the server.

With the connection to the server configured, the “Child Devices” Tab now shows an established server connection that appears as another child device called “OPC-UA Demo Server”. Click on it and select “Address space” to check the simulated and provided objects and sensors. Please note that it will take a few minutes for the address space scan to complete. The “Pump01” is especially interesting as it will be used in the next step.

5. Create Device Protocol

With the simulated pump connected via OPC-UA we can map data from the pump object to the Cumulocity domain model. We will do that by creating a so-called “Device Protocol”

From SAP Asset Performance Management, navigate again to the “Manage Devices” application which takes you seamlessly to the “Device Management” capability in Cumulocity. The device protocols can be defined in “Device Types” → “Device Protocols”. Click on “Add device protocol”, select “OPC UA” and provide the following information:

  • Name: Pump01
  • Description: Device Type for Pump01
  • Reference server: OPC-UA Demo Server
  • Select “Root” node

When clicking on “Create” you can configure the variables. Click on “Add variable”. Navigate to Pump01 and select “flow”.

Toggle measurement with the following settings:

  • Type: flow
  • Series: flow
  • Unit: l/m

Click “Save”.

Repeat the steps for “bearingTemperature”:

  • Type: bearingTemperature
  • Series: bearingTemperature
    -Unit: C

And finally “power”:

  • Type: power
  • Series: power
  • Unit: W

If you want you can also create the other variables like described in the screenshot below:

In the “Data Reporting” section select “Cyclic read” with a reading interval of “3000” msec. Finally activate (on top) and save the Device Protocol.

Navigate back to “Devices”. You should see a new Device there called “Pump01” that represents the created protocol definition. When clicking on “Measurements” and activating real-time by clicking on the dot in the top you should see the values coming in.

6. Creating Indicators in SAP Asset Performance Management

With the data available in Cumulocity you can now focus on assigning it to technical objects from SAP Asset Performance Management. This step bridges the OT and IT world, bringing device semantics into the process and master data context from the IT world. In our case, we assign the simulated pump to a “Cooling Water Circulation Pump” but you can assign it to any other asset of your choice as available in your system. To proceed with assigning the sensors, you need a representation of them as indicators in SAP APM. Follow the documentation to create three indicators:

  • Pump Bearing Temperature
  • Pump Flow Rate
  • Motor Power

7. Assign Data Points to Indicators

SAP Asset Performance Management automatically provisions Technical Objects along with their indicators into the Embedded IoT platform for data contextualization. From the APM launchpad, open the “Map Devices to Assets” application, which navigates to the “Digital Twin Manager” within Cumulocity.

Use the search in the top right area to search for the identifier of your Technical Object (e.g. 217100093 from the screenshot above, or any parent object such as 1710) to easily open the corresponding asset. The indicators are shown with their nomenclature from SAP Asset Performance Management and can now be “linked” to their corresponding measurements/series from the OPC UA protocol definition via the “Link source” button.

After successful assignment, the measurement data will be made available within SAP Asset Performance Management.

8. Review data in SAP Asset Performance Management

You can validate that time series data from your simulation server is now available on the Technical Object for further processing within SAP Asset Performance Management. Open the “Explore Technical Objects” application and navigate to the “Cooling Water Circulation Pump”. On the “Indicator Monitoring” tab, you can see the incoming data in the time series chart.

Please note that it can take up to 90 minutes until data is available in APM.

Conclusion & Next Steps

This guide demonstrated how you can connect an industrial device via OPC-UA to Embedded IoT powered by Cumulocity and assign its measurement data to an existing technical object in SAP Asset Performance Management.

This described setup uses a simulated pump. If you want to leverage OPC-UA in a productive use case, you may follow the steps described here:

Doing so you would not use the thin-edge demo container, but install thin-edge.io locally on a gateway that has access to an already available OPC-UA server where devices are already connected to, or utilizing a certified device from Cumulocity’s extensive hardware partner catalog.

1 Like