Close

Software

A project log for Frank'n'Sense

Low-cost IoT device with a range of sensors for Building Environmental Monitoring.

David OgilvyDavid Ogilvy 07/07/2015 at 11:350 Comments

The firmware for the Frank'n'Sense will be natively written for running on the ESP8266 cpu core. There'll be no extra microcontroller to do any of the work to keep both energy use and cost down.

The ESP8266 has more than enough GPIO to handle a few i2c devices. There's no hardware i2c module, so everything will be software (bit-bang) i2c controlled. This means I can have multiple i2c channels if necessary due to conflicting addresses. If I really get stuck, I'll add a Microchip MCP23S08 or MCP23S17 to get some more GPIO.

Most of the datasheets for sensors are quite detailed, and the communications to collect data from them quite simple. Writing code for each should be easy - especially when there are plenty of open-source drivers available for arduino, raspberry pi, etc to get help from (Thanks Sparkfun/Adafruit!).

For collecting data, I am leaning very heavily towards the MQTT protocol. It's well suited to command and control of large networks of devices. Commands can be sent individually to a device, or sent globally to all. Fluentd is a data collector for Hadoop, and has an MQTT data collector plugin available.

Most digital sensors can be configured to collect a sample and then sleep. The idea will be to have the rather power hungry ESP8266 send a request to the sensors to collect a sample, grab the data (usually available within milliseconds), upload it via MQTT, collect any waiting commands from the MQTT server, put the sensors to sleep, then put the ESP8266 to low-power sleep more for "X" minutes until the next data collection cycle begins.

The major benefit of MQTT here, is messages or commands sent to a device are queued on the MQTT server until the sensor wakes up to collect them. Perfect!

Discussions