> | | > Point to Point Xbee Network Testing

Point to Point Xbee Network Testing

Posted on Friday, 4 January 2013 | 2 Comments

Xbees are wireless modules which interface radio transmissions with standard serial input output.  All transmission issues are taken care of by the Zigbee protocol (which is the protocol that Xbee Series 2 modules use).  This ease of use means Xbees are often used as drop in replacements for a serial cable as can be seen in the diagram below.  In this configuration the module's default settings mean that a link can be set up quickly and easily.
Xbees in Unicast mode
This is called 'uni-cast', when a module knows the address of it's recipient, and sends data directly to it.  In this example, the second module also knows the address of the first Xbee, and therefore can reply back to it.

Xbee Shields

In this project, shields are used to interface the Xbee module with the Arduino Uno on the robots.  The main component on these shields is a voltage regulator to convert the Arduino's 5V logic to the Xbee's 3.3V. Without this the Xbee module could be damaged.

There are two jumpers on the Xbee shield in order to set whether the Arduino uses the USB port for serial output as normal, or sends it's data to the Xbee.  If flashing a board with a Xbee module connected, the jumpers need to be in the USB setting, if the Arduino needs to connect to the Xbee, the jumpers need to be in the Xbee setting.  It is also worth noting that the Arduino can be connected to a computer via the USB cable in order to monitor what the Xbee is receiving with the jumpers in the Xbee setting.  This is due to the Rx channel being connected to both the Arduino and the USB port.  The diagrams below show the shields on top of the Arduino, with the jumpers in both positions.

Another possible configuration is to have the jumpers in the USB position, but having the Arduino chip removed.  This can be done by carefully inserting a flat headed screwdriver underneath the chip and slowly lifting it up without bending any pins.  Take note of which way up the chip goes so that it can be reinserted later!  This configuration allows the Arduino board to act as an interface to the Xbee module, meaning that the computer can send serial data to be sent over the Zigbee network.  This configuration is used later in the project so that Processing can communicate with the two robots.

Testing an Xbee Network

Most communication examples use the 'Physical Pixel' example sketch.  This bundled example can be found in the Arduino IDE in Examples>Communication>Physical Pixel.  The code can also be seen below.
  Physical Pixel
 An example of using the Arduino board to receive data from the 
 computer.  In this case, the Arduino boards turns on an LED when
 it receives the character 'H', and turns off the LED when it
 receives the character 'L'.
 The data can be sent from the Arduino serial monitor, or another
 program like Processing (see code below), Flash (via a serial-net
 proxy), PD, or Max/MSP.
 The circuit:
 * LED connected from digital pin 13 to ground
 created 2006
 by David A. Mellis
 modified 30 Aug 2011
 by Tom Igoe and Scott Fitzgerald
 This example code is in the public domain.


const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);

This reads an available byte from the Arduino's serial buffer, and if it is the character 'H', turns on the LED hardwired onto pin 13.  If it is an 'L', it turns the LED off.  In order to test this sketch, code needs to be written to send the characters. This is done simply by writing the required character to the serial port, which the Xbee then picks up and transmits to its partner.  This code can be seen below.
void setup() {
  // initialize serial communication:

void loop() {
The result of this is to see the LED on pin 13 on the receiving Arduino flashing on and off every second, therefore confirming the two Xbees are connected.  It has been found if a connection is not found, performing a hard reset of the two devices simultaneously forces a re-setup of the network, and allows the two devices to find each other.

The actual network required for this project is a point to multipoint network, which is much more complex, and will be covered in a separate post.


  1. Thanks for sharing. Learn a lot from your Blog.I have read your blog about it-security-matter It is very help full.I really enjoyed reading it, you may be a great author.I must say you've done a wonderful job by sharing your article with us. External Network Testing

  2. Thanks for the great post. I am trying to connect two xbees together using two arduinos. Interestingly when the coordinator is connected with a ftdi cable with the pc the router is able to send data from the arduino. But when the coordinator is connected with an arduino then its no more receiving any data from the router (which is mounted on an arduino). I have tried the software serial and also the normal serial mode. But no luck. Is there any way to solve this?


Theme MXS. Powered by Blogger.