Skip to main content

Xbee and mbed streaming live data

I've seen a few reviews now of devices like the Xbee and they never seem very exciting. So this is the first of a number of posts I'll be writing where you see me using the product. So let's get started and see if the Xbee is usable as a product!

The Xbee is a small board that uses radio waves to give users a wi-fi like communications network. for most engineers we are looking at small micros like PICs or mbeds type kit that have simple serial communications. Xbee uses a complex system that allows them to connect as either a point-to-point or mesh together as a network of more than two devices. My plan was to use the m3pi robot that has a mbed on the top to stream live data to my PC. The robot will line follow a simple oval circuit and the streamed data will show how well its working - a bit like seeing live data coming back from a formula 1 car!

Xbee devices don't come pre configured and for reference I have serise two units which from what I was told are harder to set up. However I downloaded the X-CTU tool from Digi International that allows you to configure them. However my first issues was connecting them to my PC. Firstly the pin pitch will not plug into a breadboard and there is no simple USB connection on the boards. so you will either need a Xbee to USB adaptor board or as I did, hack together a FTDI development board, few wires and Xbee connectors that match the pin pitch. I used the FTDI FT2232H which has two serial ports on it, allowing me to connect bother Xbees at the same time!

Using an online guide I was pointed at I configured the two units in about 20 mins. And having both connected at once meant I could test them. In my case I wanted simple point-to-point serial. so what goes in one end comes out the other. This as i said worked real easy so on to testing them out in a real project.

The m3pi comes with a Xbee socket on the board so I plugged it in and sent some test data from the mbed to the Xbee. Took me awhile to get this working but the truth was it was working just did not understand. you see when the Xbee turns on it has to find the matched other unit. I was thinking this is just simply blast the airwaves but I found it can take upto 10 seconds for them to find and link up. You need to think more like Wi-Fi on your computer than something like a wire link that just works from switch on.

The next step was to put the line following PID code in the mbed and then to stream out the live data. This would include the power (speed) of each motor as well as the line position. On the PC end I put together a very simple processing application to draw the data on the screen. So after a little debugging I got it working and here are the results!

First we can on the top the line position data from a period of about five seconds, as the track is round you can see that its seeing the line moving to the left all the time. But you can see its nice and close and making corrections all the time despite the robot looking to be very smooth.

The next line is harder to see but the red dots show the left motor and the light blue the right motor speed. We can see that the left motor is on all the time (mostly) and the right motor changing speed.

Over all you can see the data received was good and worked well. For a simple basic first go at this I was pleased that the Xbee connected and streamed that data without any problems. There are many features on the Xbee and just serial communication is I think what most people will be looking for. So top marks for the Xbee and looking forward to trying out the other features.

If you want to keep track of my progress on this and other projects you can follow me on Twitter as @monpjc or via google+ or facebook.

Thanks
Paul
(aka @monpjc)

Other useful links
http://www.ladyada.net/make/xbee/configure.html
http://www.faludi.com/itp_coursework/meshnetworking/XBee/XBee_program_Arduino_wireless.html
http://www.circuitsathome.com/category/wireless/xbee

DesignSpark Electrical Logolinkedin