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!
Showing results for 
Search instead for 
Did you mean: 
Former Member

This blog explains the setup of a Particle Photon (or Core) connected to HCP – IoT, as an extension to rui.nogueira blog about RaspberryPi on SAP HCP – IoT ( You can use Rui’s HCP IoT setup from the link above and move over to the work instruction below to start posting your sensor data from the particle to HCP IoT.

My experience with the RPI which Rui has been using was that you needed to do a lot to get the RPi going (Install OS, Dev Tools, connectivity setup, etc). And all of those things together got me seeking for an easier solution (from my point of view). At the end I had created a similar scenario, but with the Particle Core and Photon instead of using the RPi.

The fun thing about the Particle Core and Photon is that they are very small and they’ve got WiFi onboard. The connection setup to a wifi access point can be established by an app on your phone or tablet.

Spark rebranded to Particle
When I started exploring IoT with HCP I bought a Spark Core (kickstarter project). A couple of months ago Spark has been rebranded to Particle ( Particle has also launched a new device in the meantime, the Particle Photon. I’ll be using the Photon for this blog. And they've started another kickstarter project for 2G and 3G connectivity.

Particle Photon Kit
For this blog I’ve used the Particle Photon Kit which contains a couple of standard components.

  • The Photon
  • USB cable for power supply
  • Breadboard
  • Resistors
  • LED’s
  • Photo resistor

Particle Tools
The Particle Core and Photon are delivered with some “free” tools. “Free” because you’ve already payed them when you bought the device. One of the nice tools is the Web IDE. You write your code in the particle cloud and publish it to your device once you’re done.

Currently you have to put the webhook (file) onto the particle cloud with a CLI (commandline interface). Particle is working on an easier solution to create the webhooks.

More info on the webhooks :

More info on installing the CLI:

Let’s get started (Work Instruction)
So now we have all the ingredients to get us going.

  • HCP IoT from Rui’s blogs.
  • The Particle Photon Kit
  • The Particle tools

TaskScreenshot / Code
Setup the hardware

Connect the photon

The RGB LED between the two buttons should be breathing cyan. That way you can confirm that the device is connected to the internet.

When the LED is Flashing green, it’s looking for the internet connection.

Create a file (using notepad or some other texteditor) with the following code.

Change the "<<<YOUR HCP URL HERE >>>" with your HCP IoT url. For example: https://iotmmss***********

Change the "<<<YOUR HCP DEVICE TOKEN HERE >>>"  with the token you received while creating your device on HCP.

save the file and name it "HCP_webhook.json"


"event": "post_to_hcp",

"url": "<<<YOUR HCP URL HERE >>>",

"requestType": "POST",

"headers" : {

"Authorization": "Bearer <<<YOUR HCP DEVICE TOKEN HERE >>>",

    "Content-Type" : "application/json"


"json" : {





"mydevices" : true

Logon to the particle cloud through the CLI withthe command prompt or terminalcommand: particle login

Create the webhook with your json file

Command: particle webhook create hcp_webhook.json
Response from particle should look something like this.

Using settings from the file hcp_webhook.json

Sending webhook request  { uri: '',

  method: 'POST',


   { event: 'post_to_hcp',

     url: '*********',

     requestType: 'POST',


      { Authorization: 'Bearer *********,

        'Content-Type': 'application/json' },


      { mode: 'sync',

        messageType: '{{HCP_MTYPE}}',

        messages: [Object] },

     mydevices: true,

     deviceid: undefined },

  headers: { Authorization: 'Bearer ********* }


  Successfully created webhook with ID **********

login at the Particle Web IDE.

Go to:

Create a new application by clicking on the “Create new app” button and enter a name for your application.

Enter the following code to your application and replace the "<<< YOUR HCP MESSAGE TYPE ID HERE >>> " with the message type ID from HCP.

int photoresistor = A0; // This is where your photoresistor is plugged in. The other side goes to the "power" pin (below).

int power = A5; // This is the other end of your photoresistor. The other side is plugged into the "photoresistor" pin (above).

// The reason we have plugged one side into an analog pin instead of to "power" is because we want a very steady voltage to be sent to the photoresistor.

// That way, when we read the value from the other side of the photoresistor, we can accurately calculate a voltage drop.

char resultStr[250]; // Here we are declaring the String, which we will use later to store variables that are being used within the webhook towards HCP.

void setup() {

pinMode(photoresistor,INPUT);  // Our photoresistor pin is input (reading the photoresistor)

pinMode(power,OUTPUT); // The pin powering the photoresistor is output (sending out consistent power)

digitalWrite(power,HIGH); // Write the power of the photoresistor to be the maximum possible, so that we can use this for power.


void loop() {

    float tempLight =  analogRead(photoresistor); // This variable will be used to store the value of the photoresistor.

    char *hcp_messageType = "<<< YOUR HCP MESSAGE TYPE ID HERE >>>"; //This variable contains the HCP message type ID

    //Next we will fill the resultStr with all the variable data thats needed for the webhook towards HCP and use the publish command to send the data towards HCP.

sprintf(resultStr, "{\"HCP_MTYPE\": \"%s\", \"HCP_SENSOR\": \"Light\", \"HCP_VAL\": %f}", hcp_messageType, tempLight);

Spark.publish("post_to_hcp", resultStr, 60, PRIVATE);

memset(resultStr, 0, 255);

    // delay to send the measurements every 30 seconds.


Verify your code.
When your code is successfully verified, you’ll get the following response at the bottom of the screen.
Publish your code to your Photon as soon as it is successfully verified. Use the Flash button on the top left of the web ide.
During the flashing the RGB LED on your photon will flash magenta. As soon as it is ready, it will reboot the device and connect the wifi again.

As soon as your code is flashed and the Photon is connected again, your code is active and being executed.

Go to the Particle Dashboard to verify that your Photon is pushing the sensor data to HCP:

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

When all the code and settings are correct, 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 you Photon.


As visible in the blogs of craig.cmehiland also by gregor.wolf there are quite some blogs on the topic of IoT solutions connecting to HCP. Combining the blogs gets your IoT scenario up and running in no-time. The more sensors, the more interresting it gets. Within this example I used the photo resistor as it was included in the Kit. In the next blog I'll describe how to add the DHT11, basic temperature and humidity sensor, on the Particle while using the available libraries from the Web IDE. Pretty straight forward, but even easier once you have an example :smile:

Labels in this area