A walktrough to SAP Leonrado IoT Foundation – Create your digital twin with SAP Cloud Platform IoT Application Enablement
In this new Blog series, i want to cover a complete walktrough to SAP Leonardo Foundation IoT and my experience with this products.
And hopefully u can see how easily u can create and work with this products, to “connecting things with people and processes“.
In detail u can expect the following content:
1 | Create your virtual twin with SAP Cloud Platform Application Enablement (this blog) |
2 | Build up an IoT App on top of SAP Cloud Platform Application Enablement |
3 | Deploy your SAP Cloud Platform IoT Application Enablement App to the Cloud Foundry Environment |
4 | How to display a route in a SAP Cloud Platform Application Enablement IoT Application |
5 | How to connect SAP Analytics Cloud to SAP Cloud Platform IoT Application Enablement – part 1 |
6 | … |
Introducing
As already mentioned at e.g. SAP TechEd, the SAP Leonardo IoT Foundation is the technical backbone and provides in detail the following core services:
- Technical Services
- Data Management
- Business Services
In my last blogs my primary focus was on the Technical services, in the upcoming blogs i want to guide you trough the IoT Business Services wich are bundeled in SAP Cloud Platform IoT Application Enablement (AE).
Introducing to SAP CP IoT AE
SAP CP IoT AE consists of the follwing main features:
- Thing Services
- UI Content and Event Services
- Administration Services
- Analytics Services and APIs
- Location Services
- Rules Framework and Machine Learning*
*planned
With SAP CP IoT AE we are now able to use diferent microservices/API´s to build up our virtual/digital twin.
For our scenario we would now start already by the “Technical Services” to connect a thing to IoT service. For the simplicity i would use here my notebook/CPU usage, but this also works for example on a Raspberry PI.
A detailed description exists also for SAP Cloud Platform Internet of Things for Neo environment can be found at the “SAP Developers” page here
For the new SAP Cloud Platform Internet of Things for Cloud Foundry environment, the used script must be adopted, for this check the github link below.
Repetation: Device Creation in SAP CP IoT service (via the improved UI)
Please refer also to the offical documentation and additional to the latest release notes for changes, bug fixes an new functionalities.
Create a capability:
Create the Sensor Type and link the previously created capability:
Create your Device:
Finally create the Sensor for your device and link the Sensor Type:
To communicate on a secure way with IoT service we need the device certificate (i use here the PEM format) of our “Notebook”:
Important write down or copy the “Certificate Secret”, we need this in the next step for the creation of the key file.
Now its time to transform our certificate:
>openssl rsa -in ./MyNotebook-device_certificate.pem -out credentials.key
Enter pass phrase for ./MyNotebook-device_certificate.pem: <Certificate Secret>
writing RSA key
>openssl x509 -in ./MyNotebook-device_certificate.pem -out credentials.crt
We still now prepared to send the data to SAP CP IoT service, by executing the script but this i not required.
Because we want to build uour virtual twin, so lets enter SAP Cloud Platform IoT Application Enablement (AE).
Create the Digital Twin with the Thing Modeler with SAP Cloud Platform IoT AE
The entire point is now to enter the SAP IoT AE Launchpad were we cann access different applications.
https://<your-tenant>.flp-iot-sap.cfapps.eu10.hana.ondemand.com
In FLP we can now see the different tiles for the Tenant Administration an the the IoT Thing Modeler etc.
Important: Please have also a closer look in the detailed documentation about the “Thing Modeler” and his features here.
Our starting point is now the “Package Manager” to create a new package.
A detailed documentation about “Packages” can be found here.
After the successfully creation of the package we opening the “Thing Properties Catalog”:
During the creation of the package you can define, one the follwing “Scopes”:
- Private
- Tenant
If your package is e.g. defined as Tenant, you are able to reference to other packages.
This is helpful i u want to reuse existing own “Property Sets” or SAP predifned “Property Sets”:
Define the Property Sets
In the Thing Properties we create now two new property sets:
Name | Type |
Product Data | Basic Data |
CPU | Measured Values |
Also here pls check the documentation for detailed informations here.
The Product Data property set consists for “general” properties:
For the real “measures” we using the “CPU property set.
In the “Measured Values” section we add the “usage” with the uom an the data type and finally we specify a lower and upper “Threshold“:
Important: To define a “Property Set” from Type “Measured Values” its important to check this documentation for the successfully onboarding and the prerequisites.
In short to connect the “Thing” from IoT AE with the “real Device” from IoT service, the matching between the capabilty (IoT service) and the property set (IoT AE) must be identical, otherwise the mapping does not work. Therefore check always the documenation.
Finally our “CPU” property set looks now like this:
In the lower right corner we can now jump directly in the Thing Modeler:
Create the Thing Type
We creating now our “Thing Type” by filling up some basic information.:
Afterwards we adding now the property sets.
As u can see below based on the reference (during the package creation), we´re able now to choose also these one of these property sets for our thing:
But for now we want only using here our own defined property set.
Optional it´s possible to add a image to our “Thing Type” to having an visualization for the thing:
Connect the “virtual” thing with the “real” device
This most interresting task will be covered in the next few lines.
We connect now both “IoT worlds” (IoT service and IoT Application Enablement) ;o) together.
For this we just clicking in the upper left corner on the “new Thing”:
Afterwards we fill the required data and link now the “Thing” from SAP CP IoT AE to our SAP CP IoT service device:
And whoot….., the “matching” between the “capabilities” (IoT service) and the “property set” (Iot AE) is correct an we got now a successfull “Data Type Match” result !
After we complete this task, we got now the unique “Thing ID”.
Send data to IoT service and check if the data ingestion works
If we now come back to our entire python script, now its time to exectue this:
>python CPUusage.py
….we should now get the following console output, the value 200 eq HTTP 200. Our data is therefore successfully posted to SAP CP IoT service:
if we check now check this, we can see the data as well in the visualization:
And finally if we switch over to SAP CP Application Enablement, we can also the the data whcih is succesfully transfered from IoT service via “Ingestion Pipeline” into SAP CP IoT Application Enablement:
Update:
For all API fans (like me), SAP IoT AE provides a lot of API´s where we can CRUD access to our things.
E.g. we can already read the “Time Series Store” by calling the follwing REST API:
https://{{tenant_id}}.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things('442414166D8D4F79B809054EBE3B45C4')/iotae.sycor.syc.sap.blogs.notebooks:ZBook/CPU?timerange=1M&$top=2
Result:
In the next blog we would continue the little story.
We will create an SAP UI5 application with the SAP Web IDE (Full Stack) to visualize our Data and display our things.
Overview about Helpful Links
SAP Cloud Platform Internet of Things for the Cloud Foundry Environment
SAP IoT Application Enablement
Feature Scope Description for SAP IoT Application
Python Script to send CPU usage to IoT service via REST on GitHub
Starter Kit for the SAP Cloud Platform Internet of Things for the Cloud Foundry Environment
Enterprise Architecture Explorer – IoT Application Enablement
cheers,
Fabian
Hi Fabian,
Very helpful blog on IoT Application Ennoblement Kit. Thank you.
could you please share some details on what kind of Events or Alerts we will get if the set thresholds are met for any measure?
Thank you in advance,
Venu
Hi,
do you know if there is a free trial for the IoT AE?
Best Regards,
Steffen