Setup for MakerFaire 2015

At the Tinaja Labs booth, called The Sense of Things, I had a full IoT system (Internet of Things) in place. Front to back I started with wireless sensors, to a Raspberry Pi that collected sensor data, to a Beaglebone Black running Node-Red (as a signal routing application), to newly introduced inexpensive wi-fi modules (the ESP8266), and finally to old-school X-10 light switches.

I’ve always described my setup as a home automation system that is built on a wireless sensor network.  I first heard about the concept of the Internet of Things (IoT) in 2009.  Home automation and wireless sensor networks are now included in the overarching concept of IoT and includes M2M (machine to machine) and industrial applications like manufacturing systems.  IoT describes all the things that can be connected through internet technologies with sensors on one end, actuators on the other end and coordination software in the middle.

Overview of the IoT system

Download the OS image here. Read instructions here and learn about how to burn an OS image to a MicroSD card using WinDiskImager32.  More info about setting up a MicroSD card here.

The system in place includes examples of typical components of an IoT system.  On one end I had wireless sensors (based on XBee Series 1 radios), in the middle I had connecting and coordination system software (Node-Red), and on the other end I had charting and analysis (Graphite/Grafana) and actuation (wi-fi based LED control).  Pretty much, that covers the basic areas of home automation.

Code for this setup is on Github at:  TinajaLabs/makerfaire2015

Sensor PCB with XBee

the MS-1 PCB

My MS-1; a Multi-Sensor PCB w XBee.

I designed this PCB a few years ago and it still works great.  I deployed these in every room of our home.  It has a 3.3V regulator, an XBee Radio, a temperature sensor (tmp36), a light sensor (CdS cell), and headers for 2 more sensors (mostly I’ve hooked up a hall effect sensor and an FSR, force sensitive sensor).  I also included a rail to rail buffer chip to create a clean separation between the sensors.  In hind-sight I probably didn’t need that.

The sensor board schematic and the PCB layout:

MS-1 PCB Layout

MS-1 Schematic

Using XCTU, a configuration tool (available for Windows, Mac, or Linux) from Digi, I configured the XBee Series 1 radio end points like this:

ID=1111 (same for all radios in your system)
CH=0C (same for all radios in your system)

Wi-fi Capacitive Touch Button

Download the OS image here. Read instructions here and learn about how to burn an OS image to a MicroSD card using WinDiskImager32.  More info about setting up a MicroSD card here.

This is a new sensor setup, breadboarded, that uses a capacitive touch switch (Standalone Toggle Capacitive Touch Sensor Breakout – AT42QT1012) and an ESP8266 wi-fi PCB.  The capacitive switch responds to touch and toggles a high/low voltage  on the GPIO01 pin of the ESP8266.  The ESP8266 is programmed to send the switch’s state over wi-fi to a web service on the Node-Red software.  More about that in the Node-Red section below.
django-tagging 0.3.1 or greater


Here’s the Fritzing breadboard of the capacitive switch hooked up to an ESP8266. Find the code I used code on Github.

The Gateway “Stack”

The picture below shows what I call my gateway rack (constructed from a CD caddy and CD sized pieces of colored Plexiglas from Tap Plastics).  All of the functionality could probably be included on any one of these devices, but for the sake of experimentation and separation of functions, I set up 3 micro-computers:

  1. Raspberry Pi B+ (on red Plexiglass):  Has a GPIO board from Ciseco called the Slice of Pi that supports an xbee coordinator configured radio.  It is running  Raspbian OS and a python script that collects the serial data being collected by the XBee radio.  The metric data is collected, bundled up and formatted, and sent to a Node-Red TCP Socket module.  It also has an application named mochad-0.1.16 that provides X-10 device connectivity.
  2. Beaglebone Black (on blue Plexiglass): Running Debian Wheezy and installed with Node-Red (requires Node.js; should already be installed on Wheezy)
  3. Odroid C-1 (on orange Plexiglas): Running Ubuntu 14.04.2 LTS with Graphite and Grafana installed to provide a data store and data charting for all the sensor data.


When loading up an OS on these gateway devices, the basic process is to load an image file onto a MicroSD card that stands in as the computer’s bootable hard disk.  I prefer using Win32 Disk Imager and I found ApplePi-Baker to be useful on Mac OS X.  There’s a great overview of different methods here:

Sensor Gateway

Download the OS image here. Read instructions here and learn about how to burn an OS image to a MicroSD card using WinDiskImager32.  More info about setting up a MicroSD card here.

The Raspberry Pi sensor gateway has a GPIO PCB from Ciseco, the Slice of Pi, that supports an xbee radio.  This XBee radio is configured to be the coordinator radio for all my XBee Sensor PCBs (described above).  There is a python script,, that reads the data being received from the XBee radio via a serial port.  Sample code on Github.

Using a software configuration tool from Digi (manufacturer of XBee radios) called X-CTU, and an XBee FTDI device (from AdaFruit, or Sparkfun – FTDI friend needed), you can set the configuration of the XBee modules.  Here are the critical settings for my setup:

ID=1111 (same for all radios in your system)
CH=0C (same for all radios in your system)

To start the python script whenever the Raspi boots up, you’ll need an init script.  Find a sample on Github.

Once you place this file in /etc/init.d, run this command:

# update-rc.d tinaja_sensor defaults

Once this is set up, the python script will start-up at boot-time, or you can manually start and stop the script when you make changes like this:

# service tinaja_sensor stop
# service tinaja_sensor start

Node-Red Gateway

This gateway was built using a BeagleBone Black, Revision B.  It is running the OS, BeagleBone Debian.

Download the OS image here. Read instructions here and learn about how to burn an OS image to a MicroSD card using WinDiskImager32.  More info about setting up a MicroSD card here.

Download the OS image hereRead instructions here and learn about how to burn an OS image to a MicroSD card using WinDiskImager32.  More info about setting up a MicroSD card here.

Node-Red is a web based application with a drag-and-drop user interface that makes it possible to build data flows by dragging various components on to the design surface (http web services, tcp socket listeners, MQTT, functional blocks, format converters, etc.) and connecting them with rubber-band connectors that direct the “flow” of data between components. node-red-sample1

This gateway device is responsible for managing the connectivity and the logical flow between the sensors and actuators.  All of the sensors in my home direct their metric data to a web service or a simple TCP Socket which are listening within Node-Red.   From Node-Red, the data can be directed to various destinations such as a data store, a chart, an actuator such as a relay, a light switch, an alerting system, or even a controller for central heating and cooling.  These definitions are called flows and are store on disk in JSON format.

Node-Red is built on Node.js (based on Javascript) and the BeagleBone Debian Image comes with that pre-installed.  The best way to get Node-Red installed is to follow the instructions for BeagleBone Black on the Node-Red web site:

If you’d like to use a Raspberry Pi instead of BeagleBone Black you can look at a specialized distro called TheThingBox –  It is an OS image pre-loaded with Node-Red.

Node-Red Flows

A Node-Red flow is a definition of a collection of nodes modules which are strung together in Node-Red.  You can read about flows on the Node-RED site here.  and see a sampling of available nodes and flows on the Node-RED web site.  You can find some of my flows on Github.

Charting and Analytics Server

This device is an Odroid C1 running Ubuntu 14.04.  It’s basically a Raspberry Pi clone with a quad core CPU and 1G of RAM.  It can run from a MicroSD as the other micro-computers or, it can run significantly faster ( and significantly more expensively) on an eMMC memory card.  You can purchase these devices in the US from a company called

I have utilized this server to host our data storage and to provide our charting and analysis services.  For that I use Graphite, a python based Django web application which includes a TCP socket listener, named Carbon, for all the data input and a round robin database (RRD) known as Whisper.  Graphite at its core is a capable charting application but it looks kind of dry.  To see cool looking charts with an easy to design web interface I use Grafana.



Graphite Chart Style

Grafana Chart Style

Graphite is a comprehensive application and it has a bunch of moving parts.  The basic process of setting this up is to install Graphite the various supporting components:

  • Carbon, the TCP Socket listener for all the data
  • Whisper – the round robin database
  • Graphite – the web application runs in Apache and has these prerequisites:

You can read the Graphite install instructions here.



Grafana Chart Style

Next comes Grafana.  It is a fork of a component that comes with an application known as ELK (Elasticsearch, Logstash. Kibana).  I’ll let you figure out from which component it is derived.

When I originally installed Grafana it was with version 1.8 and it required the addition of Elasticsearch and Java.  Version 2.x does not have the Elasticsearch/Java requirement so I would recommend 2.x.  You can read about installing Grafana here.  The simple approach requires 3 commands:

# wget
# sudo apt-get install adduser libfontconfig
# sudo dpkg -i grafana_2.1.2.deb

Wifi Controlled Light (LED)

This setup uses an ESP8266 wi-fi device as a web server which is waiting for a URL web service request that toggles an LED on/off.  Of course the LED stands in for a relay or anything you’d like to switch on and off. You can find the code I used here.esp8266_LED_Controller

Here’s the Fritzing breadboard diagram.

What’s Next?

From here going forward, I’ve got some more projects to work on. One is to have all the system events logged and to have a voice system that announces the events; kitchen light on, garage door opened, and so on.  It’s a precursor  to a voice control system.  I’d like to set up a wall switch replacement that contains environmental sensors (temp, humidity, light, presence) and capacitor touch switches for a simple control surface.  I’d also like to manage conditioned air to each room in the house based on metrics received from the wall plate sensors in each room.  In other words it would look like a dozen very inexpensive thermostats distributed all around the house and controlling the air conditioning on a room to room basis.

If you get here and find this article meaningful but find something I could improve upon, please let me know.  Thanks.

Raspberry Pi as an Xbee Wireless Sensor Network Gateway

Notes about Raspberry Pi, an ARM based pc about the size of a deck of cards which costs $35. I might use it as a replacement for the Asus WL520 GU wifi modems I’ve been using as an Xbee WSN Gateway.


General References


I started out with the 4G SD Card from Newark that was pre-loaded with wheezy-debian. Now I’m using the distro from Adafruit called Occidentalis v0.2.  It includes ssh and other features that makes it easier to confugure.

Copy the image to a 4G SD Card using Win32DiskImager.  Basically you download an OS image to a windows machine and copy it to an SD Card.  When using WinDiskImager, pay close attention to your read/write actions because it’s possible to overwite the wrong drive.

Before selecting an SD Card, look at the list in Verified Peripherals.  Not all SD Cards work the same, and I spent a lot of time trying to launch the OS even though the image copy was successful.  If you get to the point where you’ve successfully copied the image but it won’t boot up, cut your losses and try another SD Card.

  • login as: pi, password: raspberry
  • I set up a root account and did most of the installation as root

Expanding the partition on the sccard

Once installed, expand the SD Card partition to fill the 4G memory space. The image on the 4G sdcard is 1.8G. This describes how to expand the partition to fill the entire 4G.


Set up SSH so you can access the Raspberry Pi from a terminal program of via Putty and/or WinSCP.

ssh-keygen -t rsa -C ""

XBee connection

I used the CISECO daughter board kit which costs about $6 which has a GPIO connector and a place to hook up an xbee to the serial port on the GPIO.  It derives the 3.3V from the GPIO and it includes an array of through holes for misc prototyping.

  • XBee Radio PCB daughter board– by CISECO – basically a breakout board for the GPIO connections with access to the serial port and 3.3V.
  • Getting started with GPIO and PythonThis is the first of two articles showing basic GPIO on the Raspberry-Pi using the prototype area of the Slice of Pi. This covers basic details on the GPIO pins, setting up a Python library to allow access to the GPIO. There is an example circuit to build on the Slice and some code to get the outputs working. This was originally a blog post on Matts blog at


Raspberry Pi with XBee daughterboard, Slice of Pi

Raspberry Pi with XBee daughterboard, Slice of Pi

On the Adafruit distro, Occidentalis v0.2, I was having some issues with reading the serial port in my python code.  I kept getting erros related to the serial port being in use.  Some research got me to this article on the site and this article from Clayton’s Domain.  I edited a file, /boot/cmdline.txt, and this is what it came down to (all on one line):

dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Install Apache on Raspberry Pi

Eventually I will want to set up a web interface to allow users to edit the gateway config items, like the network protocol and to manage the various sensors, python scripts, etc.  For now, I’m just going to manage it it by ssh command line.

  • Webmin– “Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.”
  • Raspcontrol– PHP based Dashboard application. More about status then configuring.

Installing Python components

Rasberry Pi, default linux install, has python already installed.

I needed these modules to allow me to access various web services like Cosm (pachube), Thing Speak,, and my own SOAP based service that I wrote in C#.


We need some extra libs to run the sensor programs.

Check if python is installed and what version is installed

python -V

Change directory:

cd /home/tinaja/downloads/

WGet the file then unpack it:

tar -zxvf pyserial-2.5.tar.gz

cd pyserial-2.5
python install

simplejson 2.6.1

simplejson 2.6.1 is compatible with python 2.5.

Change directory:

cd /home/tinaja/downloads/

WGet the file then unpack it:

tar -zxvf simplejson-2.6.1.tar.gz

cd simplejson-2.6.1
python install


The suds libs provide services for SOAP calls.

Need to install python’s setup tools:

apt-get install python-setuptools

Change directory:

cd /home/tinaja/downloads/

tar -zxvf python-suds-0.4.tar.gz

cd python-suds-0.4/
python install


Used by Cosm (pachube)
? git clone git://

# cd /home/tinaja/downloads/
# wget
# older version - wget
# tar python-eeml-1.2.0.tar.gz
# python install


I’ve loaded the python code I’m using on GitHub:


The Raspberry Pi can be wifi enabled with a USB based wifi device. The main concern would be with power consumption; the raspberry pi runs off of a 5V (currently 700mA) supply (like a cell phone charger) and a wifi device might strain the load.

For now (8.26.2012) the wired ethernet configuration works great.  It can just plug into a IP provider modem.

To change the boot-up text

Did this to brand the OS as one I set up.  Only for show…

edit /etc/moto.tail

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

Type 'startx' to launch a graphical session

This version, from Adafruit's Occidentalis v0.2, set up by:
 _____ _              _         _          _         
|_   _(_)_ __   __ _ (_) __ _  | |    __ _| |__  ___ 
  | | | | '_ \ / _` || |/ _` | | |   / _` | '_ \/ __|
  | | | | | | | (_| || | (_| | | |__| (_| | |_) \__ \
  |_| |_|_| |_|\__,_|/ |\__,_| |_____\__,_|_.__/|___/
                   |__/, Summer 2012

To set a program to start at boot-up

To automatically run the main python script,, when the computer starts…

Edit /etc/rc.local and add the python line shown below:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

# add this for Tinaja Labs sensor tracking
python /home/tinaja/ &

exit 0

To set up Tomcat Server

At some point I might want to set up a Tomcat server and use it with some Java apps.  Later.


To watch the message log file

This allows you to see the system messages generated by the script as it sends various sensor readings to the web services.

cd /var/log/
tail -f messages

To kill the Tinaja python script

Look for the process id of the python script with this command:

ps aux # for a full list
ps aux | grep python  # to see only python processes

Take note of the process id number and issue this command:

kill 9999 # where 9999 is the process id number

That’s all I have for now, hope you found something useful here.

Wireless Sensor Networks

This is going to be a base post (I’ll make it sticky) to hold the outline of tutorials related to various aspect of wireless sensor networks.  From the sensors and radios, to a gateway,  to web services, data logging and eventually, charting and analysis.  Look at this overview of Wireless Sensor Networks on Wikipedia.

Our interest is in developing a wireless sensor network platform that is inexpensive and simple to use.  There is a sweet spot between super high tech and older outdated technology where we believe there exists a meaningful set of technologies that will fit our goals.

XBee, Wifi, Sensors

XBee, Wifi, Sensors

What we’ve discovered is that we can use radios, like the xBee radios from Digi, with up to 4 sensors hooked up to each one, as our remote sensor boards.  We have also discovered that we can transform a wifi router into a tiny, low powered computer running an embedded, open source, operating system called OpenWRT.  Many wifi routers have a serial port available on the main pcb inside the device to which we can hook up a coordinating xBee radio; the counterpart to the ones on each sensor board.  Then we install a scripting language, Python, into the Linux operating system.  Finally, we install python scripts which can be used to collect the data being transmitted from the sensor boards and send that data to web services like Cosm (formerly Pachube), ThingSpeak,, Paraimpu, etc.

So we have wireless sensor boards sending sensor data to a radio wired into the serial  port of a wifi router.  The wifi router has been re-flashed with an open source embedded Linux operating system, OpenWRT, and to that we’ve added Python as an easy to use scripting language.  We have then added various scripts to bundle the incoming data and send it to the internet for further processing, charting, and so forth.

It is an inexpensive, flexible, easy to use, wireless sensor network platform.

In this ongoing quest to learn more about sensor networks I’ll add links to the Resources Page.


Here’s a list of notes we’ll be updating with information about how to build you’re own wireless sensor network.

  • WSN: Sensors: this is where is all begins.  The sensor responds to some environmental events and generates a voltage or a digital signal.  I’ll be going over a few sensor types that I’ve built; Tweet-a-watt, Temperature, Gas (example of indoor air quality), and a Force Sensitive Resistor (FSR) as an example of Elder Care.
  • Radio: XBee – Radios allow us to create the wireless part of sensor networks.  The XBee radio is very accessible to beginners even if configuration is a bit challenging.  I’ll describe the various aspects of XBee radios that I’ve used.
  • Gateway: Wifi Router – in the original design for the Tweet-a-watt the output from the sensor’s transmitter sent data to an XBee receiver hooked into a PC (via FTDI-USB).  The approach I describe uses a low powered (about 4 watts) Asus wi-fi router in place of a PC.  I’ll describe using OpenWRT as a replacement OS and adding a USB memory stick to extend the storage memory of the device.  I’ll also show how I added python with web service calls in order to send data to the internet.
  • Client facing site: a site for users to register their gateway devices and manage the sensors associated with each.  Also the place to look at the charts and subsequent analysis for the sensor data.  This is an MVC web application written in C# and ASP.NET using Visual Studio 2010 Express and SQL Server 2008 Express.

Next: WSN: Sensors