Product Lifecycle Management Blogs by SAP
Dive into product lifecycle management news, learn about digitalizing PLM for the digital supply chain, and stay informed with product updates from SAP.
cancel
Showing results for 
Search instead for 
Did you mean: 
lukas_riegel
Explorer

Introduction


Since version 15.1 SP5 MQTT source and destination systems are available in SAP Plant Connectivity (PCo). In the 15.2 release of PCo, client certificates have been added to the authentication for the Universal Web service destination system.

This provides the required capabilities in order to connect PCo technically to SAP Cloud Platform Internet of Things for the Cloud Foundry Environment (also known as IoT Services).

In this blog post, we will illustrate how to configure the end to end connection of those systems.

Prerequisites



  • An installation of SAP Plant Connectivity

  • A tenant for SAP Cloud Platform Internet of Things for the Cloud Foundry Environment

  • A tenant for SAP IoT Application Enablement

  • Both tenants must be connected if you want to see your data in SAP IoT Application Enablement


Scenario


We are going to stick to the exemplary data model provided in the Starter Kit for the SAP Cloud Platform Internet of Things. This model consist of an "Ambient" capability able to measure Humidity, Temperature and Light.

The goal is to send some measurements from SAP Plant Connectivity to the modelled instance.

Package configuration


First step is to set up the data model in SAP IoT Application Enablement. The example will be based on the APIs of SAP IoT Application Enablement:



POST /Configuration
{
"version": "1.0.0",
"id": "<packageId>",
"scope": "private",
"description": {
"en": ""
},
"dependencies": [],
"services": {
"dataService": {
"thingTypes": [
{
"name": "<packageId>:iotstarterkit",
"description": {
"en": ""
},
"propertyTypes": [
{
"id": "Ambient",
"description": {
"en": ""
},
"propertySetType": "<packageId>:Ambient"
},
{
"id": "Image",
"propertySetType": "<packageId>:Image"
}
]
}
],
"propertySetTypes": [
{
"name": "<packageId>:Default",
"description": {
"en": "Default PST"
},
"dataCategory": "MasterData",
"propertyTypes": []
},
{
"name": "<packageId>:Image",
"description": {
"en": "Image properties"
},
"dataCategory": "MasterData",
"propertyTypes": [
{
"value": {
"description": {},
"id": "ImageName",
"length": "127",
"type": "String"
}
}
]
},
{
"name": "<packageId>:Ambient",
"description": {
"en": ""
},
"dataCategory": "TimeSeriesData",
"propertyTypes": [
{
"value": {
"description": {},
"id": "Humidity",
"type": "Numeric",
"unitOfMeasure": "%",
"qualityCode": "0"
}
},
{
"value": {
"description": {},
"id": "Temperature",
"type": "NumericFlexible",
"unitOfMeasure": "°C",
"qualityCode": "0"
}
},
{
"value": {
"description": {},
"id": "Light",
"type": "Numeric",
"unitOfMeasure": "CD",
"qualityCode": "0"
}
}
],
"annotations": []
}
]
}
}
}




Please note down the id of the capability.

Now, we are going to bring the capability together in one SensorType:



POST /iot/core/api/v1/sensorTypes

{
"name": "iotstarterkit",
"capabilities": [
{
"id": "<capability id measure>",
"type": "measure"
}
]
}




Please note down the id of your sensor type.

Finally, we can create our device and attach a sensor to this device:


POST /iot/core/api/v1/devices

{
"name": "IoTStarterkit-Device",
"gatewayId": "<mqtt gateway id>"
}





POST /iot/core/api/v1/sensors

{
"name": "IoTStarterkit-Sensor",
"deviceId": "<your device id>",
"sensorTypeId": "<your sensor type id>"
}




Once again, please note down the id and the alternate id of your device and your sensor.


Thing onboarding


Now, we will create a Thing in Application Enablement. We are going to model a robot with one arm. At the end of this blog post, we are going to send commands to this robot arm via MQTT.



POST /Things

{
"_externalId": "IoTStarterkit-Device1",
"_name": "IoTStarterkit-Device1",
"_description": {
"en": "IoTStarterkit Thing"
},
"_thingType": [
"<packageId>:iotstarterkit"
],
"_objectGroup": "<your_ObjectGroup>"
}




Here again, please note down the id of the created Thing.

The next step is to connect the Thing in IoT Application Enablement with the Sensor in IoT Services. This is done using the following API call:



POST /mappings/sensorthing

[
{
"thingId": "<thingId>",
"sensorId": "<sensorId>"
}
]




SAP Plant Connectivity Configuration


In order to speed up the configuration we provide a template for configuring the connectivity from SAP Plant Connectivity to IoT Services.

Please import the template file in PCo. The password is mentioned in the linked webpage.

After importing the template configuration, you should be able to see one Source System and two Destination Systems as shown in the screenshot below:



Required Configuration Steps



  • Source System - Section Client: Client ID

  • Source System - Section Client: Server URI

  • Source System - Section Connection: Session Certificate

  • Destination System - Section Message Settings: Topic Name


The above mentioned steps are required in order to adjust the template to your system.

We will guide you through those steps in the following section of this blog.

The first step is to adjust the Client ID and Server URI in the configuration. To do so, please select the Source System and ensure you are on the tab called 'Client' on the righthand side. Use the alternateId of your Device as Client ID and point the Server URI to your IoT Services tenant.



SAP Cloud Platform Internet of Things for the Cloud Foundry Environment allows devices to connect to the Internet of Things Gateway Cloud (using MQTT or REST) through a secure TLS connection, where client certificate authentication is in place. Thereby, Transport Layer Security, version 1.2 (TLS1.2) is used. To establish a secure connection from SAP Plant Connectivity to the Gateway Cloud it is necessary to configure the so called 'Session Certificate' in SAP Plant Connectivity. This is done one the second section in the source system called 'Connection'. Please select the certificate matching to your device here. The certificate has to be downloaded from IoT Services (either through the Cockpit or using the APIs) and imported into the Windows Certificate Store. A guide how to do this is published by Microsoft on their website - this guide is valid until step 15.





The ClientID has to be configured in the destination system as well. This is done on the last section called 'Message Settings'. Please use the alternate Id of your device here again.



SAP Plant Connectivity Configuration Test


Normally, data would be consumed/collected from a source system like OPC UA, OPC DA or Modbus in PCo and then sent to the destination system - in out case the destination system we configured in the previous steps. To allow testing of the destination without the need to connect to a actual source system we created a second destination system called 'SAP_CP_IoT_MQTT_Testing'. This can be used for your local tests. It basically uses some variables, that can be manually entered and calls the MQTT destination system with them.

To start your configuration, please select the 'SAP_CP_IoT_MQTT_Testing' destination and select the second section called 'Variables'. Herein maintain the variables - especially the sensorAlternateId and capabilityAlternateId. Please ensure those values match the alternateId of your previously created Sensor, respectively Capability.



To finally test the MQTT destination, please click on the 'Test Configuration' button highlighted in the screenshot.



After executing the local test in PCo you should be able to review the data arrived in SAP Cloud Platform Internet of Things. To do so, please navigate to your tenant and use the 'Data Visualization' to review the data sent to the Gateway Cloud MQTT.



As we connected our Thing we modelled in SAP IoT Application Enablement with the sensor in IoT Services we are able to see the data in IoT Application Enablement, too.


Summary


I hope you could follow all the explained steps and got an overview of the required steps to establish a connection between SAP PCo and SAP Cloud Platform Internet of Things for the Cloud Foundry Environment. Feel free to ask your questions in the comments, if there are any open.

26 Comments