Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

Now news is out. SAP has launched SAP Hana Cloud platform for Internet of Things. HCP IoT services BETA can be tried on the HCP trial landscape.

As an HCP+IoT enthusiast my immediate wish was to try my hands on these HCP IoT services. My objective of writing this blog is to share my experience of the same.

What is SAP Hana Cloud Platform IoT Services

SAP HANA Cloud Platform for the IoT provides the infrastructure to enable businesses to securely tap into a network of millions of connected devices and to make it easy for customers to deploy IoT applications at the edge, The services provide interfaces for registering devices and their specific data types, sending data to a database running on the SAP HANA Cloud Platform (HCP) in a secure and efficient manner, storing the data in HCP as well as provide easy access to the data stored.

There are 2 main components of IOT service

  • Remote Device Management Service (Used to onboard new devices)
  • Message Management Service (Used to manage messages between device, cloud platform and business applications)

Resources required

1.      Cloud platform->  Hana Cloud Platform Trial account . I registered here and got an account.

2.      Real IoT device (e.g. Raspberry Pi with Temperature sensor) OR Device simulator applications

Step 1: Enabling IOT Cockpit (Remote device management service) on my Hana Cloud account

1.      Go to Hana Trial account  -> Services

2.      Enable Internet of Things Service (BETA)

3.      Assign role “IOT-User” to your user

4.      After the above steps you should be able to see an application called “iotcockpit” in your subscribed application list (Go to “Subscriptions” tab)

Step 2: Installing Message Management Service

1.      Launch “iotcockpit” application

2.      Click on tile “Install Message Management Service”

3.      Enter Host (e.g., Account ID (account on which you wish to deploy MMS services), User id , Password

4.      Press “Install”

5.   Now you should be able to see application “iotmms”  on tab “Java Applications”

I used my trial account to enable both services  (iotcockpit and iotmms).In actual practice it will be different accounts.    

Step 3: Onboarding my Raspberry Pi on iotcockpit

               Since I already have a setup of Raspberry Pi connected with a sensor, I  on-boarded/registered the device on iotcockpit .

               Basically the below relations need to be established by defining and associating these entities

               Message Types (Incoming and outgoing) -> Device Type (e.g. Raspberry Pi in my case) -> Device  

1.      Launch “iotcockpit” application

2.      Go to “Messages” tile and define 2 message types (1 for incoming, 1 for outgoing). Define data fields you want to include in message types.

3.      Go to “Device Types” tile and define device type and associate above defined message types

4.      Go to “Device” and associate above defined device type.

I noted down ID of the registered device. And generated oAuth  token from “Authentication”  tab. These will be used  by consumer/device to communicate with IoT service.

Step 4: Sending message from my Raspberry Pi to IOT service

HCP IOT service comes with http and web socket based APIs so that iot devices/consumer applications can push/read the data.

I developed a python program for my raspberry pi to push sensor data.

The python program executes a web request following the rules of correct url preparation and setting the body content confirming to inbound message type.

e.g. I posted the below request body to the url https://iotmms[my account id][device id]

{"mode":"sync", "messageType":"1", "messages":[{"sensor":"MyTemperatureSensor", "value":[current temperature value], "timestamp":1232191650}]}

I used the noted  device id and the oAuth token (from Step 3) while preparing the web request.

After executing the program I could see the message sent from the device was available on IOT MMS table .

I used tile “Display Store Messages” to check my message.

Step 5: Reading data sent by my Raspberry Pi in a Java web app running on HCP

I created a small java web application (deployed on HCP) to read the data sent by my raspberry pi.

In this java application I connected to the same schema as iotmms schema e.g. [my account id].iotmms.web

For Java development on HCP you refer online documentation here


Step 6: Sending message from cloud app to my Raspberry Pi using IoT service

It is also possible to send the message to connected raspberry device from a business application.

In the same java web app I used the destination connecting to MMS Core API.

I sent  a  message to this destination. I could see that the message was cached and ready to be read by the device

Step 7: Raspberry Pi pulling/reading message from IOT MMS cache

After step 6, the messages destined for my raspberry pi (identified by device id) are cached in IOT MMS cache on HCP.

My raspberry pi needs to pull/read this data from cache using IOT MMS API.

I created one python application for this and deployed on my raspberry pi

The python application executed a web request (Method GET) against SAP IOT MMS API url.

e.g. https://iotmms[my account id][device id]

This returned response with messages cached for Raspberry PI.

Once messages are read IOT device can take action on sensors.


Help document on IOT services:

SAP IOT starter kit: