Using Sigfox callback API to create your own application

In different previous post, I explained what is SigFox technology (a radio-communication system made for Internet Of Things, allowing a sensor to communicate with servers on Internet at an affordable price) and how to send data from a sensor to the SigFox backend.

This new post is explaining how to configure this back-end to get the sensor data loaded in your system and create your own application.

To understand how it works, you may know that each time a sensor is sending a message over the SigFox network this one is recorded in the sigfox backend. You can configure a call back in this backend to indicate what action you want to perform with this message.

Once you have you own access to the backend, you have to go on “Device Type” tab and select one of the device type by its name or create a new one. In fact, a callback is a setting attached to a device type. And a device type is a group of devices ; generally attached to the same function.

Then, you click on “Edit” button to get access to the “device type” settings. Here you can specify an url dynamically called, en email or a batch url (called once a second) This last option is particularly interesting if you have a large scale sensor network.

You also have 3 channels : Data to get the user specific messages, Service to operational information (preprogrammed messages), Error to get the network events like a communication loss. You can specify multiple call back. Basically it looks like this :

How to setup a call back in SigFox Backend
How to setup a call back in SigFox Backend

So you can select precisely all the fields you want to get and rename them at your convenience. Based on the callback information you can get the location of the device as the station (TAP) is identified and you are getting a latitude and longitude. Unfortunately the information is rounded to the nearest integer so the location is really approximative.

As part of the fields you have some about quality of reception : RSSI is the reception level signal is (SNR – signal to noise), avgSignal is an average SNR. It seams that when received by multiple base-station, the value correspond to the first message received ; not especially the best. It is possible to request to receive one callback per message received by clicking on duplicate checkbox. When this option is used you can also get a field “duplicate” indicating if it is a detailed (per base-station) message.

Once the callback function is configured, you have to write your backend function. The example above is simply adding the received data to a json file :

   <title>Demonstrateur SigFox</title>
     $_id = $_GET["id"];
     $_time = $_GET["time"];
     $_signal = $_GET["signal"];
     $_station = $_GET["station"];
     $_lat = $_GET["lat"];
     $_lng = $_GET["lng"];
     $_rssi = $_GET["rssi"];
     $_data = $_GET["data"];
     $_avgSignal = $_GET["avgSignal"];

     if ( $fl = fopen('sigfoxData.json','a')) {
       fwrite($fl,"\"data\": { \"id\" : \"". $_id . "\", "
                             ."\"data\" :\"" . $_data . "\", "
                             ."\"from\" :\"" . $_station . "\", "
                             ."\"lat\" :\"" . $_lat . "\", "
                             ."\"lng\" :\"" . $_lng . "\" }\n" );

Then you can send data connecting to the device modem as describe in this post.

AT$SS=01 02 03 04
AT$SS=02 03 04 05

The result can be checked from the sigfox backend

Data reception example in the sigfox back-end
Data reception example in the sigfox back-end

You can notice that callback status is OK for these two messages indicating it has been done and no error has been returned.

Now we can check the json file and get the result

"data": { "id" : "86D9", "data" :"01020304", "from" :"009E", "lat" :"46", "lng" :"3" }
"data": { "id" : "86D9", "data" :"02030405", "from" :"009E", "lat" :"46", "lng" :"3" }

This is corresponding to what have been sent… good news ! Now we just have to build a real application processing these data and make fun !

As a complement of this example about the device location, the back-end system offer some other functions with an interesting device map :

sigfox device location map
sigfox device location map


I assume that the light blue area is the one covered by the antenna, it is interesting to see how large it is (even if a circle would have made more sense to me) and the dark blue area is a refined area, I assume in relation with the signal power and eventually multiple reception source.

In fact, for some of the sent messages, multiple base station are receiving them and I assume some triangulations are possible.

What I do not know is how it looks like when the device is mobile… I may do some tests… sometime.

As seen in my previous post, the main important point with this technology is the easy way to use it !

My next topic will be about power consumption of the device before starting my custom development …


This entry was posted in IoT, Sigfox and tagged , , . Bookmark the permalink.

20 Responses to Using Sigfox callback API to create your own application

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.