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, Open.sen.se, 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.

Tutorials:

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

1 Comment

Peter Schwartz: The Art of the Really Long View

The art of the really long view from a Long Now Seminar presentation by Peter Schwartz.

Leave a comment

LapPi – Raspberry Pi as laptop

Here’s a really beautiful assembly of a DIY laptop with Raspberry Pi at its core from Instructables.  It requires some woodworking skills as well as computer assembly.

http://www.instructables.com/id/LapPi-A-Raspberry-Pi-Netbook/

Leave a comment

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.

RaspberryPi.jpg

General References

OS

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.

SSH

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 "your_email@youremail.com"

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 http://lwk.mjhosting.co.uk

pi_001th.jpg

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 RaspberryPi.org 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):

/boot/cmdline.txt
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.

  • http://tinkernut.com/wiki/page/Episode_320
  • 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, Open.Sen.se, and my own SOAP based service that I wrote in C#.

pyserial

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:

wget http://sourceforge.net/projects/pyserial/files/pyserial/2.5/pyserial-2.5.tar.gz/download
tar -zxvf pyserial-2.5.tar.gz

cd pyserial-2.5
python setup.py 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:

wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.6.1.tar.gz
tar -zxvf simplejson-2.6.1.tar.gz

cd simplejson-2.6.1
python setup.py install

suds

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/

wget https://fedorahosted.org/releases/s/u/suds/python-suds-0.4.tar.gz
tar -zxvf python-suds-0.4.tar.gz

cd python-suds-0.4/
python setup.py install

eeml

Used by Cosm (pachube)

http://pypi.python.org/pypi/python-eeml/1.1.0
? git clone git://github.com/petervizi/python-eeml.git

# cd /home/tinaja/downloads/
# wget http://pypi.python.org/packages/source/p/python-eeml/python-eeml-1.2.0.tar.gz
# older version - wget http://pypi.python.org/packages/any/p/python-eeml/python-eeml-1.1.0.linux-i686.tar.gz
# tar python-eeml-1.2.0.tar.gz
# python setup.py install

Code

I’ve loaded the python code I’m using on GitHub:
https://github.com/TinajaLabs/gateway_raspi

Wifi

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:
 _____ _              _         _          _         
|_   _(_)_ __   __ _ (_) __ _  | |    __ _| |__  ___ 
  | | | | '_ \ / _` || |/ _` | | |   / _` | '_ \/ __|
  | | | | | | | (_| || | (_| | | |__| (_| | |_) \__ \
  |_| |_|_| |_|\__,_|/ |\__,_| |_____\__,_|_.__/|___/
                   |__/ TinajaLabs.com, Summer 2012
-----------------------------------------------------

To set a program to start at boot-up

To automatically run the main python script, allsensors.py, 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"
fi

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

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.

Java

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.

13 Comments

Maker Faire 2012

Come visit us at Maker Faire!

I just got the confirmation email that I’ve been accepted to have a booth at this year’s Maker Faire.  The booth is called A Sense of Things, as it was last year, and is numbered 7443.   I hope to visit with all my sensor friends on Saturday and Sunday, May 19th, 20th.

I’ll be showing our latest development on a low cost wireless sensor network designed for the “everyman” or “everywoman” who wants to track things in and around their homes.  Please stop by for a visit.

To sign up for the maker Faire:  http://makerfaire.com/be-a-maker.csp

 

Leave a comment

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 Pachube.com, ThingSpeak, Open.Sen.se).  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.

http://nest.com

http://www.wired.com/gadgetlab/2011/10/nest_thermostat

http://blog.ponoko.com/2010/11/16/ten-rules-for-maker-businesses-by-wireds-chris-anderson/

,

1 Comment

Maker Faire Surprise

On the drive to Maker Faire on Friday, I had a few dark moments wondering if anyone would really care about the work I’ve been doing on wireless sensor networks.  I imagine that there are all these sensors struggling to be heard and I’ve been constructing a platform to help facilitate that.  But would anyone share that vision?   On I drove…

My friend, Terence, helped get us set up with the booth and finally with no hope of getting any internet access (seems it was over-taxed most of the time), we retired to the Friday evening’s beer and paella dinner.  We met a lot of wonderfully creative Makers.  The Maker Faire is such a wonderful collection of creativity in all it’s myriad forms.  It is inspirational and gives me hope.  Terence made a good point that Obama should have come to the Maker Faire to see an example of what makes America great.

Well I have to say I was very surprised to see how many people came to our booth to learn about wireless sensor networks.  I’m exhausted and my voice is shot but I feel very satisfied to see so much interest in what we have built.  Thanks to all who came by the booth.  I hope that this experience can be the beginning of an exchange of ideas to make more robust sensor networks that can provide meaning to those who seek to extend what we can know about the world around us.  I heard so many great ideas and I hope we can keep the them coming.

Now that the Maker Faire is over, I plan to focus on this web site for the next couple of weeks and get the tutorials in order.  I’ve started some of them and have not yet published some others.  I promised everyone who I spoke with at the Maker Faire to get these completed and that’s where I’ll be focused.  If anyone wants info about any particular part of the platform, sooner than later, please let me know and I’ll be happy to move that to the front of the line.

Thanks to all who came by the booth, to Terence, to my friends who’ve been supporting my efforts to Make my vision, to Aurora for putting up with my project clutter, and thanks to the folks at Maker Faire for putting on a great show.

(the original post about Maker Faire)

2 Comments

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…

Leave a comment

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.

Replacing:

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

22 Comments

Maker Faire! May 21, 22

There was a call for Makers, I applied and got accepted. So this year, instead of being in the stands, I’ll be out on the field having fun. My booth will be called The Sense of Things, as a play on the concept of The Internet of Things.

I will be showing what I’ve learned in the last year regarding wireless sensor networks.

Short Description: Wireless sensor networks, data acquisition and analysis; a discussion about building wireless sensor networks based on open source software and hardware (OSHW) for use in things like home energy, air quality, and elder care.

Long Description: Exploring sensor networks, data acquisition and displaying data.

This project will demonstrate what I have learned in the last year from others on the internet. Open source software has lead to open source hardware (OSHW) and makes it possible to build wireless sensors, open source wireless gateways, data logging data services and charting applications.

With this kind of system we can monitor things like energy used in a home, indoor/outdoor temperatures, wind speed, dangerous gases, the presence of a person in a room, etc.

We will discuss how various online tutorials and technologies (Tweetawatt, xBee, Asus wifi with OpenWRT, data logger, web services, Pachube, Adafruit, MightyOhm, etc) were used to develop the test system.

Web site: TinajaLabs.Wordpress.com

Please come by for a visit.

Saturday, May 21st – SHOWTIME :  10 a.m. – 8 p.m.
Sunday, May 22nd – SHOWTIME:  10 a.m. – 6 p.m.

 

3 Comments

Physical dashboard devices – Eh!

According to this article by Katie Fehrenbacher at Gigaom, the developers of home energy management systems have figured it out that there’s no future in dedicated dashboard devices when you have a marketplace full of iPhones, Android phones, iPads and other tablet devices.

The dedicated dashboard devices would be able to display various conditions of your home energy system, your local weather, etc., and to control devices in the home.   But now that we have Android phones and iPads, these new devices can access the web and use either native web pages or specialized apps.

It’s a no brainer.   Have a web based system as the default UI and provide specialized apps for hand held controls.

Leave a comment

Follow

Get every new post delivered to your Inbox.

Join 224 other followers

%d bloggers like this: