Intro: Simple As Sending IoT Sensor Values Through SigFox and Intel Edison, Using Python
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…
Step 1: 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.
Step 2: a Friendly Development Environment
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).
Step 3: The Framework: Sensor.py
There is no difficulty to mention at that step.
Step 4: What You Get With Sensor.py
Step 5: SigFox and the Akene Shield
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
Step 6: Let's Make Sure the Akene Shield and Its Modem Is Functional
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
Step 7: Sending Direct Commands Through a Terminal to the TD1208 of the Akene Shield
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:
which should reply OK (otherwise there is a problem)
which reply by the TD1208 identification
which send the 01234567 message to the SigFox network (the maximum hexadecimal digits is 24, i.e. 12 bytes)
which return the list of commands available
To exit miniterm, on OS X with a french keyboard: CTRL 6
Step 8: 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):
• 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
Step 9: What You Get With Sendsigfox.py
>python sendsigfox.py 346723
Step 10: 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...
Step 11: What You Get With Sensor2sigfox.py