In the previous blog, I described the set of activities I performed to configure a Raspberry PI which collects data from sensors and transmits them to an application hosted on the HANA Cloud Platform. The application on HCP shows gauges which change according to the temperature and light exposure relayed from the sensor devices. In the prototype, I had used sensors from a sensorTag along with a rail wagon to demonstrate this.
Internet of Things (IoT) services in HCP enables us to securely onboard devices and configure them remotely. It also allows us to send and receive messages from the configured devices. It supports HTTP and WebSocket protocols for communication and stores the sensor data in HCP Persistence layer. In this blog, I am going to outline the steps I performed to enable the IoT service and configure it to onboard the Raspberry PI device.
I followed the article “Try out the SAP HANA Cloud Platform Internet of Things (IoT) services” by Michael Ameling which walks through the steps to enable the IoT service and deployment of Message Management Service.
Once you are in the cockpit, use the top three tiles to add a device type, message type and a device.
Device type is a grouping of devices which share the same configuration. I created a new device type called “Raspberry PI”
After creating a Device type, I was able to see its ID along with the Device Registration Token which can be used later.
I added a new message type and assigned the previously created Device type as follows
I provided the below fields as part of the message type
After saving the message type, the system provides a message ID which I will need to use later.
Finally, I created a new Device and assigned the message type created in the previous step.
On saving the Device, system will provide you an OAuth token. Its important to make a note of it along with the Device ID. I will need both of them in order to make a client communicate with the IoT Service.
Now we should be ready to test the test the device using a sample client which is provided. Click on the Message Management Service highlighted below
There are two sample clients provided – one for HTTP and the other to test via Web Sockets. I used the HTTP Test client
Provide the Device ID, Message type ID and a valid message payload as shown below and click on Post.
This should give you a successful message with code “200” as shown below.
Navigate back the MMS cockpit and click on “Display Stored Message”.
There will be a table created for your device and listed among other tables. Once you locate it, open it to view the contents of the table. You should be able to view your test messages.
My python script makes a HTTP POST calls to the IoT service. Hence, every 5 seconds I get data posted to the above table. It’s important to note that you will need the OAuth token (generated earlier) when trying to make a HTTP Post for a particular device.