Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member191815
Participant

This blog is part of a series which is related to a end-to-end IoT scenario. This is the full scenario used for the mini CodeJam that was organised at the SAP Inside Track 2016 Belgium #sitBRU.

Basic IoT scenario using HCP and Particles and UI5 - the explanation

Part 3 - Integration with HCP

Welcome to part 3. In this blog we will connect our particle to HANA Cloud Platform.

Before we can actually start creating the user interface, we have to configure the particle cloud to the HANA Cloud Platform. We already connected the particle to the particle cloud, and configured our device and messages etcetera in HCP, but now we have to connect the particle to HCP.


To communicate between the particle cloud and the HANA Cloud platform we have to use a webhook.

An integration component inside the particle cloud which can call webservices.

Steps


Go to the Particle Dashboard and perform the last steps. https://dashboard.particle.io

On the dashboard site, select the Integrations option.

In the integration tab, select the option to create a new integration.

In the next step, select the option of “Webhook”

In the top-right select the option of “Custom JSON”.

Replace the existing code with the following code.  Rename the “EVENT” to the name of the webhook you used with your Photon Code. This should be something like “WebHook_**”.
Be aware that you are not able to change the webhook after you’ve created it. You can only remove it and create a new one once again.



{
"event": "YOUR WEBHOOK NAME HERE",
"url":
"
https://iotmms{{HCP_USER}}trial.hanatrial.ondemand.com:443/com.sap.iotservices.mms/v1/api/http/data/{{HCP_DEVICEID}}",
"headers" : {
"Authorization": "Bearer {{HCP_BEARER}}",
"Content-Type" : "application/json;charset=utf-8"
},
"requestType" : "POST",
"deviceID": "",
"mydevices": true,
"json": {
"messageType": "{{HCP_MTYPE}}",
"messages": [
{
"Humidity": "{{HUM}}",
"Temperature": "{{TEMP}}",
"Light": "{{LIGHT}}"
}]
}
}

Your code should look like this. So by now your HCP setting should be finished. Your particle is pushing data to the particle cloud. And the webhook is created to push the event data from the particle to your HCP IoT service.

Select the Logs option to view the data traffic from the photons to the HCP IoT service. The log show the traffic of all the photons active in your account.

The dashboard should show you the following:

  • WebHook_**
  • hook-sent
  • hook-response


The hook-response contains the response from HCP. The data from the response should look like the picture below.

Return to your HCP Message Management Service Cockpit and select the tile “Display stored messages”.

If all the code and settings are correct, then there should be a table named “T_IOT_[your message type id]”. Select the table and have a look
at the values that are being stored from your Photon.

Congratulations, you have just implemented your first part of the Internet of Things scenario with SAP HANA Cloud Platform!

Now let’s try to push a message towards the Photon. We’ll be doing this just to prove that you’re able to toggle a led”on the board. Grab the “led_test.html”, which is attached to this blog. Open the led_test.html in notepad. Change the Device ID within the led_test.html file to the device ID of your photon. You should use the particle device ID, not the IoT services device ID.

Use the particle device id available here:

Save your html file and open it in a browser. Select the “Turn the LED on” radiobutton and hit the “Do it!”

Your Photon has a test-led onboard on port D7. While you toggle the Led on and Led off on your HTML page, the led should respond.
This was just to show you the ease of the Particle API. Time to move over to the UI and create the scenario.

Congratulations! Let's move over to the next blog and create a simple user interface.



2 Comments
Labels in this area