Use the SigFox API to display its data

in a recent article, I presented the map breakout SigFox of SNOC . The recovery of data was done in callback . Here I will explain how to recover your data with the API SigFox.

click to get information on the levels.

attention VPS temporary

the server VPS ( V irtual P rivate S Server ) framboise314 hosted by web4all is used for different experiments. It is possible that at some future time the pages cited in this article are no longer accessible.

reminder of the callback operation

click to enlarge.

when using the callback, the Raspberry Pi sends a message to the card SigFox. The card passes the 12 maxi bytes) by SigFox network radio. Upon receipt of the message Server SigFox instantly transfers each data packet to a server designated by the user. He made a call to a web page and in him passing this information in GET or POST…

this is what is called a “callback” because SigFox server called “in return” the VPS server what it designated him here. If you are interrested by this technique, see you at previous article .

works with the API SigFox

click to enlarge.

the operation here is a little different as we shall see:

  1. the Raspberry Pi sends the data to the map breakout SigFox passed on by radio to the nearest SigFox antenna. Different messages are sent according to the programming of the user ( maxi 140 messages per day or about one every 10 minutes ).  They are stored on the server SigFox and can be consulted online on this server:

  2. at one time, a user wants to view the data sent by the Raspberry Pi in my browser. He logs on to the web page of the server VPS framboise314 ( ). This PHP web page contains a call to the API SigFox.

  3. the call for SigFox server is sent with the identifiers ( login/password ) of the user.

  4. Sigfox server built a block json ( J avascript O bject N rotation ) containing the messages received by the server and stored at SigFox. The message is returned to the framboise314 VPS.

  5. the web page testapi.php receives the block of data in the format json . The PHP program decodes the information contained in the data block, and displays them in a table that is returned to the browser of the user.

now that we have seen the principle of use of the API SigFox, I propose to detail its implementation.

creating an account API

to use the API (Application Programming Interface) SigFox, you need an account. The first operation is to get the credentials for this API.

click to enlarge.

on your page SigFox, make you tab use . Your user SigFox appears. Click at the right end of the line on the Group (here François MOCQ EVK ).

you arrive on your group page that includes information about your subscription. In the menu in the left column of the page, click on API ACCESS .

you get access to the API page. The first time this page is empty. Click the top right button New .

give a name to access API (I chose… feamboise314 🙂 the timezone must be correct move in the right side of the windows Custom roles the roles you want to assign.) Then click on the button Ok under the window.

click to enlarge.

your access to the API is created. Your login details are displayed. Save them preciously .

notice at the end of the first line a link to API documentation . It doesn’t hurt to go wander a little bit 😉

now that we have the keys to discuss with SigFox server, I suggest you look at how we’re going to go to him.

a first test

now that we have the credentials we will try to connect on SigFox website at this address:

you will replace VOTRE_MODULE by your own SigFox module number.

when you get to the page a window opens and you must enter the login/password to extension that you got before.

in return you get messages from your module SigFox statements.

it is in this format json you will receive information from the SigFox site. Fortunately, we have the tools in PHP to process these information 🙂

the page to display

the specification

I want to display the information contained in messages SigFox on a web page. It will contain a logo to framboise314 (bin 😉 Yes) then a table will list the various messages that were stored on the server SigFox.

I must say that I’m not a web developer, and I developed the web page with my knowledge in PHP and CSS. (Certainly), we can do better. You have the starting point, if you want to store the information in a database, draw pretty curves… Free to you! For my part I go 😀

the web page PHP

click to download the program.

the program uses CURL to access the SigFox server. Then the block json recovered is ‘own’ and a loop scans each message and displays it in a table.

the editor of WordPress is a Scamp that removes surreptitiously spaces used for indentation or replaces signs like sneaking > by >
after having struggled a moment to try to tame, I chose to offer the program as an image. Just click on the image to download the program .

François, a little fix your tie…

so that the received page is a bit prettier I added a pinch of CSS. You will see the link that loads style.css at the top of the PHP page. Put this CSS file in the same folder on your PHP page.

 table margin: auto;
border - width:1px;
border - style: solid;
border - color:black;
border - collapse:collapse td border - width:1px;
border - style: solid;
border - color: Blue;
padding: 5px;
vertical - align:middle;
} th color: grey;
background-color: bisque;
align: center;
} tr:nth - child (odd) / * all odd rows: 1st, 3rd, 5th, etc.* / background-color: white;

TR:nth - child (even) / * all the even lines: the 2nd, 4th, 6th, etc.* / background-color: linen;

this CSS file a little outdoor table, centering and adding a bit of color.

sending a message SigFox

for testing I sent two messages from putty on the Raspberry Pi. We find these two messages at the top of the table (below).

the web page displaying messages

click to enlarge.

a better quality of link

the more observant of you will have remarked that the link quality is average, except on the two lines at the top (the most recent).

the map tests were made on a desktop, air laid flat, far from a window.

for the latest tests I simply cleared the antenna of the hardware present on the desktop (a sacred 😉 Bazaar)

the easiest was to fix it with a piece of tape on the glass of a window. This provides a better radiation of radio waves and a serious improvement of SNR ( signal-to-noise ratio = signal to noise ratio).

you can see that the signal to noise ratio has increased more than 20 dB , (with a ladle), which is an improvement of… 100 times!

after the use of the callback in the first article, this suite will allow you to access your data in a different way, using the API SigFox.

the use that is made here is basic, with a display in a table. You can play to make pretty graphs, display gauges etc… Feel free to put a link in the comments to admire your accomplishments (and perhaps give ideas to others?).

Using Sigfox callback API to create your own application

No comments:

Powered by Blogger.