Simple As Sending IoT Sensor Values Through SigFox and Intel Edison, Using Python

by exasens in Circuits > Sensors

5265 Views, 42 Favorites, 0 Comments

Simple As Sending IoT Sensor Values Through SigFox and Intel Edison, Using Python

IMG_5593.jpg

I had the chance, at an Intel IoT Hackaton taking place at Usine.io in Paris, beside an Intel Edison Arduino board and a bunch of Grove sensors/actuators, to also get the new Akene board from Snootlab.

Thanks to the Intel IoT guys, Nicolas from SigFox and all the staff of BeMyApp for this Hackaton…

The Project...

I decided to build a small light sensor station, with the Intel Edison board, the Grove shield, the SigFox Akene Shield, and an I2C Grove TSL2561.

This station will upload, through the SigFox network about every 10 minutes, 3 different values (in lux) relating to that 10 minutes period: the arithmetic average light, the minimum and maximum light.

That will allow to know how the light fluctuate around its average value for this period of time, and therefore to get the big picture on how the sky could be cloudy (if some wind at least to push the clouds…).

I will use Python for that project.

a Friendly Development Environment

IMG_5587.jpg

I assume that the Intel Edison environment is ready for Python, and a password is set on the Edison in order to open SSH sessions and also SFTP to upload the python code.

I am using OS X, and will use CoolTerm for communication, and the excellent TextWrangler as code editor and code uploader (SFTP).

The Framework: Sensor.py

There is no difficulty to mention at that step.

Downloads

What You Get With Sensor.py

Screen Shot 2015-09-29 at 14.13.00.png

>python sensor.py

SigFox and the Akene Shield

IMG_5591.jpg

The Akene board is an experimentation Arduino shield from SnootLab with the TD1208 SoC (System on Chip) on it. The TD1208 is a SigFox-certified radio transceiver combined with an ARM Cortex M3, which implements the telecommunication modem stack for sending values to the SigFox operated telecommunication network, and also includes I2C capabilities for IoT sensors, beside its serial modem link.

SIgFox services rely on a LPWA (Low-Power Wide-Area) network currently deployed in Western Europe, San Francisco, as well as other countries or cities. The SigFox protocol is designed for small messages and its technology is focusing on energy efficiency for devices clients and large area coverage for each infrastructure base station.

The SigFox network allows each device to send up to 140 messages per day (i.e. every 10mn), each of them up to 12 available bytes i.e. 6 short integer values (the timestamp and the unique device ID are also transmitted in addition).

More informations: http://makers.sigfox.com

Let's Make Sure the Akene Shield and Its Modem Is Functional

IMG_5600.JPG

The Akene shield can be used as a modem, so we will first connect it to the Edison that way:

• Ground to Ground (Black wire)

• 3.3v to 3.3v (Red wire)

• serial Rx (pin 0) of Edison to Tx of Akene (pin D4) - Blue wire

• serial Tx (pin 1) of Edison to Rx of Akene (pin D5) - White wire

Sending Direct Commands Through a Terminal to the TD1208 of the Akene Shield

Screen Shot 2015-09-29 at 14.29.39.png

We can consider the TD1208 as a modem.

The PySerial package has to installed.

>python -m serial.tools.miniterm

We use miniterm (part of PySerial) - and specify the serial port: /dev/ttyMFD1 - to send direct commands, like:

• AT

which should reply OK (otherwise there is a problem)

• AT&V

which reply by the TD1208 identification

• AT$SS01234567

which send the 01234567 message to the SigFox network (the maximum hexadecimal digits is 24, i.e. 12 bytes)

• AT?

which return the list of commands available

To exit miniterm, on OS X with a french keyboard: CTRL 6

A Simple Python Command to Send a Message to the SigFox Network

This is a fast adaptation of a python command dedicated for another TD1208 board (RPISIGFOX from SNOC) and found on internet.

Just to mention that, for using serial with Intel Edison,

• it is prior necessary to initialise the port / pins which will be used, in our case /dev/ttyMFD1 (pins 0 and 1):

import libmraa

x=Uart(0)

• the port is automatically open when calling serial.Serial(......

You can use the command that way:

> python sendsigfox.py 01234567

which will send the message 01234567 to the SigFox network

Downloads

What You Get With Sendsigfox.py

Screen Shot 2015-09-29 at 14.43.37.png

>python sendsigfox.py 346723

The Full Program: Sensor2sigfox.py

No special difficulty there also, just to mention:

• Each data sent is a short integer of 2 bytes. the valueAvg, valueMin and valueMax are therefore 6 bytes, i.e. 12 hexadecimal chars string. As the setup from SigFox in the case I am using is done in order that data are resent to actoboard.com, and that actoboard.com currently accept data in LittleEndian byte order, each data is, prior to be sent, transformed accordingly...

• the Akene shield is fully plugged on top of the Grove shield, and in order to fit the wiring of the serial of Edison on pins 0 and 1 and the serial of Akene on pins D4 and D5, straps has been used (0 to D4: White strap) and (1 to D5: Yellow strap), see first picture... That mean a clean wiring but no possibility to use Pin 4 and 5 of the Edison...

Downloads

What You Get With Sensor2sigfox.py

Screen Shot 2015-09-29 at 14.19.13.png

>python sensor2sigfox.py