Sigfox IoT Dashboard with thethings.iO IoT platform

In today’s post we are going to show you how to create (step by step) a Sigfox IoT Dashboard with thethings.iO IoT platform.

Sigfox thethings.iO

In this example we’ll use the same board an peripherals as the previous post (Connecting the SmartEverything to thethings.iO). Please follow the first two steps in order to flash the code in the SmartEverything. The Smart Everything board is a 32-bit ARM Cortex-M0+ that supports Arduino and brings a Sigfox module (Telit LE51-868 S), a GPS module with embedded antenna (Telit Jupiter SE868-A), a Proximity sensor (ST VL6180X), Humidity and temperature sensor (ST HTS221), accelerator sensor with Axis sensors (ST LSM9DS1), and a Pressure Sensor (ST LPS25H). In addition to this, the SmartEverything also has NFC and Bluetooth Low Energy modules.

Let’s start the tutorial

Now, make sure you have an account at thethings.iO. If not, register quickly by clicking here.

Once you have done this, you can start with this Step by Step.

In order to receive the data from Sigfox, you’ll need to redirect all the messages using a callback from our Sigfox profile. You’ll need to configure our thethings.io profile for this:

  1. Navigate to Things (2nd row at the left).
  2. Create a new product: Insert your product name. Then choose a name for each resource you’re going to use. Finally choose Sigfox inside Format.thethings-io-newproduct
  3. Press on the product you have created. Copy the url in the Subscription URL.

thehtings-io-sigfox-details

Now lets move to the Sigfox backend:

  1. Go to Device:
  2. Navigate to Callbacks.
  3. Click new
  4. sigfox-callbacks-list-thethingsChoose the following configuration:
      1. Type: DATA UP-LINK.
      2. Channel: URL.
      3. Url pattern: Paste your previous subscription URL from thethings.iO.
      4. Use HTTP method: POST and click Ok.sigfox-callback-thethings

Parsing data from Sigfox

Now go to thethings.iO IoT platform and you will need to specify how to parse the data that Sigfox forwards to thethings.iO, in order to display the correct values:

  1. Go to Cloud Code
  2. Navigate to Functions and Edit the parser with the name that you gave to the product before.
  3. Parse your resources by splitting the string that Sigfox sends (An hexadecimal number containing all the sensor values, one after the other). In the preview params, copy the sigfox payload you send from Sigfox and change “quote” to “data” to prove your function.
function parseF(s) { // Use this function in order to patch the GPS data stored as floats in the code
 var a = ((s & 0x7FFFFF | 0x800000) * 1.0 / Math.pow(2,23) * Math.pow(2, ((s>>23 & 0xFF) - 127)));
 if (s >= 2147483647) { //If >= (it's a negative latitude or longitude)
 a =-a;
 }
 return a;
}

function main(params, callback){
 var result = [
 {
 //Replace with your own payload parse 
 "key": "temperature",
 "value": parseF(parseInt(params.data.substring(8,16),16))
 },
 {
 "key": "humidity",
 "value": parseF(parseInt(params.data.substring(0,8),16))
 }
 ]
 callback(null, result) 
}

Creating the dashboard Widgets

It’s time to create an IoT Dashboard with thethings.iO to show all the values of your sensors!

    1. Click on the botom right cross (+)thethings-io-widget-create
    2. Introduce a name for the widget.
    3. Select Thing Resource.
    4. Select Sigfox.
    5. Select your thing Token.
    6. Select the resource that you want to show.
    7. Select how you want to show your resource (Lines, bars, log…) and choose realtime (if you want to see the values updating in realtime). Play with the value inside Custom Parameters.

Repeat this process until you finish your awesome IoT Dashboard!

thethings-io-new-sigfox-dashboard