Skip to Content
Author's profile photo Aaron Williams

Using the SAP HCP IoT Services

As a Product Manager for HCP, focusing on IoT, I have been asked to do a lot of CodeJams.  Most of the CodeJams have been on Getting Started on SAP HCP, but with the new release of the SAP IoT Services, we can do IoT CodeJams. For the CodeJams and other events, we need a step by step process on how to get started.  Using Michael Ameling’s great how to” post as a starting point, and trying to re-use as much of his team’s code as possible, I created a number of tutorials.  And since I also wanted to help people get started before they had hardware, I added in how to test your IoT Services using Postman (a REST Client).  If you, never used one of these, it will help get you started with APIs.

I shared them with colleagues to get them proofed and tested.  They gave me great feedback and then passed them around internally here at SAP. So I figured that I could just post them here and share with the wider SAP Community.

Here they are:

  1. Getting Started with the IoT Services–  Just like is says, this gets you going.
  2. Connecting a Java HTML UI5 GUI–  Creating a simple graph and how to upload it.
  3. Connecting a UI5 GUI using WebIDE– This uses the SAP WebIDE to build everything. –added details on how have both the WebIDE and Java working
  4. Nodejs and Python– Writing the python or node.js code that you will need.
  5. Building up the hardware– Using a Tessel-
  6. Completing the Round Trip-  Using the messaging to send messages to your devices.– coming soon

Links:

Rui’s Fish Import/Export – how to build a full project using SAP HCP

The SAP HCP Podcast

SAP Insurance’s IoT House Video

Where SAP HCP is traveling

Gamification Service– How get started with SAP Gamification

Assigned tags

      34 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      The tutorials are easy to follow and helpful especially when you don't have any hardware device at hand.

      Thank you for this awesome post!

      Author's profile photo Aaron Williams
      Aaron Williams
      Blog Post Author

      you are welcome...

      Author's profile photo David Lincourt
      David Lincourt

      Great tutorial. I used it along with the "Starter Kit for the SAP HANA Cloud Platform Internet of Things (IoT) Services" (https://github.com/SAP/iot-starterkit).

      I purchased a GrovePi+ Starter Kit For The Raspberry Pi from Dexter Industries (Raspberry Pi Internet of Things Kit). Their team was very responsive to get my GrovePi+ up and running. Then I adapted the example provided in the Starter Kit - I have a rotary angle sensor rather than a slider... no code change here) and I used a LCD RGB display instead of the OLED one. Only very minor change required.

      Here is a photo of my computer. You can see the UI5 app that displays the data on the HANA Cloud Platform, my Raspberry Pi console, and my webcam showing the output on the LCD.

      IoT_Trial.png

      I plan to use the button from the kit to trigger the start/stop of data collection instead of having to crank up the sensor to the max to start and then to 0 to stop. I would also like to do some statistical analysis of the values... things like average, max, min, rate of change, etc.

      More to follow.

      In closing, thanks to the community for sharing so much knowledge that getting up and running was very easy!

      David

      Author's profile photo Aaron Williams
      Aaron Williams
      Blog Post Author

      David, this is great, you really should create a blog post for it, so that more people can see it and learn from it!

      Author's profile photo David Lincourt
      David Lincourt

      Thanks Aaron - will do when I get something a bit more substantive up and running.

      Author's profile photo Marcus Conrad Behrens
      Marcus Conrad Behrens

      Aaron - you did it again end-to-end tying all of the innovations together from iot device management to ui5 user experience.

      To me the gem in this series is the transition from the hana table exclusively used by the mms service to an xs service exposing odata such that analytics tools from Microsoft (like PowerPivot) or SAP (Smart Business) can make use of it.

      Author's profile photo Aaron Williams
      Aaron Williams
      Blog Post Author

      Thanks.  As much as I would like to take full credit for that, I got about 95% of the code from one of our great Architects, @Anton Levin

      Author's profile photo Felipe Hernandez Plazas
      Felipe Hernandez Plazas

      Aaron, excellent post, thank you for that. I have a question regarding IoT Services:

      In MMS, according to the documentation (SAP HANA Cloud Platform Internet of Things (IoT) Services (beta)), the websocket secure protocol is used to connect to the service.

      Will it be possible to access a websocket endpoint using ws protocol instead of wss?

      Author's profile photo Aaron Williams
      Aaron Williams
      Blog Post Author

      No you have to use wss.  For good or bad, everything that the IoT services does has to use the "secured" part of the protocol (so https- yes, http- no, wss- yes, ws- no)

      Hope that helps...

      Author's profile photo Felipe Hernandez Plazas
      Felipe Hernandez Plazas

      Yes, this helps, thanks!

      Author's profile photo Jan Gottweiss
      Jan Gottweiss

      Excellent post!

      Thank you!

      Author's profile photo Former Member
      Former Member

      Hi Aaron, these are very convenient procedures. Thanks a lot!

      But I encounter an issue in part 1 when using sample client to send data with the message type which I created. It shows code 202 and 409, and when I check the stored message, there is no such table matching to the message type that I created. Is this a bug currently or did I miss some steps? Thanks

      websocket result.jpg

      Author's profile photo Anton Levin
      Anton Levin

      Hi Ji,

      "roomstatus" is a wrong value for the "messageType". You should use its ID instead not the name.

      Regards,

      Anton

      Author's profile photo Former Member
      Former Member

      Hi Anton,

      Thanks for your help. That is the reason.

      Best Regards,

      Ji JING

      Author's profile photo Denys Kempen
      Denys Kempen

      For those interested, Philip Mugglestone of the SAP HANA Academy has posted a blog about the new hand's-on tutorial series on the IoT Services:

      Hand's-On Video Tutorials for Internet of Things (IoT) Services

      Author's profile photo Former Member
      Former Member

      Hi Aaron, I still have an issue regarding to field with date type in message type.

      What data format should be for the type of date? Now I send the message with data "2015-12-14 09:00:14", I will get the reply said that "400  {"msg": "Parse error. Expected [timenow] of type [Date]"}".

      Thanks and Best Regards,

      Ji JING

      Author's profile photo Anton Levin
      Anton Levin

      Hi Ji, as documentation says, dates should be ISO-8601 compatible strings or unix time in seconds SAP HANA Cloud Platform Internet of Things (IoT) Services

      Regards,

      Anton

      Author's profile photo Former Member
      Former Member

      Hi Anton, thanks for your help. Now it is solved 🙂

      Author's profile photo Marcus Conrad Behrens
      Marcus Conrad Behrens

      Use UTC or local time with timezone in ISO8601 format. I tried IoT Services with a timestamp with datatype Date and this sample is from now and it works: 2015-12-15T09:34:59Z

      Author's profile photo Former Member
      Former Member

      Hi Marcus, thanks for your help. Now it is solved 🙂

      Author's profile photo Former Member
      Former Member

      Hi, Any one tried to link any user created table to be used to store IOT data?

      By default the tables are created by MMS according to message types, but what is the way that we link user created HANA tables to be used instead of auto generated table?

      Regards

      Srivatsan

      Author's profile photo Anton Levin
      Anton Levin

      Hi Srivatsan,

      it is possible with the MMS Processing API. See intro documentation here SAP HANA Cloud Platform Internet of Things (IoT) Services

      And more detailed information with some snapshot is directly available in your MMS instance. Open in browser https://iotmms<your-user>trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/processing/api

      Regards,

      Anton

      Update

      Also this link will be helpful SAP HANA Cloud Platform Internet of Things (IoT) Services

      Author's profile photo Former Member
      Former Member

      Hi Anton,

      Thanks for the Links but I find that these are not to use any custom defined table as is (Replace the MMS table with our table directly) but they allow us to change the column names and table names..

      Regards

      Srivatsan

      Author's profile photo Anton Levin
      Anton Levin

      But isn't it exactly what you want? For example, you have your custom defined table CT with columns C1, C2, C3 and your IoT Message Type MT with fields F1, F2, F3

      With the following mapping:

      {

        "deviceType":"DT",

        "messageType":"MT",

        "processingService":"sql",

        "properties":{

        "mms.processing.sql.mappings":{

        "table_name":"CT",

        "column_names":{

        "F1":"C1",

        "F2":"C2",

        "F3":"C3"

        },

        "add_default_columns":false

        }

        }

      }

      MMS will store all incoming messages to a table that you have created. Maybe, I understood you usecase wrong?

      Regards,

      Anton

      Author's profile photo Gunnlaugur Th Einarsson
      Gunnlaugur Th Einarsson

      When enabling IoT service I get this

      /wp-content/uploads/2016/01/iot_failed_862316.jpg

      Any ideas ?

      Author's profile photo Aaron Williams
      Aaron Williams
      Blog Post Author

      sorry I don't.  Is this in the trial version?  If so, it would seem that the service was down for some reason when you tried to enable it. 

      Did it magically start working again?

      Author's profile photo Anton Levin
      Anton Levin
      Author's profile photo Former Member
      Former Member

      Hello,

      I am trying to run a demo but I came across a weird problem.

      Problem occurs in HCP, with my trial account. There seems to be a problem when trying to access the service of IoT, within the Services available in HCP. Every time I try to access the service cockpit (“Go to service” link) I get 6 errors, such as “Could not load hierarchies”, “Could not load data types” etc. Due to the above errors and as far as I understand, I am not able to add new message types or device types etc…

      Any ideas about a solution?

      Author's profile photo Anton Levin
      Anton Levin

      Hello Athanasios, please check with IoT FAQ https://help.hana.ondemand.com/iot/frameset.htm?a012a3788b6e498a8971dd27c97ce6bf.html

      IoT Cockpit
      Why does the IoT Cockpit display error messages telling me that entities cannot be loaded?

      Cause: Your trust settings are wrong.

      Solution: SAP HANA Cloud Platform cockpit > select your account > select Trust in the left menu. The option Principal Propagation must be Enabled.

      Regards,
      Anton

      Author's profile photo Former Member
      Former Member

      Hello Anton and thank you for the reply,

      The Principal Propagation is enabled already but I still get the same errors…
      I disabled it, signed out of HCP, signed in and enabled it again, but no luck…
      Any other suggestions?

      Author's profile photo Anton Levin
      Anton Levin

      I could suggest to re-check your Trust settings -> Trusted Identity Provider (are you using custom one?) and also your role assignments for IoT RDMS under Subscriptions -> iotrdms -> Roles

      Author's profile photo Former Member
      Former Member

      This is a very nice tutorial!
      Excellent Job

      Author's profile photo Jitendra Kumar
      Jitendra Kumar

      Hi Aaron ,

      I am new to IOT services. I searched how to proceed with initial steps. Mean while I got this blog but the given link for Getting Started with the IoT Services  and also other link  is not working. Can you please help me on this.

       

      Regards

      Jitendra

       

       

      Author's profile photo Anton Levin
      Anton Levin

      Please, see this blog [1] and official online documentation [2]

      [1] https://blogs.sap.com/2015/04/29/try-out-the-sap-hana-cloud-platform-internet-of-things-iot-services/

      [2] https://help.hana.ondemand.com/iot/frameset.htm