Skip to Content

Last week I visited Berlin. I went by car, and decided it would be great to finally test SensorPhone app on iPhone. Patrick Colucci claimed his app had been The Easiest Way to Stream your iPhone’s Sensor Data to HANA Cloud Platform. And just that same morning he made an importnat update to the app allowing to save parameters within the SensorPhone. So, I had no excuse not to try it out.

The SensorPhone app reads some iPhone sensors and posts their valuesto SAP HANA Cloud Platform using its IoT Service. If you are not familiar with SAP HCP’s IoT, then have a look at recently updated tutorials:

Unfortunately only upon arrival to a hotel in Berlin I realized that IoT Service in my HCP Trial account was not configured to save collected data to my own SAP HANA instance, and therefore I did not have access to run SQL queries directly on the table.

The good thing though, is that Message Management Service (MMS) in SAP HCP IoT provides an OData V2-compatible API that can be used to browse all created tables as well as to consume messages stored by MMS. The OData service document can be retrieved through the endpoint:

https://iotmms[account]/com.sap.iotservices.mms/v1/api/http/app.svc

Eg. in my i076835trial account in SAP HCP the message type id for data collected from iPhone via SensorPhone app is A7B01790F3E80BC544A3, and therefore can be retrieved from the endpoint

https://iotmmsi076835trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc/T_IOT_A7B01790F3E80BC544A3

Important thing to note is that this endpoint returns only 100 records by default. I wanted to retrieve all 426 records collected during the trip from my home town of Wrocław to Berlin, and therefore needed to use a trick of adding OData’s $top query parametr to the URL, like this:

https://iotmmsi076835trial.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc/T_IOT_A7B01790F3E80BC544A3?$top=0&$format=json

Having all records in JSON notation, it was pretty straightforward then to convert values to CSV, select only columns with GPS data and then use GPS Visualizer to convert data to GPX format and to visualize the way I drove:

OpenStreetMap_WROBER.png

and elevations on the way:

/wp-content/uploads/2016/06/20160605135624_36107_profile_973174.png

In the SensorPhone application I set the opion to post new data every 10 seconds. You will immediately spot straight lines at both charts above. It obviously happened when I crossed the border between Poland and Germany and my phone switched to roaming. The message at the bottom of the error displayed at that time on the phone says it all.

IMG_9225.PNG

The data roaming was not active by default in my phone, so only a few data points were collected during times when I turned data roaming on and posted current sensors values. I did the similar thing with data collected on my way back to Wrocław and you may see that I turned data roaming a bit more often and that I took a different road that time:

OpenStreetMap_BERWRO.png

But on the way back I configured as well MMS service to persist the data in my SAP HANA instance, so that I could do some calculations and analysis using SQL. But first let me use OData with SAP Lumira.

To report this post you need to login first.

1 Comment

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

Leave a Reply