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)

/wp-content/uploads/2015/05/1_705026.png

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

/wp-content/uploads/2015/05/2_705022.png

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.  https://hanatrial.ondemand.com), 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].hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/[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.

/wp-content/uploads/2015/05/3_jpg_705027.png

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

/wp-content/uploads/2015/05/4_705028.png

              

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

/wp-content/uploads/2015/05/5_705029.png

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].hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/data/[device id]

This returned response with messages cached for Raspberry PI.

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

Reference:

Help document on IOT services: https://help.hana.ondemand.com/iot/

SAP IOT starter kit: https://github.com/SAP/iot-starterkit/

To report this post you need to login first.

2 Comments

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

  1. Rajesh Kumar Pasupula

    Hi,

    Good.. you are able to do hands on IOT on HCP..

    I would like to know how did python program linked to raspberry pi to push/pull messages to IOT..As I am totally unaware of the Raspberry Pi & python. so like to know the details on that..

    Thanks & Regards

    Rajesh

    (0) 
    1. Apoorv Bhargava Post author

      Hi Rajesh,

      Sorry for late reply.

      It would be difficult to provide a tutorial as part of this comment on how Raspberry Pi works with sensors . But I try to share very short information.

      There is good amount of material available online related to Raspberry PI and Python.

      I think if you have the interest and have one raspberry pi with you then it would be easier to understand.

      Raspberry pi is nothing but a small computer using one of the version of LINUX as operating system.

      It has  possibilities of I/O pins which can be connected to sensors.There could be different ways how to you read sensor data from RPi. e.g. in case of temperature sensor we read the data form a file which is constantly updated by sensors once certain modules are enabled on RPI.

      Python is just one of the many run time environments which can be used on RPI.

      It can be Java, C++ etc. as well.So you can choose based on your comfort.

      Regards,

      Apoorv

      (0) 

Leave a Reply