Skip to Content
Technical Articles

SAP IoT Demo – Part 1 & 2

Hi All,

In this blog series I’ll explain my learning journey on the Internet of Things Service (CF). This is a growing blog and be divided into 4 different sections:

For this demo we use a Rasberry Pi 3 Model B+ with a DHT11 sensor. The sensor is able to measure temperature and humidity.

Part 1 – onboarding the device

  • Navigate the the SAP Cloud Platform Internet of Things Cockpit (CF) and logon.

  • Select the tenant

  • First it’s important to check and understand the device model for the Internet of Things Service.
  • Define the capability C_MT_DHT11. The capability will have 2 properties which are being send from the sensor: humidity and temperature.

(If you want, you can change the Alternate ID. In this demo SAP will just generate one for me.)

Be aware of next message. This means that if you made a mistake, you’ll have the recreate the capability.

  • Create a sensor type ST_MT_DHT11

For now we only create a measure, so to receive values from the sensor.

  • Create a device called D_MT_GREENHOUSE


  • Create a sensor called S_MT_CONDITIONS, which is an instance of ST_MT_DHT11

  • Now let’s delete the default sensor which we don’t need.

Now we have successfully created the device and we can move to part 2, data ingestion.

Part 2 – data ingestion 

  • First the DHT11 sensor must be connected to the Raspberry Pi, click here for the details.
  • The Adafruit Python DHT Sensor Library must be installed, click here to go directly to the instructions.
  • SAP has provided a very useful IoT Starterkit with code snippets & examples, click here to go directly to the Python script that is used as reference for this demo.
  • The script has been modified a bit to read the temperature & humidity values from the DHT11 sensor, the script is called “”. Please refer to below screen shot for the full code. Please replace the values for line 7-10 with the corresponding tenant and alternate ID’s. I used Thonny Python IDE to to create the code.

import sys
import Adafruit_DHT
import time
import requests
import json

config_alternateId_4_device='<Alternate ID device>'
config_alternateId_4_sensor='<Alternate ID sensor>'
config_alternateId_4_capability_up01='<Alternate ID capability>'

temp = 0.00
hum = 0.00

while True:

    humidity, temperature = Adafruit_DHT.read_retry(11, 4)
    data = {'humidity':humidity,'temperature':temperature}
    json_data = json.dumps(data)
    temperature1 = str(temperature)
    humidity1 = str(humidity)

    request_url='https://' + config_instance + '/iot/gateway/rest/measures/' + config_alternateId_4_device
    payload='{ "capabilityAlternateId" : "' + config_alternateId_4_capability_up01 + '", "measures" : [[ "' + humidity1 + '", "' + temperature1 + '" ]], "sensorAlternateId":"' + config_alternateId_4_sensor + '" }'
    headers={'Content-Type' : 'application/json'}, data=payload, headers=headers, cert=('./credentials.crt', './credentials.key'))
  • Download the PEM certificate and save the security key, which is needed in next step as the “pass phrase”. In this demo a separate folder is created on the Raspberry Pi with the name “IoTGreenhouse”

  • To authenticate the device the next steps needs to be done for the certificate:

Copy past code from here:

openssl rsa -in D_MT_GREENHOUSE-device_certificate.pem -out credentials.key
openssl x509 -in " D_MT_GREENHOUSE-device_certificate.pem -out credentials.crt

Result should be:

  • Then running the script should send values to the SAP Cloud Platform

Now we are able to ingest real sensor data, so we can proceed with next step.


Part 3 – SAP IoT Application Enablement (Create digital twin)

Click here to navigate to part 3.


Part 4 – Creating an application using an IoT template in the Web IDE

(expected shortly, first week of January)


Thanks for reading and feel free to share comments/ feedback or any other meaningful inputs :).




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