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.

The new Nest Learning Thermostat – $250

A friend sent me a link to this article  about the new Nest Thermostat and I got very excited; went to the site to put in my order… rrrrP!  (that’s the sound of me hitting the brakes)

$250?  Why does cool have to cost so much?

I have been building my own home wireless sensor network for the last 2 years. Temperature, light, hall effect, gas detection, FSRs, the Tweet-a-watt, etc. using XBee modules and a wifi gateway that uses an open source OS (OpenWRT) and Python scripts to send data to web services (like, ThingSpeak,  I’ve been studying home energy automation for a couple of years now and I’m beginning to understand the various aspects of what it takes to put together components to collect and communicate meaningful, actionable information.

The Nest Learning Thermostat has some cool features.  It learns… and that’s fantastic.  As I understand it, you can set the thermostat up or down at different times and it will remember what you set and build a schedule that repeats your preferences. That’s very cool. It has a motion detector to sense the presence of people in the house and turns the system down/off. That’s cool, too. But there are some serious issues that I see over and over in this field.

First off this device costs too much. It should be priced at somewhere below $50 for the thermostat. That would put it at a price point to get it into the homes of many more people. The more consumers use it, the more we can reduce our dependence, as a nation, on foreign sources of energy. That’s a national, heck, a global goal, right?

Next, I don’t see any way to help consumers understand meaningful and detailed results of the savings they create by using the thermostat. They might see an overall drop in their gas or electric bill, but how much can be attributed to the thermostat as opposed to the incandescent bulbs they replaced with CFLs, or by the shading of a porch, or by being more diligent in turning off the entertainment system (including the STB) and vampire loads.

Also, the designers have created a thermostat in a very traditional form. IOW, they’re not “thinking different”. The learning aspect is interesting, but I’d rather just go to my android app, or the web site and just start with a default profile for my region, house size, etc, and adjust to taste. Otherwise, I’ll not look at it again unless there is an exception to the rules, like going on a long weekend vacation.

Similarly, the designers are stuck with the concept that we need a thermostat on the wall and that we would ever want to get up off the couch and go look at it. Why spend the effort in a device that shouldn’t even require a UI. IOW, the phone app or web page should be the preferred UI.

A “think different” approach might have a temperature sensor and a motion detector in each room and these very cheap components can inform the HVAC controls how to adjust for optimum comfort vs cost. The display and controls don’t need to be on a wall in the hallway… That’s as old as the the round Honeywell thermostats people were referencing in the comments on the Wired Magazine article.

I also believe that the display devices that you get with most home automation system, perhaps in the style of elaborate refrigerator magnets with displays, are destined, too soon, for garage sales and Goodwill stores. Let’s extend the devices that we already have for control surfaces, like tablets, smart phones, game consoles. For those who don’t have smart phones in their homes, how about something like a cheap android phone form (w/o the phone functions), music players, remote controls, wifi tether devices; any devices that can support apps.

I believe profit is deserved by all who work but how much is enough? If you look at Chris Anderson’s approach describing how to make a profit on your products (), you would sell at 2.3 times the cost of parts; and that’s a good profit margin. If I did my math right, it looks like the BOM costs about $108.

I suppose they might be adding in some of the costs of running a free web service that stores all the data so clients can see the ongoing history of their thermostat settings correlated to the temperature of their house and the local weather.

Lastly, my impression is that the design isn’t finished. Design doesn’t stop until you’ve optimized the functionality, the design, and the cost. In this era of programmable microcontrollers, arduino shields, MEMS sensors, surface mount components, standard protocols, inexpensive cloud based web services, the Internet of Things… we need to delight consumers by making the products attractive, pervasive, and affiordable…  for everybody.

OSHW – Open Source Hardware

I support the Open Source Hardware Definition v1.0

A cool new logo has been defined for Open Source Hardware (OSHW).

Here are the principles of what is being attempted in open source hardware (from the site):

Open source hardware is hardware whose design is made publicly available so that anyone can study, modify, distribute, make, and sell the design or hardware based on that design. The hardware’s source, the design from which it is made, is available in the preferred format for making modifications to it.  Ideally, open source hardware uses readily-available components and materials, standard processes, open infrastructure, unrestricted content, and open-source design tools to maximize the ability of individuals to make and use hardware. Open source hardware gives people the freedom to control their technology while sharing knowledge and encouraging commerce through the open exchange of designs.

Read more here…

Netgear GS605 v2 fix

NetGear GS606 v2 with new capacitors

NetGear GS606 v2 with new capacitors

A few weeks ago we had a serious storm here in the SF Bay area and the power went out for about 5 hours.  It took a few days for me to realize that the internet connection was running pretty slow, so I started trying to trace it.

I’m using Comcast IP service and right out of the cable modem I was getting 21Mbps (using the Speakeasy speed test).  After the first Netgear gigabit switch the bandwidth dropped to about 3.g Mbps and after the second, it dropped less than 1.0 Mbps.  Killin’ me!

So after some Google searching I found that the Netgear GS605 v2 was susceptible to power surges which often happen during or after power outages.  The problem is apparently in the poor quality capacitors used.  Once replaced, they are back to full force with less than $10 worth of parts and about 20 minutes.  Here’s how I replaced the capacitors.

Tools, parts:

  • Soldering Iron
  • Solder Sucker
  • Torx Screwdriver (T8)
  • 2 x 1000 uF 10V, 1 x 470 uF 25V capacitors

Open it up:

On the bottom there are some rubber feet that can be peeled back to reveal tiny torx head screws (from my set I used a T8).  Unscrew the 4 screws.  The PC board is not secured further, so when you remove the back, you can jiggle the PCB and it will come out as a single unit.

Removing the capacitors:

On the PCB you can see 4 capacitors:

  • 2 x 1000 uF, 10V
  • 1 x 470 uF, 25V
  • 1 x 100uF, 16V (looks like part of the power regulator, I did not replace)

To remove the capacitors, I first tried using one of those solder sucker tools but I think my soldering iron it not getting hot enough.  I basically put some side pressure on the exposed post oposite the capacitor side of the PCB and when the solder melted, the capacitor slipped out at an angle.  Doing the same on the other post released the capacitor.  I removed the 2 1000 uF caps and the 470 uF cap.


I went to Radio Shack and purchased:

  • 2 x 1000 uF, 35V – $1.79 ea.
  • 1 x 470 uF, 35V – $1.49 ea

The replacements from Radio Shack were their generic versions, bigger in size and higher in rated voltage but I wanted to get it done and not wait a few days for an online order.

Because the new capacitors were so large, I had to mount them sideways. on the PCB.  This is generally straight forward if you pre-bend the leads.  Put the cap in place and with needle nose pliers, pre-bend at the appropriate lengths.  The 1000 uF cap closest to the edge needed to be bent with the leads in a slightly overlapping form, but once you get in there it should be obvious.  Here’s what it looked like.

NetGear GS606 v2 with new capacitors, close up

NetGear GS606 v2 with new capacitors, close up