Connect you SigFox sensor to BAG·Tower

maxime louvel

Last Update 9 месяцев назад

In this tutorial, we will explain how to create and connect a Sigfox sensor to BAG⋅Tower. You can use your own sensor type and follow this tutorial with us!
Requirements

Before you get started with this tutorial you need:

   - An active SigFox account and a sensor of your choice. You can buy connectivity for your sensor here.

   - An active BAG⋅Tower account. You can create it here. You have 14 free trial days ;)

The Enless PT100 temperature sensor
We will integrate an Enless PT100 temperature sensor. You can use the sensor of your choice. The configuration of the device and its frames decoding algorithm will depend on the sensor type and its provider. Just be sure that you have your sensor’s documentation.
Let’s go!
I. Creation/registration of a sensor type device (asset) in BAG⋅Tower

Follow these steps to create/register your sensor asset:

  Login to BAG⋅Tower

  Click on Add new asset

  1. Select Sigfox sensor from our equipment list.

  2. Fill the assets addition form (Name, period, etc..).

  3. For Asset ID, insert your sensor’s unique identifier provided by the manufacturer (usually, it can be found in your sensor’s case).

  5. Once you create the Asset, click on the Details button of the device. 

  Write down the values of the API Key and Company, as shown in the next figure (you will need these values later):

II. Sensor configuration at Sigfox

   1. Login to the Sigfox backend. If you have no registered your sensor yet, create your device type (in this example we call it Temperature) and register your sensor as a device of type Temperature. You can refer to the SigFox support page to get more information about how to create a device type and a device.

   2. Select the Temperature device type to configure it. In the left-side menu select Callbacks and create a new Callback.

   3. Configure the Callback as illustrated in the image below:

Be sure that Url pattern is set to https://api.bagtower.bag-era.fr/prod/logs/pool.

In the headers section, set the company-id, x-api-key, and sensor-id fields as follow:

   - company-id: This value corresponds to the Company value that you kept from phase 5 of sensor configuration in BAG⋅Tower.

   - x-api-key: This value corresponds to the API Key value that you kept from phase 5 of sensor configuration in BAG⋅Tower.

   - sensor-id: Keep the value {device}

Interpreting the data coming from your sensor

The raw data sent by your sensor will be sent to BAG⋅Tower as a frame containing hexadecimal values. Each byte(s) of data from the frame corresponds to a value: temperature, humidity, battery level, …

In order to be able to use this data in BAG⋅Tower (alerting, data visualization, ..), we need to decode these raw frames. To do so, we will use the decoder functionality available in BAG⋅Tower.

I. How to write a decoder?

In this example, we will use a decoder written in python. We will create a function called decode that gets the SigFox frame sent by the sensor as input parameter. The function must return a value of type dictionary compatible with the log data format of BAG⋅Tower.


Let us go back to the example ot the Enless T100 sensor which sends communication frames such as: 0321dc00. This frame contains 8 bytes of data. According to the documentation provided by the manufacturer, we can interpret/decode it as follows:


   0x03 (Two bytes): Ttransmitter type. 3 is for the T100.

   0x2 (1 byte) : Firmware version: 2

   0x1 (1 byte): Battery status. 1 means OK.

   0xdc00 (2 bytes - big-endian): Temperature value multiplied by 10 ((0*255 + 220)/10 = 22.0°C).


In our case, we are interested by the temperature and battery status values. We must then generate a dictionary formatted as:

Thus, the code for our python decode function can be:
II. Create the decoder in BAG⋅Tower


Now that we have written our decode function, we can integrate it in a BAG⋅Tower decoder. Follow these steps:


   1. Select the Assets list item from the main menu. If your SigFox sensor already transmitted a frame to BAG⋅Tower, it should be in the Uncoded (Orange) state. If it is not the case, you must wait for your sensor to communicate at least once.

   2. Then, click on Details, you will be proposed to create a decoder. Click on Create a decoder.

   3. On the decoder page, you can choose the frame to test. Then, paste the code of your decode function. Click on Validate decoder to verify your code. Once the code is validated, click on Save and attach, then click on Attach.

   4. From now on, the next time your sensor communicates, the frame will be decoded by the decoder, and the sensor will enter the Online state.

Congratulations!

Your sensor is now connected to BAG⋅Towerand and its data is correctly decoded and interpreted!

You can now add all the sensors you want and monitor your assets! Enjoy! :D

Was this article helpful?

0 out of 0 liked this article