Skip to Content

With the new IoT Services on the SAP HANA Cloud Platform (HCP) it has become much easier to work with IoT scenarios on HCP.

I’ll take the opportunity and will show you how to use the IoT Services with the scenario around my blog post series Rui’s Fish Import/Export.

Table of Contents

What needs to be changed

We’ll change what we have done in part 2 of this blog post series and in part 3

To demonstrate that on a high level let’s first look into the initial picture I’ve drawn at the beginning of this series.

/wp-content/uploads/2015/05/screen1_708299.png

The picture is not really very accurate. If we look into the details of what we have built so far, the picture should rather look like this:

/wp-content/uploads/2015/05/screen2_708300.png

Meaning we have developed and deployed a Java application on our HCP account which does two things. On the one side it’s a servlet that we use as an endpoint for the application on the Raspberry Pi. That servlet also stores the incoming data in a HANA schema.

On the other side that servlet reads-out the data from the HANA schema and provides it as a JSON stream for our HTML5 app.

With the IoT Services we’ll get rid of the Java servlet that retrieves and stores the data. We’ll keep the part that provides the JSON stream. With those changes our picture will look like this:

/wp-content/uploads/2015/05/screen3_708301.png

We’ll reduce our code footprint and also will get for free the possibility to add authorization capabilities to our scenario along with the IoT Services on HCP. Isn’t that cool?!

Let’s upgrade our app with the IoT Services

First thing we need to do is to enable the IoT Services in our SAP HANA Cloud Platform cockpit.

1. Enable the IoT Services

Task Screenshot

1. Open your cockpit for your trial account on SAP HANA Cloud Platform via the link https://account.hanatrial.ondemand.com/cockpit and switch to the Services navigation tab.

Click on the Enable button at the right for the Internet of Things Services (BETA) and wait a few seconds until you can click on the link Go to Service

Screen Shot 2015-05-20 at 21.00.12.png
2. Click on the link Go to Service Screen Shot 2015-05-20 at 21.00.46.png
3. Now you should see the Internet of Things Services Cockpit Screen Shot 2015-05-20 at 21.01.08.png

2. Install the Message Management Service

The Message Management Service will become our new endpoint for receiving the sensor data of our Raspberry Pi devices. Installing it is a straight-forward thing.

Task Screenshot

1. In your Internet of Things Services Cockpit you need to click on the tile Install Message Management Service.

After that you’ll have to provide your User Name and your Password of your account.

Finally click on the Install button.

Screen Shot 2015-05-20 at 21.01.51.png

2 Now you’ll notice that a new block will show-up in the screen.

You’ll find the link to the installed MMS application at the bottom.

Click on that link.

Screen Shot 2015-05-20 at 21.02.22.png

3. The link will bring you to a newly created Java application called iotmms.

This app needs to get started first.

While it starts we can use the time to assign your own user to the role IoT-MMS-User.

To do that click on the Roles tab

Screen Shot 2015-05-20 at 21.03.15.png

4. Select the role Iot-MMS-User with a click on the respective row.

Now click on the Assign button and add your user to the list of Individual Users.

Screen Shot 2015-05-20 at 21.03.31.png

5. Now click again on the Overview tab your iotmms Java Application and wait until the State switches to Started.

Once that happens you can click on the link you find under the Application URLs.

Screen Shot 2015-05-20 at 21.03.48.png
6. The Message Management Service of the IoT Services is now finally up-and-running on your account. Screen Shot 2015-05-20 at 21.04.10.png

3. Create our new endpoint on the IoT Services

Now that the Message Management Service is up and running we can take the next step and configure our new endpoint without having to write one line of code. I’ll try to stick to the meta model we have setup in blog 2 of this blog post series so that you should be able to follow the steps easily.

Task Screenshot

1. On our Message Management Service screen we click on the tile View registered devices and device types.

As we haven’t created anything, yet, there shouldn’t be any Device Types, Devices or Message Types available.

Screen Shot 2015-05-20 at 21.04.52.png

2. First we’ll click on the tile Device Types.


Click on the + button at the bottom to create a New Device Type called Raspberry Pi.

Finally click on the Create button.

Screen Shot 2015-05-20 at 21.10.59.png

3. You should see now that we have created one Device Type.

In a next step click on the tile called Message Types.

Screen Shot 2015-05-20 at 21.12.26.png

4. The Message Types will be our container for our data model.

We click on the + button at the bottom to create a New Message Type called Sensor Temperatures.

As a Device Type you should select the entry we’ve just created before called Raspberry Pi.

As a Direction please select From device.

Now we add the Fields of our data model to the Message Type.

Screen Shot 2015-05-20 at 21.16.30.png

5. Create a field for unit, storedAt and for value as shown in the screenshot at the right.

You can add new fields by clicking on the + button in the Fields section.

Please be sure the Type for each field is set correctly and click on Create.

Screen Shot 2015-05-20 at 21.17.48.png

6. Your screen should look like the one you see at the right.

If you click on the Fields icon you should see the same fields like in the screenshot. Click on the arrow icon at the top left to get back to your IoT Cockpit.

If you don’t you’ve done something wrong. Only in such a case: select your Message Type, click on the trash can icon below and create the Message Type again starting from point 4 from above.

Screen Shot 2015-05-20 at 21.18.28.png

Screen Shot 2015-05-20 at 21.18.36.png

7. Your Internet of Things Services Cockpit should now look like the screenshot at the right.

Last major step is now to click on the tile called Devices.

Screen Shot 2015-05-20 at 21.18.46.png

8. Click on the + button and type in a New Device called Truck 1 – Fish box Salmon.

Click on the Create button to save your New Device.

Screen Shot 2015-05-20 at 21.19.17.png

9. This step is now very important for the new authorization part in our scenario.

We’ll get an OAuth Token for the device that we need to save somewhere in a text file.

After you’ve done that you can confirm with clicking on the Close button.

Screen Shot 2015-05-20 at 21.19.31.png

10. You should now see your newly created device listed under the list of Devices.

Another important ID we’ll need later on is the ID of the Device.

You can find it if you click on the Info icon. The ID will be shown then.

Please also store this ID together with the OAuth token you’ve already stored before.

Screen Shot 2015-05-20 at 21.20.02.png

11. By clicking on the + button at the bottom you can now create as many Devices as you want to your list of Devices.

Just follow the same steps from 8 – 10 to do so.

Once you are done just click on the arrow button at the top left to get back to your IoT Cockpit.

Screen Shot 2015-05-20 at 21.21.07.png
12. In case you have created 2 devices like I did, your IoT Cockpit should look like the screenshot Screen Shot 2015-05-20 at 23.59.58.png

What is missing?

Well. We’ve just clicked together our new IoT endpoint without having to create ONE single line of code. What we have now is an API interface that our Raspberry Pi can use.

We’ll have still to:

  • update our Java app on the Raspberry Pi to use the new endpoint
  • change our former Java app so that it connects to the HANA schema from the new endpoint
  • change our former Java app to that it just creates the JSON stream

I’ll post these last steps as new blog post within the next couple of days.

Hope you’ll have fun with the new IoT Services on the SAP HANA Cloud Platform!!

Best,

Rui

To report this post you need to login first.

12 Comments

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

  1. P. Lans

    Again a very clear step-by-step tutorial. On to the next steps Thanks Rui!

    I think the IoT service will prove to be a valuable asset to HCP

    (0) 
  2. Didier Heck

    Great posts series Rui. Eager to see the new Raspberry Pi Java code taking advantage of the Data Services of the MMS API offered by the HCP IoT services. Are you planning to take also advantage of the Push Service in a new version of your HTML5 app to push some messages to the Raspberry Pi ?

    (0) 
  3. Twan van den Broek

    Hi Rui

    I’ll post these last steps as new blog post within the next couple of days.

    So, any update when that couple of days will be finished?

    😛

    No worries, just curious to learn more in your next blog.

    thanks to Rui’s Fish Import/Export for great times with SAP and IoT.

    (0) 
    1. Rui Nogueira Post author

      I’m finishing it this week. There won’t be any need for a Java app as I wrote above. It’ll be the IoT Services and an HTML5 app only. I like it 🙂

      Best,

      Rui

      (0) 
      1. P. Lans

        Great to hear Rui,

        I anxiously await the last part.

        I proceeded on my own. Ditched Java (really not my thing) on the Pi and started over with Python. It is sending data to SAP HCP via the IoT service and it stores it into a SQLAnywhere database if the service returns an error.

        I just can’t get the UI5 application to work properly with the data.

        So I’m highly interested to see how you’ve done that.

        Kind regards,

        Peter

        (0) 

Leave a Reply