Skip to Content

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.

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.

/wp-content/uploads/2016/06/image045_971704.png

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

/wp-content/uploads/2016/06/image046_971780.png

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

/wp-content/uploads/2016/06/image047_971781.png

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

/wp-content/uploads/2016/06/image048_971782.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.

/wp-content/uploads/2016/06/image049_971783.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.

/wp-content/uploads/2016/06/image050_971784.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.

/wp-content/uploads/2016/06/image051_971785.png

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

/wp-content/uploads/2016/06/image052_971807.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.

/wp-content/uploads/2016/06/image053_971808.png

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

/wp-content/uploads/2016/06/image054_971809.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.

/wp-content/uploads/2016/06/image055_971838.png

Use the particle device id available here:

/wp-content/uploads/2016/06/image056_971839.png

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

/wp-content/uploads/2016/06/image057_971843.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.

/wp-content/uploads/2016/06/image058_971844.png

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

/wp-content/uploads/2016/06/image055_971812.jpg



To report this post you need to login first.

2 Comments

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

  1. Fadel Antonio Cazor Casis

    Hi Wim,

    I’m getting an error from my integration log because the humidity value is nan, maybe a hardware error or a mistake i  my configuration in Hana message?

    “LIGHT”: “59.000000”, “TEMP”: “0.000000”, “HUM”: “nan”

    ook-response/WebHook_03/0{“msg”:”Parse error. Expected [Humidity] of type [FLOAT] but received [\”nan\”]”}June 19th at 6:55:27 pmparticle-internal

    {“data”:”{\”msg\”:\”Parse error. Expected [Humidity] of type [FLOAT] but received [\\\”nan\\\”]\”}”,”ttl”:”60″,”published_at”:”2016-06-19T21:55:27.621Z”,”coreid”:”particle-internal”,”name”:”hook-response/WebHook_03/0″}

    (0) 
    1. W. Snoep Post author

      hi Fadel,

      Great you came this far. Sorry for the delayed response because of holidays.

      Regarding your challenge, there could be various reasons behind the ‘nan’ value. For example a broken sensor, or wrong setup of the breadboard with the connected humidity sensor. Did you explicitly specifify the library as shown in blog 1. You need to include “ADAFRUIT_DHT”.

      Wim

      (0) 

Leave a Reply