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 :

<html>
  <head>
   <title>Demonstrateur SigFox</title>
  </head>
  <body>
  <?php
     $_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" );
       fclose($fl);
     }
  ?>
  </body>
</html>

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

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

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 …

 

18 thoughts on “Using Sigfox callback API to create your own application

  1. the light blue area is the one corresponding to latitude 46 and longitude 3. That’s why is a square, not a circle.

    the dark blue area is the intersection of the coverage map of several TAPs.

    do you have an idea how to know where are the TAPs located? is there any place published the location of the sigfox base stations?

  2. Hi,

    Thank you for explaining the Sigfox API.

    So the API Sigfox can provide the GPS coordinates of a device ?in your example the “lat” and “lng” represent the device GPS coordinates or the Sigfox base station coordinates ?

    { “id” : “86D9”, “data” :”01020304″, “from” :”009E”, “lat” :”46″, “lng” :”3″ }

    Best regards,

    • In a way it is the location of the base station, but as the precision have no decimal, it gives you a square of something like 60 km

  3. Very interesting all this.
    I’m planning to make some tests with UNB in the following months but not only with SigFox.
    There are major outsider around here but most are US ones and we have to wait that they jump over the ocean (they adapt their product to ITU region 1 ISM band).
    My questions are where did you buy your TD1208 (at telemetrieshop?) and, above all, where did you get you subscription to the SigFox network?
    Thanks for sharing all this.
    db
    A neighbour from Lyon.

    • You can request some sample to avnet-memec if you can hack it a little ; otherwise you can start with the dev-kit. Personally I did not. For your SigFox access, you can contact them. My point of view it is better to directly deal with sigfox if you have an industrial project instead of passing through telecom design cloud … but it is only my personal opinion.

      • Hello,
        Thank you for your reply.
        I didn’t really have an industrial project.
        It’s rather a personal project I’ll talk about in the web.
        Something like you did: a TD1208 modem on a breadboard or a perfboard and a bunch of sensors around it.

        My interest is:
        first, to understand the radio modulation used and, finally,
        second, to use the system to know about accesses to remote places I have here.
        Sigfox is not the only one I’m interested in.
        That’s only the first one widely available for everyone.
        Other projects may come next year (for a Region 1 compatibility) that don’t rely upon a static network of radio relays.
        Iotera is one of these.
        Very interesting but not very techy-oriented (not to say closed), more marketing and plug and play for pet owners and old-age people.
        If you’re interested we could group ourselves for an order.

        About SigFox, I try to find some mail address in their website but they mention to contact “your local SNO”.
        And my local SNO is … Sigfox itself.
        Should I contact them by phone rather than trying to find something like … ?
        db

      • The correct address is subscribe.
        But they don’t answer.
        American people are far more reactive as it seems.
        Pfff.
        db

  4. BTW and apart from my previous thread I’d to know if someone’s already tried to use the TD120x as a receiver (not the local relay but as a reception box from SigFox) and so establishing a duplex channel.
    I know it’s possible since the SigFox channel stays open a little while after sending but the receiver sensitivity (-126 dBm), contrary to the TAP ones (more or less -140 dBm), won’t allow for a so large distance from the TAP.
    db

    • Sigfox is ready but we are all waiting for the SDK update from Telecom Design, it is planned for the end of the month. As soon as it is available, I’ll post on it the result of my experimentations.

  5. Very interesting articles. Have you been able to find any documentation on the callback interface? I am trying to work out what delivery guarantees are on offer – for example if my callback service is offline when a message is sent, what will happen? Do I lose the message?

    • I assume you loose it but you are notified and you can see what message has been lost in the backend. The best way to manage this is to put 2 different callback in the backend going to two different servers, so you can be quite sure one of them will get it 😉
      Take a look to the api, you could have some other way. Actually I did not investigate a lot in this direction.

  6. Thank you for this article, it’s very helpful.
    I want to do a callback tests but I don’t know how can i configure my web server to do this ?
    How can i create easily my web app ? in wich directory you put your backend function ?
    Best regards

    • I’m sure Google will give you many exemple to get a PHP hello-world page. Once you have this working cut & past the code given in this post to you php page … it should work

      • I tried this but the function Get don’t contain the variables; should i had something to my url when i call it in my browser ?

  7. Really interesting…
    I just was wondering, since the devices don’t use any kind of security certificate, how to prevent fraudulent URLs GETs
    maybe checking the REMOTE_ADDR or REMOTE_HOST ?

    • In the backend you can specify a basic AUTH mechanism to limit a such spam. For sure, your callback URL should not be public. You can also based a filter on IP address but it is subject to change (recently the cloud hosting has changed, I assume the IP also). I assume sigfox will be able to help you more on this as it is a classical question they have from big company going to prod.

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.