- Overview
- Prerequisites
- SigFox Integration Configuration
- SigFox Configuration
- Advanced usage: Downlink
- Video tutorial
- Next steps
Overview
Sigfox Integration allows to stream data from Sigfox Backend to ThingsBoard and converts binary device payloads to the ThingsBoard format.
Please review the integration diagram to learn more.
Prerequisites
In this tutorial, we will use:
-
ThingsBoard Professional Edition instance — eu.thingsboard.cloud;
- a Sigfox account;
- a device registered with Sigfox.
Let’s assume that we have a device Sigfox-2216792. Our sensor device publishes “temperature”, “humidity”, “co2” and “co2Baseline” readings.
SigFox Integration Configuration
Create Uplink Converter
You can сreate an uplink converter in the Data converters page or directly in the integration. Uplink converter is necessary in order to convert the incoming data from the device into the required format for displaying them in ThingsBoard.
Go to the Integration center -> Data converters page and click “plus” button to create a new converter. Name it “SigFox Uplink Converter” and select type Uplink. To view the events, enable debug mode. In the function decoder field, specify a script to parse and transform data.
Let’s review sample uplink message from SigFox device:
1
2
3
4
5
6
{
"device": "BF1327",
"time": "1661868952",
"data": "2502af2102462a",
"seqNumber": "3737"
}
- the “device” is responsible for the name of the device;
- the “data” is a telemetry concatenation by two characters, where value “02af” - temperature, “21” - humidity*, “0246” - co2, “2a” - co2Baseline.
One can use either TBEL (ThingsBoard expression language) or JavaScript to develop user defined functions. We recommend utilizing TBEL as it’s execution in ThingsBoard is much more efficient compared to JS.
You can use the following code, copy it to the decoder function section:
|
You can use the following code, copy it to the decoder function section:
|
SigFox Integration Setup
- Go to the Integrations center -> Integrations page and click “plus” icon to add a new integration. Name it “SigFox Integration”, select type SigFox;
-
Add recently created SigFox Uplink Converter;
-
For now, leave the “Downlink data converter” field empty;
- Specify your URL;
- Copy HTTP endpoint URL - we will use it later;
- If necessary, you can specify additional parameters, without which the data will not be included in the integration. To do this, check the Enable security checkbox and click “Add” entity button. Specify an arbitrary header and value;
- Click Add to create an integration.
SigFox Configuration
Now we need to set up a Sigfox account so that data from our device is sent to the ThingsBoard platform.
Go to your Sigfox account -> Device type -> enter your device type edit mode. In my case, this is “thermostats”.
In “Downlink data” section specify callback downlink mode.
Then go to the Callbacks tab.
A callback is a custom http request containing your device data, along with other variables, sent to a given platform when the aforesaid device message is received by Sigfox cloud.
Create a callback to connect the Sigfox cloud to your ThingsBoard platform. In the upper right corner, click on the “New” button, and select “Custom callback”.
Specify custom payload config, header filter, and paste copied HTTP endpoint URL in URL pattern line. Add a message body whose structure matches the message from your device. Click “Ok” to create callback.
Payload body:
1
2
3
4
5
6
{
"device": "{device}",
"time": "{time}",
"data":"{data}",
"seqNumber": "{seqNumber}"
}
Make the downlink callback active. Click on the “Downlink” icon.
After this, the device is ready to send data to Thingsboard. Send an uplink message from the device.
After you sent the uplink message a new device was created in Thingsboard. You should receive a notification about it. To view notification click on the “bell” icon in the upper right corner of the screen. The notification will contain link to the Sigfox-2216792 device provisioned by the integration (your device name may differ from the one shown in this example). Learn more about notifications and how to configure them here.
Navigate to this device.
Here you will see information about the new device. Navigate to the Latest telemetry tab to see the keys and their values.
Go to the “Attributes” tab. There you see the attributes of the device and its values.
Received data can also be viewed in the Uplink converter. In the “In” and “Out” blocks of the Events tab:
Advanced usage: Downlink
Create another converter with the name “SigFox Downlink Converter” and select type Downlink. To see events - enable Debug mode.
You can use our example of downlink converter, or write your own according to your configuration:
|
You can use our example of downlink converter, or write your own according to your configuration:
|
Now you have to add downlink converter to the integration.
When integration is configured, we need to go to the Rule chains page, choose Root Rule Chain and here create integration downlink node. Enter some name here, select the SigFox Integration you created earlier, and click Add.
After these steps, we need to tap on a right grey circle of the message type switch node and drag this circle to left side of the integration downlink node. Here choose ‘Attribute Update’ and ‘Post attributes’, tap “Add” and save Root Rule Chain.
Test Downlink
To test downlink, create a shared attribute on your device and send some Uplink message on this device.
Go to your Sigfox account -> choose your device -> Messages tab. And you will see Downlink message
Go to the Statistics tab. You will see a downlink message on the chart.
Video tutorial
See video tutorial below for step-by-step instruction how to setup SigFox Integration.
Next steps
-
Getting started guides - These guides provide quick overview of main ThingsBoard features. Designed to be completed in 15-30 minutes.
-
Data visualization - These guides contain instructions on how to configure complex ThingsBoard dashboards.
-
Data processing & actions - Learn how to use ThingsBoard Rule Engine.
-
IoT Data analytics - Learn how to use rule engine to perform basic analytics tasks.
-
Hardware samples - Learn how to connect various hardware platforms to ThingsBoard.
-
Advanced features - Learn about advanced ThingsBoard features.