Quantcast
Channel: SCN : All Content - SAP HANA Cloud Platform Developer Center
Viewing all articles
Browse latest Browse all 3285

Basic IoT scenario using HCP - part 3 - Integration with HCP

$
0
0

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.

image045.png

 

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

 

image046.png

 

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

image047.png

 

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

image048.png

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.

image049.png

 

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.

 

image050.png

 

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.

image051.png

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

image052.png

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.

image053.png

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

image054.png

 

 

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.

image055.png

Use the particle device id available here:

image056.png

 

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

image057.png

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.

 

image058.png

 

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

image055.jpg

 




Viewing all articles
Browse latest Browse all 3285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>