Skip to Content
Technical Articles

SAP Leonardo IoT – How to define your Device Model and start persisting measures

In a previous blog SAP Leonardo IoT for SMBs I gave a short overview and description of the SAP Leonardo services. In this blog I’ll like to go more in detail and explain how an IoT device can be modeled on the SAP Leonardo Internet of Things for the Cloud Foundry, 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!

 

Device Model

The first step is to define the device model of your specific device. The SAP Cloud Platform Internet of Things for the Cloud Foundry Environment Device Model documentation explains in details the different components and their relationship shown here below:

To define your device model, you can:

  • Use the SAP Cloud Platform Internet of Things for the Cloud Foundry Environment Cockpit
  • Use the Internet of Things Service APIs

 

Define you Device Model via SAP Cloud Platform Internet of Things for the Cloud Foundry Environment Cockpit

Navigate to your SAP Cloud 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 Cloud Platform 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:
https://trial.canary.cp.iot.sap/iot/core/api/v1/doc/

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.

 

Measures

Once your device modeled into the SAP Cloud Platform Internet of Things for the Cloud Environment you are ready to start persisting and retrieving your devices measures.

For sending measures to the SAP Cloud Platform 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 Cloud Platform 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:

Users may also retrieve measures that were stored in the SAP Cloud Platform 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.

More resources

You can find more explanations and samples about SAP Cloud Platform Internet of Things for the Cloud Foundry Environment at:

Check the full set of blogs part of our series on SAP Leonardo IoT (only two for the moment but will grow fast!):

Upcoming blogs will cover other SAP Leonardo IoT Services and prototype applications we have developed connecting to SAP Business One and SAP Business ByDesign, there are still some blogs to go so please stay tuned!

1 Comment
You must be Logged on to comment or reply to a post.