Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 



Hello Community,

Welcome to the "Set Up the Internet of Things Edge Platform - MQTT" blog.

This blog will be the second part of a journey of blogs written by c3d1947136cd4c748a7aa794001af496 , thomasswolfs and myself.

In the previous blog c3d1947136cd4c748a7aa794001af496 talked about the functional case of this coffee machine project and provided a high-level overview of this IoT scenario.

This blog will cover the installation and setup of the SAP IoT Edge Platform MQTT service.

This installation will be done on a Raspberry Pi 3 Model B+ device.

Next we will cover the installation of the Paho MQTT-Client in a virtual environment to publish data to the SAP IoT Service Cockpit.

After this installation we will show you how to build a Python Script to use this Paho MQTT-Client to publish the data.

Eventually you can verify the data in the SAP IoT Service Cockpit under the Data Visualization section.


It's recommended to have a know-how on the setup of devices and sensors and their capabilities in the SAP IoT Service Cockpit. This properties will be used later in the blog to publish the data.


Blog series about the Smart Coffee Machine, here you have an overview:

Useful documentation links


SAP Help Portal: Set Up the Internet of Things Edge Platform - MQTT

Python Software Foundation: Install Paho-MQTT


Download, install and set up IoT edge gateway


Download the Internet of Things Edge Platform (and Adapters)

Download the Internet of Things Edge Platform from the SAP Software Center. This software is available here in the SAP Software Center.


Install the IoT Edge Platform (and Adapters)

Extract the downloaded .zip folder.

Inside the extracted folder, you can find another ZIP file. Please extract this gateway-<version>.zip. 

Navigate to the extracted gateway directory and open a terminal on this location.

Depending on what OS you are working on launch the right script to install the gateway. On Windows launch the (build.bat), on MacOS ( and on Linux and Raspberry Pi also the ( We use the Raspberry Pi in this blog.

Dont forget to pass the parameter MQTT.

So your command should look like this:


A new file config_gateway_mqtt.xml is created in the /config folder.


Set up the IoT Edge Platform (and Adapters)

Open the config_gateway_mqtt.xml with a text editor.

Enter the host name for your connection-string :

(update the {SAMPLE} part with your tenant host name)

Your code block should look like this:
<!-- <cnf:connectionString>failover:(nio://;soTimeout=60000)?initialReconnectDelay=5000</cnf:connectionString> -->
<cnf:ackMode>1</cnf:ackMode><!-- AUTO_ACKNOWLEDGE = 1 / SESSION_TRANSACTED = 0 -->
<cnf:nonPersistent />

Next provide the host name for the address in the core connection:

(update the {SAMPLE} part with your tenant host name)

Set the first transport connector for your MQTT-broker equal to your device IP -address:

(update the {YOUR-DEVICE-IP-ADDRESS} part with your device IP -address)
<cnf:transportConnector name="mqtt" uri="mqtt://{YOUR-DEVICE-IP-ADDRESS}:61618?transport.soTimeout=60000"/>
<cnf:transportConnector name="mqtt+mutualAuth" uri="mqtt+nio+ssl://;transport.soTimeout=60000"/>
<cnf:transportConnector name="nio" uri="nio://"/>
<cnf:transportConnector name="tcp-connector" uri="tcp://"/>



Download the IoT service cockpit certificate


You can find the certificate when you log on to the Internet of Things Service Cockpit.

This under your user information:

Download the certificate

Next you will have to create a new folder named certificates inside the config folder:

In this folder you extract the downloaded certificate file.

Your certificates folder will contain the following files:

Open the file and change the following line with your password:


Save it.



Run the IoT edge MQTT gateway


To run the IoT edge gateway navigate to the directory /gateway.

In here we will try to run the edge gateway.

This with the following command (.sh linux, .bat windows):



Depending on what device you want to run the gateway on you could get the following error:

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

This because the the VM cannot reserve enough space to launch and run the gateway.

This can be solved by running the following command, which will increase the available memory:

export _JAVA_OPTIONS='-Xms64M -Xmx128m'


When we try to run the gateway again with:


We will see the gateway is starting.

If the Internet of Things Edge Platform is started successfully, you see the following message Initialization successfully finished.



Install the Paho-MQTT client


To send the data to the SAP IoT Service Cockpit you will need a MQTT-Client.

We will use the Paho MQTT-Client.

You can download the GUI MQTT-Client tools here.

We will use the command line in this blog since we are working on the Raspberry Pi.

This command line installation is explained here.

We will use the virtual environment to start the MQTT-Client.

You can create and start this environment as follows:

Run the following commands:
sudo pip install virtualenv

virtualenv paho-mqtt

source paho-mqtt/bin/activate

pip install paho-mqtt

After executing this commands you will see your command line starts with the name of the environment in front of it.



Develop a Python script


To send our data to the IoT Service Cockpit we will build a Python-script thats uses the MQTT-Client to send the data.


Provide your id's in the following variables:

YOUR-IP-ADDRESS = The device its IP-Address

deviceId = "YOUR-DEVICE-ID"
sensorId = "YOUR-SENSOR-ID"
capabilityId = "YOUR-CAPABILITY-ID"

Change {YOUR-VALUE} to a value you want.

This publish payload is build according to the capabilities you configured in you SAP IoT Service Cockpit.

The Script:
import paho.mqtt.client as mqtt
import sys


# Create new instance
client = mqtt.Client("P1")

# Connect to the ip-address of the DELL IoT Edge Gateway with the specified portnumber and timeout
client.connect("YOUR-IP-ADDRESS", 61618, 60)

# Variables
# sensor and capability id -> use alternate id
deviceId = "YOUR-DEVICE-ID"
sensorId = "YOUR-SENSOR-ID"
capabilityId = "YOUR-CAPABILITY-ID"

#This is a special variable that is send with the payload while publishing.
#The use of this variable will be explained in a later blog of Wouter Lemaire about Interceptors.

#Fill in the publish payload with values for {YOUR-VALUE}

client.publish("measures/"+ str(deviceId) +"","{ \"capabilityAlternateId\": \"" +str(capabilityId) + "\",\"sensorAlternateId\":\""+
str(sensorId)+"\", \"measures\":[["+ "\"" + str({YOUR-VALUE}) +"\"" +","+
str({YOUR-VALUE}) +","+ "\"" + str({YOUR-VALUE}) +"\"" +
","+ str({YOUR-VALUE}) +"," + str({YOUR-VALUE}) +
","+ "\"ct\"" +"]]}")

except KeyboardInterrupt:
print('\ncaught keyboard interrupt!, bye')

Save the script with a name and the .py extension.

We used the same script to publish our data over MQTT.

Our script is extended with some extra code to read our waterflow sensor data.


Run the Python script


Finally the moment to run the Python-script. This can be done by navigating to the folder where your script is in and running the following command:

python {YOUR-SCRIPT-NAME}.py

Here you can see the script measuring the waterflow.

The script will publish the data to the SAP IoT Service Cockpit. Time to verify!


Verify the data in SAP IoT service cockpit


Navigate to your device and scroll down to the Data Visualization section.

Select your sensor and the desired properties.

As we can see the data successfully entered the SAP IoT Service Cockpit into our device.

The Interceptors also recognized the type of coffee and they marked it as an Espresso.

More about Interceptors in the next blog by c3d1947136cd4c748a7aa794001af496.



What did we do in this blog


We learned a lot of things about the SAP IoT Service Cockpit and the setup and installation in the EDGE MQTT component.

Some bullets to recap our learning path and what we've learned:

  • We downloaded the Internet of Things Edge Platform (and Adapters)

  • We installed the Internet of Things Edge Platform (and Adapters)

  • We configured the Internet of Things Edge Platform (and Adapters)

  • Found out where to download the IoT Service Cockpit Certificate

  • We ran the IoT Edge MQTT Gateway

  • We installed the Paho MQTT-Client

  • We developed a Python script

  • We ran the Python script

  • We verified the data in the IoT Service Cockpit


We really hope this blog was interesting and helpful to you and we really enjoyed working on this project!

We are happy to announce our next blog about Interceptors, by c3d1947136cd4c748a7aa794001af496.

A big thanks to c3d1947136cd4c748a7aa794001af496 for the nice teamwork and a big thanks to the Flexso Digital company for making this project possible!


Greetings, c3d1947136cd4c748a7aa794001af496 , thomasswolfs & vvdries


Labels in this area