ZigBee Simple Sensor Network

by January 30, 2012 04:40 AM

This is the project I mentioned in Configuring My First XBee Radios where I'm going to setup the sensor network from chapter 5 in Building Wireless Sensor Networks. I'm going to end up with two remote temperature sensors that are mesh-networked together to stream their data to a base station radio connected to my PC.

Preparing the radios

Coordinator

This is a simple matter of connecting to the xbee with X-CTU and switching its mode from AT to API (along with ATAP = 2). I also went ahead and zeroed out ATDH and ATDL since the coordinator will be receiving data only.

Routers

These stay in AT mode, but need the following settings:

  • ATID - set to the same PAN ID as the coordinator
  • ATDH - 0 (forces the radio to use 16-bit addressing)
  • ATDL - 0 (destination is the coordinator for both routers)
  • ATJV - 1 (rejoin network on restart)
  • ATD0 - 2 (puts pin 0 in analog mode)
  • ATIR - 3E8 (sample rate of 1,000 milliseconds - polls for the temperature once a second)

Something that might be worth noting here. When I first unplugged the coordinator and plugged in the first router, my computer's USB completely stopped working. Yep, I lost both my mouse and keyboard and no amount of unplugging and plugging them in helped. I tried every USB port on my computer. I eventually had to do a hard restart (and luckily only lost a little progress on this post - I save often). I did notice I had left X-CTU running when I did the switch. This time I closed X-CTU in between configuring the two routers and everything worked fine. Don't know for sure if that was the problem since I don't care to reproduce it, but wanted to put it out there just in case you run into the same thing.

Preparing the sensor boards

Sensor Board

This was an experience for me. It seems like I have a vague memory of having soldered before, but we might as well say I've never done it. I'm proud to say I finished with only one burn (right index finger). The solder jobs themselves look horrible.

Working with all the parts was interesting as well (transistors, resistors, etc.). Very neat and I'd say rather satisfying when the end product is a physical thing instead of software. Good times!

This is a picture of the first one I put together (the second looks identical). The little black thing poking up right below (in the picture) the XBee is the actual temperature sensor. The mess of stuff near the bottom is the voltage regulator (from 9-volt to 3.3-volt) and the capacitors (to get rid of noise in the power supply). Prototyping on those breadboards is super easy.

Capturing the sensor data

The book actually supplies a program ready to use that will allow you to visually see on your computer all the data being sent from your remote sensors. It's a Processing program that uses some Java libraries to communicate with the XBee radio over the COM port. I could have used that I suppose...

Sensor Network App

Being the developer that I am though, I wrote my own in .net. I put the code out on github in a project called XBee (real stretch for a project name, I know). You can see the library I wrote along with the project specific to this example at https://github.com/rtennys/XBee. The format of the messages sent from the XBee radios in API mode are very easy to work with. It was a fun little exercise for sure.

What's Next

I think I'm going to do two things next. I'm going to kind of stick with the book moving on to creating temperature sensors that are configured as end devices instead of routers. This allows them to be much more conservative on the energy they consume thus allowing me to use a battery power supply instead of having to plug them in. In addition to what the book shows though, I'm going to create my own PCB instead of using the breadboard.

Tags: , ,

Comments (3) -

Nathan Robinson
1/31/2012 1:48:21 AM #

I need to bring my breadboard and digital logic kit over sometime and build some circuits with you sometime...
Have you considrered using something like a Fit-PC [http://www.fit-pc.com/web/] as the computer? They are very low power computers. My Fit-PC 1 is a fanless ~ 3 watt pc that runs my home server (e-mail, web host, dns, ssh, and file share). I run it completely headless with text-mode ssh only.
You could ssh into that computer and not have to worry about locking up your usb.

rtennys
1/31/2012 8:22:21 AM #

fit-PC looks very cool! Also noticed the link to http://trimslice.com/ on their site which is also cool.  Nice find dude!

May take you up on the get together one of these days. Something tells me I would learn a lot.

Nathan Robinson
1/31/2012 10:09:47 AM #

Trim-Slice-Debugger extension board with JTAG and serial interfaces
Now that sounds really interesting!

Pingbacks and trackbacks (1)+

Comments are closed