SAP IoT – How to define your Device Model and start persisting measures
In a previous blog SAP IoT for SMBs I gave a short overview and description of the SAP Intelligent Technologies services offered by SAP Business Technology Platform. In this blog I’ll like to go more in detail and explain how an IoT device can be modeled on the SAP IoT services for SAP BTP for the Cloud Foundry Environment, we will then focus on the Onboarding & Device Management level to move into higher levels in subsequent blogs.
Along the blog I’ll provide many pointers to already available documents and tutorials covering the different topics I talk about; my goal is to compile all the links together on these blogs and not to repeat the materials already available. Please play the game and click on the different links not to miss any detail!
The first step is to define the device model of your specific device. The SAP IoT services for SAP BTP for the Cloud Foundry Environment documentation explains in details the different components and their relationship shown here below:
To define your device model, you can:
- Use the SAP Business Technology Platform Internet of Things for the Cloud Foundry Environment Cockpit
- Use the Internet of Things Service APIs
Define you Device Model via SAP Business Technology Platform Internet of Things for the Cloud Foundry Environment Cockpit
Navigate to your SAP Business Technology Platform Internet of Things for the Cloud Foundry Environment Cockpit tenant and login with your credentials.
Once logged in, for each one of your tenants you will see the number of Devices, Sensors, Capabilities,… that are available in your tenant:
You can drill down and check the details for each one of your Devices, Sensors, … The first time you connect they will of course be empty. In my case I have defined 4 Devices that are represented by 3 Sensors, each one of a different SensorType, and I have defined 4 Capabilities containing each one a set of Properties measured by my devices. You can of course create new Devices, Sensors and Capabilities representing your specific device.
For more information, please refer to the Internet of Things Service Cockpit documentation explaining each one of the screens available as well as how to create, edit and delete the different components of your IoT DeviceModel.
Define your Device Model via Internet of Things APIs
The same operations available in the SAP Internet of Things for the Cloud Foundry Environment Cockpit are available as Service APIs on your tenant.
You can find the available APIs directly on your tenant:
– Device Management API: https://<HOST_NAME>/<INSTANCE_ID>/iot/core/api/v1/doc
– Message Processing API: https://<HOST_NAME>/iot/processing/api/v1/doc
Or from a trial link at:
You can test the APIs with a tool like Postman and of course you can develop your own scripts/applications creating automatically your devices, sensors, capabilities, …
The following example shows how to get the list of Devices in a tenant by executing the request /iot/core/api/v1/devices on my IoT tenant url via Postman:
The tutorial Create a Device Model Using the API shows how to create a device model for the Internet of Things Service using the Device Management API.
Once your device modeled into the SAP Internet of Things for the Business Technology Platform Environment you are ready to start persisting and retrieving your devices measures.
For sending measures to the SAP Internet of Things for the Cloud Environment, APIs are also available. You can call directly these APIs from your device (if the device is able to do it) or you will need an Edge component close to your device capable to send the device measures to the cloud.
There are two types of Gateway protocols supported by SAP Internet of Things for the Cloud Environment. Depending on the Gateway you specify while creating your Device Model a different protocol needs to be used to send the measures to the cloud:
- MQTT Gateway – Send Data with MQTT
- REST Gateway – Send Data with REST
Users may also retrieve measures that were stored in the SAP Internet of Things for the Cloud Foundry Environment database.
You can check the measures stored for your Device directly in the Internet of Things Service Cockpit:
Or you can use the REST APIs to retrieve the measures:
For more information, please refer to the tutorial Consume Measures.
We have shared a Postman collection containing several API samples as part of the materials we published at the SAP SMB Innovation Summits 2019 Hackathons, just replace your tenant URL on the provided samples to execute them against your tenant.
You can find more explanations and samples about SAP Internet of Things for the Cloud Foundry Environment at:
- SAP Internet of Things YouTube Play List – several videos going into details of each option on the SAP Leonardo Internet of Things cockpit, check all the videos!
- Enable SAP Internet of Things Service for Cloud Foundry – for the moment (07/05/2019) not available on trial accounts.
- IoT Starter Kit – contains references to documentation as well as end to end samples
- SAP IoT build block – set of documents and samples we prepared for the SAP SMB Innovation Summits 2019 Hackathons.
- Don’t forget the SAP Internet of Things for the Cloud Foundry Environment main page for more details.
Check the full set SAP Leonardo IoT blog series:
- SAP IoT for SMBs
- SAP IoT – How to define your Device Model and start persisting measures
- SAP IoT – Digital Twin
- SAP IoT – Services
- SAP IoT – WebIDE templates and controls
- SMB.io: IoT mobile app prototype
Happy IoT development!
Brilliant blog, Maria.
Is there still a trial version for the SAP IoT services for SAP BTP for Cloud Foundry?
I do not seem able to activate it in my trial account.
Thank you in advance
Unfortunately IoT services are not available on the BTP trial version.