To XBee or not XBee...
- Posted: Jun 15, 2012 at 6:00 AM
- 10,861 Views
Today's Hardware Friday projects are all about XBee in the .Net Micro Framework world...
XBee is the brand name from Digi International for a family of form factor compatible radio modules. The first XBee radios were introduced under the MaxStream brand in 2005 and were based on the 802.15.4-2003 standard designed for point-to-point and point-to-multipoint communications at over-the-air baud rates of 250 kbit/s.
Two models were initially introduced--a lower cost 1 mW XBee and the higher power 100 mW XBee-PRO. Since the initial introduction, a number of new XBee radios have been introduced and all XBees are now marketed and sold under the Digi brand.
The XBee radios can all be used with the minimum four number of connections - power (3.3 V), ground, data in and data out (UART), with other recommended lines being Reset and Sleep. Additionally, most XBee families have some other flow control, I/O, A/D and indicator lines built in. A version of the XBees called the Programmable XBee has an additional onboard processor for user’s code. The Programmable XBee and a new surface mount (SMT) version of the XBee radios were both introduced in 2010.
I'm moving to my own appartment and I want to control lamp and mood light wirelessly. Because I want to extend mood light across whole appartment in future. I have decided to use XBee. Specifically XBee Series 2.
My setup is
- 2 XBees
- 2 breakout boards
- FT232RL USB to Serial breakout board
One of nice features of XBee is availability of 10 I/O pins. This allows XBee to sample sensor data without any other microcontroller. XBee can also send sample only when selected digital input changes. This chapter is not well covered online, so I've decided to share my experience.
First of my XBees is running API Controller firmware, its connected to Netduino via serial port. API firmware allows you to receive I/O data from other XBees, which is exactly what I want. Second one is standalone, only two buttons and one lamp are connected. Its running end device API firmware.
Lets configure our XBees using Digi's configuration utility X-CTU.
XBee radios are inexpensive and they can be embedded in all kinds of devices. XBees can be networked so that a failure of one radio does not impar communication between and among others in the network. Their range exceeds that of Bluetooth connections. The article Zigbee Networking with XBee Series 2 and Seeed’s Products provides a quick overview of XBee functionality. Robert Faludi‘s book titled Building Wireless Sensor Networks is an excellent tutorial on using XBees in Arduino devices. This article demonstrates an extensible scenario for using XBee radios with .NET Gadgeteer devices.
The examples in this post demonstrate XBee radios in the AT communication mode, which is the human readable control protocol. XBee radios can also use API protocol. Either method requires learning command details and some basic configuration settings. You’ll want to get the X-CTU tool available from Digi and an Explorer dongle.
This example implements two .NET Gadgeteer devices with XBee radios. A sensor device sends notifications to another device, which acts as a relay station. The relay has Internet access via a GHI Electronics WiFi RS21 Module and it has an electrical actuator circuit that closes upon notification from any number of sensor devices. When a sensor device sends a notification, the relay device turns on the actuator switch, which closes a circuit that can run anything within the power ranges of the Seeed Studio Relay Module for .NET Gadgeteer, up to DC 10 Amps/ 250 Volts, or AC 15 Amps/ 120 Volts.
Using the .NET Gadgeteer platform with XBee radios got a lot easier with the alpha release of XBeeClientlibraries written by Paul Mineau. XBee radios use low-bandwidth serial protocol that is useful in many applications. This example implements an XBee network using three XBee radios that support a surveillance device. The .NET Gadgeteer modules include a Gyro module and Relay module from Seeed Studio, and a Camera module and SD Card module from GHI Electronics.
In this scenario the gyro module is calibrated so that rotation on one axis can be monitored to send an alert when a door swings open. When the door opens, one XBee radio sends an alert to another XBee in the network. The second radio closes a relay circuit to turn on lights and start a timer. Each time the timer ticks, the surveillance device takes a picture. The Seeed relay module for .NET Gadgeteer, which turns on the lights, hosts four relays, and each of them can handle AC electric circuits up to 7 amps/ 250 volts or 16 amps/ 120 volts. That’s enough power to illuminate an area under surveillance so brightly that it will disorient an intruder and make it easy to take pictures with the camera.
An earlier piece titled XBee Radios in .NET Gadgeteer Devices explains modem configuration and flashing XBee radios. For other pertinent information, see Robert Faludi‘s book titled Building Wireless Sensor Networks. The book is a tutorial using XBees in Arduino devices, but much of the information in the book is helpful when setting up XBees with .NET Gadgeteer. The XBee radios used in this application should be flashed in the API configuration, two of them as routers and one as a coordinator (every network of XBee radios requires one coordinator).
The XBeeClient libraries are designed to make set-up and testing of XBee radios easy. Download the Alpha 126.96.36.199 version of the libraries from CodePlex, and run the .msi installation package. If you haven’t yet used the X-CTU tool from Digi to flash your radios, see XBee Radios in .NET Gadgeteer Devices. The process is not entirely painless, but we’re just getting started with these things. In this example we’ll set up two XBee API router devices using .NET Gadgeteer XBee adapters from GHI Electronics. We’ll run the XBee coordinator on an Explorer dongle. The InteractiveConsole PC application that is included with the XBeeClient libraries is great for testing, and in scenarios such as this, it is fine to use it as the PC component of a network of XBees
The code in this brief example is part of an investigation into bandwidth and latency of XBee radios used for remote control. I’d be interested in any other experiments with XBees. If you have something, we can discuss a guest post. There are several versions of this robot now. The original by Eduardo Velloso uses light sensors and can be controlled with a flashlight. Others by Marco Minerva and MJ Sharma use Bluetooth remote control.
This experiment uses the same robot chassis as the version designed by Eduardo Velloso, which is described on the .NET Gadgeteer team blog and Eduardo’s blog. Assembly of the robot and XBee configuration details have been discussed elsewhere. The remote control device and the the robot receiver, in this case, are modified to use XBee radios. The XBeeClient libraries from the codeplex project by Paul Mineau are the core of the application.
This version of the robot and the controller use Spider mainboards from GHI Electronics instead of the Hydra mainboard, also from GHI Electronics that Eduardo used in the earlier version. Instead of light sensors, this version uses a GHI Electronics potentiometer to control the speed and direction of the robot.
Controller Device Code
The following code block shows the remote control device. The control mechanism is simply to send the voltage reading from the potentiometer via the XBee radio on the controller to the XBee radio on the robot. If the user turns the potentiometer all the way to zero, the controller sends a “stop” message instead of the voltage. A timer initiates the control signals at two second intervals. This is an ad hoc limit that I found using a baud rate of 9600.
An extremely easy Xbee library for .Net Gadgeteer
Alpha Release is available. Go to the Downloads tab to download the XBeeClient MSI which will install the Gadgeteer Module. The zip file also includes an Interactive Console for the PC. Please see the Getting Started guide.
Download the latest source code which is fully functional and ready for review.
XBee Series 2 support only, no support for 802.15.4
- Build a Bear http://GadgeteerCookbook.codeplex.com
Documentation Table of Contents
And as you would expect, all four of these articles include source...