Archive for category Tutorial
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.
- 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.
Hooking up a gas sensor is more or less the same as with the voltage divider model but it has an extra twist. The MQ Series sensors which I used for gas sensing (average cost= $5) have a heating element to react with the gases they detect. I’ve played with the MQ-2 – General combustible gas, MQ-3 - Alcohol, MQ-4 - Natural gas & Methane, MQ-5 - LPG or Propane, and the MQ-7 - Carbon Monoxide (CO).
For the analog sensing it is the same as the classic voltage divider model (see the notes on the main sensor post). Because I use an XBee analog input to read the sensor output value, the V+ is at 3.3V (which is what the XBee runs on) and the V- is at Gnd.
Here’s the schematic I set up (click to see a larger view):
It might seem more complicated than it needs to be, but basically we have a 5V regulator supply (w/ 7805) for the heater element, a 3.3V regulator supply (MCP1700-3302E/TO; same as the Adafruit XBee Adapter PCB) to power the XBee module, then the MQ series device. I’ve connected the gas sensor output to pin 20 of the XBee module, so we’ll be reading the gas sensor voltage on analog input 0.
One thing to note about these sensors is that they are not calibrated to detect specific parts per million, etc. They can also be affected by the ambient temperature and humidity. I’ve used them primarily to know when the gas concentrations are high or low, trending up or down.
Here’s a live sample graph of the data tracked at Pachube.com:
The spikes you might see on the chart are, I am pretty sure, generated by some problem of collection downstream of the sensor and the xbee radio. Hopefully, I’ll get this resolved soon.
Next Post: FSR Sensor
Next Group: Radio:XBee
The temperature sensor is based on the TMP36 Low Voltage Temperature Sensors.
My first attempt at creating a wireless temperature sensor was using a TMP36 device from Analog. The TMP36 looks like a transistor because it is in a TO-92 package.
I soldered together an XBee Adapter board from Adafruit then I soldered the TMP36 directly to the adapter board. Using the layout above. I soldered the voltage input pin to the closest VCC trace, the ground to ground (obviouisly) and the Analog Voltage output pin to the AD0 pin.
This seems to work fairly well if you only have one input. If you plan to use multiple sensors on the XBee ADC inputs, you’ll need to set up a rail to rail op amp buffer. But that’s for another post.
Here’s a live sample of a TMP36 data stream from my back porch as derived from a chart on Pachube.com:
Large spikes are a known problem with the data collection downstream of the TMP36 and the XBee module. To be fixed soon, I hope.
Next Post: Gas Sensor
Next Group: Radio:XBee
The Tweet-a-Watt is a wireless power meter based on a commercial device called the Kill A Watt which is hacked to include a wireless XBee radio. It was designed by Limor Fried of Adafruit Industries and she has written up one of the best online tutorials for a kit based project. It collects data from the Kill A Watt from P3 International and with an added XBee radio sends data to a PC and then on to a twitter feed. Hence the name, Tweet-a-Watt, a combination of Twitter’s Tweet and the Kill A Watt power meter.
The basic components:
Kill A Watt Power Meter (P4400)
Everyone should own at least one Kill A Watt. It can tell you the cumulated kilowatt hours (KWh) at the plug load of an appliance, along with the volts, amps, and watts.
With pencil and paper and a little time you can hook this up to the various appliances in your home and look at the meter and simply “do the math”. With the math, and perhaps a spreadsheet program, you can analyse what your appliances draw in watts and learn what to turn off or use less. You can get them online for as little as $17 and at your local hardware store for about $25.
The Kill-a-Watt starts to become a Tweet-a-Watt with the introduction of an XBee radio. The radio can be hooked up inside the Kill-a-watt and that makes it possible to transmit the readings from the Kill A Watt and send them to a computer for logging and analysis.
The original design of the Tweet-a-Watt project had an XBee radio receiver hooked up to a PC through what is known as an FTDI USB cable; essentially a serial input. There was a python script that would run on the PC and collect the serial input and package the data for delivery to a twitter feed.
During my investigations I saw Limor Fried’s short video about using an Asus Wifi Router instead of a PC to collect and send the sensor data to the internet. If you’re trying to reduce your energy consumption it seems a shame to have to run a PC; even a laptop will draw perhaps 60-90 watts. The Asus wifi router setup can be configured to run the python script and do the same basic job as the PC but it only draws about 4 watts. Much better. See the post about setting up the ASUS WL-520gU.
Next Post: Temperature Sensor
Next Group: Radio XBee
Sensors are the front line components in a wireless sensor network. They move a response from the physical realm into the electrical realm. Each sensor responds to some environmental events and generates a voltage or a digital signal or something that can be measured. There’s a great list of sensors on Wikipedia (hours o’ fun). I am constantly surprised by the seemingly endless list of sensors.
To list some things that can be sensed:
- Gas, Smoke
- Tilt, Acceleration
- Air pressure
Most sensors are what are defined as Passive. Passive sensors react to some environmental stimulus and put out a signal. Active sensors inject something into the environment and then respond to the effects created by the active aspect. Radar is a classic example of an Active Sensor.
Because we’re talking about “wireless” sensors, it’s hard to talk about wiring up the sensors without talking about the radios that make them wireless. We’ll focus on XBee radios but there are others that I’ll describe on the Radios post. On many sites on the internet sensors are shown as hooked up to a microprocessor (which then connects to a radio). I have found that for the sensors I have built so far, none have needed to use a microprocessor. Instead, I’ve connected the sensors directly to an analog input of an XBee. It seems you would need a microprocessor when you need to apply some kind of up front logic to a sensor’s readings.
When trying to figure out how to wire up sensors, it helps to have a basic knowledge of electronics. The most prevalent setup in sensor networks seems to be what is called the voltage divider (see the diagram below). There’s a lot of theory about voltage dividers but the basic idea is that you have a voltage at the top (Yin), you have 2 resisters connected inline (R1, R2) to a ground, and you have a voltage out (Vout) where the 2 resisters are joined. The output voltage (Vout) is some value relative to the ratio of R1 and R2.
As an example, you can imagine that R1 is a sensor that varies its resistance with temperature. If Vin is 5VDC then the Vout is going to vary dependent on the variable resistance of R1. Vout would be connected to an input on an XBee (to send wirelessly over a radio) or connected to a microprocessor (like an Arduino) for special handling.
There’s a cool page that shows lots of different circuit layouts for various sensors on the Wiring site (Wiring is kind of like Arduino). On this page you can select circuit types from a popup and some of the selections with display circuits.
Another great resource to get started is on Adafruit Industries’ Tutorial on Sensors which gives an overview of various sensors and how to wire them up.
- Tweet-a-Watt: The Tweet-a-Watt, originally created by Limor Fried (aka: Adafruit) is a modified Kill A Watt with an embedded XBee radio.
- Temperature Sensor: It is relatively easy to hook up a temperature sensor to an XBee radio.
- Gas Sensor: Hooking up a gas sensor to an XBee radio.
- FSR Sensor (Force Sensitive Resistor): Very easy to hook up even if a bit challenging to hook up physically. The FSR responds to pressure applied to its disk and simply changes the resistance based on the amount of pressure.
Next Tutorial Post: Tweet-a-Watt
Next Group Post: Radio XBee
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.
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.
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