Skip to end of metadata
Go to start of metadata

In this activity, you play hide and seek using the signal strength between two radios to guide your search.

If you get stuck, go to the Troubleshooting links at the end of the example.

1. Requirements


Two XBee 802.15.4 modules

One Arduino Leonardo

One XBee Shield

One XBee breadboard adapters

One XBee USB adapter

to configure the XBees

Two solderness breadboards

Six LEDs

Six 330Ω resistors

Jumper wires

Two 9V battery clips

Two 9V batteries


One breadboard power supplies

One micro USB cable

One min USB cable



If you have not already done so, use the links below to download and install the software:

For further information about XCTU, go to the XCTU walkthrough.

2. Add the XBees to XCTU

  1. Ensure that the XBee is seated firmly in the XBee USB adapter.

  2. Plug the XBee USB adapter into your computer using the mini-USB cable provided.

  3. Open XCTU.

  4. Make sure you are in Configuration working mode.

  5. Click Discover radio modules from the toolbar.

  6. In the Discover radio devices dialog, select the serial port(s) in which you want to look for radio modules. If you do not know the serial ports where your modules are attached, select all ports. Click Next

  7. In the Set port parameters window, maintain the default values and click Finish.

  8. As XCTU locates radio modules, they appear in the Discovering radio modules… dialog box. Once the discovery process has finished, click Add selected devices.

  9. At this point, you should see something like this in the Radio Modules section on the left:

The port number and MAC address do not necessarily have to be equal as shown in the picture.

3. Configure the XBees

  1. Restore the default settings of all XBees with the Load default firmware settings button at the top of the Radio Configuration section.

  2. Use XCTU to configure the following parameters:

    ID20152015Defines the network that a radio will attach to. This must be the same for all radios on your network.
    CECoordinator [1]Defines the role of the XBee module.
    A10110b [6]Auto-associate (bit 2)
    Scan channels for matching coordinator (bit 1) 
    A2110b [6]Allow End Device association (bit 2)
    Allow channel reassignment (bit 1)
    SMCyclic Sleep Remote [4]Enables the cyclic sleep remote mode. Sleep on a schedule determined by SP and ST.
    STC8C8Defines the period of inactivity before going to sleep for sleeping devices (hider).
    C8 (hexadecimal) = 200 (decimal) x 1 = 200 milliseconds. This value must be the same for both XBees.
    SP1414Defines the duration of time spent sleeping for sleeping devices (hider).
    14 (hexadecimal) = 20 (decimal) x 10 = 200 milliseconds. This value must be the same for both XBees.
    DPC8Defines the period to re-associate.
    C8 (hexadecimal) = 200 (decimal) x 10 = 2 seconds.
    APAPI enabled w/PPP [2]Enables API mode with escaping.
    D7Disabled [0]Seeker DIO7 is connected to RESET on the Arduino. This is used to hold the Arduino in reset when the XBee module is sleeping. This reset functionality is unnecessary for the sample application and can cause unintended Arduino reboots when remote nodes are unresponsive.

    — keep the default value.

  3. Write the settings of all XBees with the Write radio settings  button at the top of the Radio Configuration section.

Record the values of SH and SL of the hider. You will use these in the Arduino sketch later.

 What do these settings do (more details)?

In all XBee networks, it is important that the modules involved agree on the settings that define how they communicate. The default configuration of a Series 1 XBee module is to use peer-to-peer mode. In that mode, all modules must be configured by the user, in advance, using a tool such as XCTU to matching PAN ID (ID) and channel (CH) settings. In peer-to-peer mode the radios must be available to communicate at all times, so must always be awake and fully powered.

In this activity, the radios are mobile and may not have a power outlet nearby. While they could still be used in peer-to-peer mode, this would use more power. In what is known as NonBeacon mode, it is possible for some of the modules to sleep, thus consuming significantly less power.

In NonBeacon mode, there is one node which must remain powered at all times so that it can be available to the sleeping nodes whenever they wake up. This node is the coordinator. In this example we have made the seeker the coordinator by specifying CE = 1 for that device.

No longer must the nodes of the network agree on a common ID and CH in advance, they can be configured to get missing information from a coordinator in a process called association. The A1 setting (on the end devices) and the A2 setting (on the coordinator) determine which information the modules will use to find a coordinator to associate with. With the A1 and A2 settings configured in this example the PAN ID is determined in advance by explicitly specifying a value for the ID parameter. The coordinator and end devices will determine the channel without needing CH to be configured on either.

The SM value tells the end device that it can sleep. Radios can sleep in a number of ways, but the one used here is on a simple periodic schedule. The SM value tells the radio to perform "Cyclic Sleep" as determined by the ST and SP values.

The coordinator must always be powered.

The coordinator must always be powered. By adjusting the sleep settings, you can make a configuration where the hiding unit can remain hidden and operational for long periods of time efficiently. Only power the seeking unit when playing for the longest battery life.

4. Connect the components

  1. Create the following two circuits with your components and XBee breadboard adapters.

    LEDs have a polarity and their orientation in the circuit matters. Ensure that the cathode (short leg) of the LED is connected to the same column on the breadboard as the resistor to ground.


    Click to expand diagram


    Ensure that each wire is connected to the same column on the breadboard as the indicated pin of the XBee breadboard adapter footprint. This will ensure that the signals to the XBee are correct. In this example, all that needs connecting is power.

    Click to expand diagram
  2. Insert the hider XBee into an XBee breadboard adapter. Push down firmly on the XBee to ensure they are seated properly on the adapter board. Do not be afraid to use a little force.
  3. Insert the hider XBee breadboard adapter into the hider breadboard. Push down firmly on the breadboard adapter to ensure it is seated properly on the breadboard.
  4. Insert the seeker XBee into the XBee Shield.

  5. Verify that the breadboard adapter and XBee are positioned in the correct location and oriented the same as the image below. Incorrect placement has the potential to result in damage to components.


    Click to expand diagram

5. Put it all together

Program the Arduino

  1. Connect the USB cable between the computer and the Arduino.
  2. Download and extract the latest zip archive from the XBee/Arduino Compatible Coding Platform release page.
  3. Open the Arduino IDE.
  4. From the File menu select Open.
  5. Browse to the rssi_seek folder in the extracted zip archive, and select the rssi_seek.ino file. Click Open.
  6. Find the line below in the sketch and edit the address to match the address of your hider XBee (the SH and SL values).

  7. Press the Upload button to program the Arduino.
  8. Disconnect the USB cable.

Power things up

Apply power using the 9V battery clips and batteries.

6. Play the game

  1. Have one person hide the hider.

  2. Have another person use the seeker to see if s/he can find the hiding location. More lit LEDs indicate a better signal.

7. Troubleshooting

If you are encountering problems, these suggestions may help:

 How do I find the serial port of my module?

You can remove the XBee Grove Development Board from the USB port and see which port name disappears from your port list. The name that disappears is your XBee board.

Many people figure out which port is right via trial and error, but you can also use XCTU to find it:

  1. Open XCTU and discover the radio modules attached to your computer by clicking  on the top-left corner.
  2. Select all ports to be scanned.
  3. Click Next and then Finish.
  4. Once the discovery process has finished, a new window notifies you how many devices have been found and their details. The serial port and the baud rate are shown in the Port label.
 An error saying that the port is already in use by other applications is displayed.

The serial port where the local XBee module is connected can only be in use by one application. Check that the connection with the module in the XCTU console is closed and there are no other applications using the port.

 The error 'Device driver software was not successfully installed' is displayed.

Sometimes when you connect the XBee Grove Development Board into you computer, the operating system cannot install the driver automatically. If you get that error, try to remove and re-insert the board into your computer. If the OS is still unable to install the driver, remove and re-insert the board into another USB port.

As a last resort, install manually the USB drivers following the instructions that appear in the step 4 of the Downloading and installing XCTU section.

 How can I physically identify the XBee modules?

Once you have added the modules to XCTU, a simple way to identify them is to read the radio settings of each one and check the Rx and Tx LEDs of the XBee Grove Development Boards. These LEDs indicate that the XBee module is receiving (Rx) or transmitting (Tx) information through the serial port.

When you read or write the settings of a module, its Rx and Tx LEDs blink, so you can identify which module is connected to each serial port.

 An error is reported when installing XCTU.

XCTU requires Administrator permissions

Check that you have Administrator access on the machine where you are installing XCTU. On Windows systems, a User Account Control dialog may appear when you install XCTU or try to run the XCTU program. You must answer yes when prompted to allow the program to make changes to your computer, or XCTU will not work correctly. Note that you may also need to talk to your network manager to gain permission to install or run applications as administrator.

 No radios are found when discovery is performed or no serial ports are listed.

Check cables

Double check all cables. The USB cable should be firmly and fully attached to both the computer and the XBee Grove Development Board. When attached correctly, the association LED on the adapter will be lit.

Check that the XBee is fully seated in the XBee Grove Development Board

When the XBee is correctly installed, it should be pushed fully into the board and no air or metal should be visible between the plastic of the adapter socket and the XBee headers. Also, double check that all ten pins on each side of the XBee made it into a matching hole in the socket.

Check the XBee orientation

The angled "nose" of the XBee should match the lines on the silk screening of the board and point away from the USB socket on the XBee Grove Development Board.

Check driver installation

Drivers are installed the first time the XBee Grove Development Board is plugged in. If this process is not complete or has failed, try the following steps:

  1. Remove and re-insert the board into your computer. This may cause driver installation to re-occur.
  2. Remove and re-insert the board into another USB port.
  3. (Windows) Open Computer management, find the failing device in the Device Manager section and remove it.
  4. You can download drivers for all major operating systems from FTDI for manual installation.

Check if the modules are sleeping

The On/Sleep LED of the XBee Grove Development Board indicates if the module is awake (LED on) or asleep (LED off). When a module is sleeping, it cannot be discovered in XCTU, so press the Commissioning button and will wake up for 30 seconds.

 After resetting an XBee to factory defaults, XCTU reports errors for the KY and DD settings.

This is a known issue with the 6.1.2 versions of XCTU or less.

When the Invalid settings dialog appears, it is safe to continue to write settings.

  • AES Encryption Key (KY) is a setting that must be set by the user when encryption is used and does not apply with factory settings.
  • Device Type Identifier (DD) is a diagnostic parameter which is not used in the operation of the radio and can safely be set to any value.
Circuit assembly
 Do I need to match the wire colors used in the diagrams?

No, in many of the diagrams the color of the wires indicates something unique about its role in the circuit such as power, ground, and so forth. However, the color does not matter when assembling the circuit.

My circuit doesn't work
 Things to check first.

Is everything fully inserted?

Make sure that all components are fully inserted into the breadboard, sockets or connectors. When connecting, ensure that the wire or headers are aligned correctly and push firmly and evenly on the part. Header pins on the XBee or breadboard carrier boards should insert fully such that the plastic molding sits flush with the socket or board.

Do wires connect to the correct pins?

Check the diagram against the circuit that you have built. It can be easy to place wires so that they are one row off from the desired location. If you have any questions about which portions of the breadboard are connected, check out How to use a breadboard which describes the anatomy of a breadboard. This will help you to understand component placement in each game.

Are all XBees configured correctly?

Make sure that the configuration of each XBee matches the settings provided in the instructions. Before you configure the XBee, restore each module's default settings using the factory defaults button at the top of the Radio Configuration section.

 An LED does not light when expected.

Check LED polarity

An LED has a correct installation direction. When installed backwards it will not light when expected. The long leg of the LED (anode) must be provided with a higher voltage than the short leg (cathode). In most of the projects, the cathode is connected to ground and the voltage to the anode is controlled by connecting it to a digital output on the XBee or Arduino.

Another way to identify the cathode if you've clipped the wires, or want to check while it is installed is to look at the colored plastic housing. Many LEDs will make the body flat on the cathode side as well.

Check resistor

Resistors are placed in series with each LED to ensure that it does not receive too much current. Compare the stripes on the resistor being used to check that you are using the correct resistor. The resistors in these games are 330Ω and should have stripes that are orange-orange-brown.

 Do you get an error when uploading code to the Arduino?

If the Arduino IDE displays the message "Problem uploading to board." after you click Upload, enable the option "Show verbose output during upload" in the preferences (File menu > Preferences):

Click Upload again, and find the error message that appears above the line Problem uploading to board. See for suggestions.

Does the error message read "avr_dude: ser_send(): write error: sorry no info avail"?

This error appears occasionally on 64-bit versions of Windows. In order to upload code successfully to the Arduino, you must reset the Arduino at a specific time during the upload.

  1. In the Arduino IDE, click Upload.
  2. Press and hold the RESET button on the Arduino board.
  3. Release the RESET button on the Arduino board when messages like the following appear in the Arduino message window:

  4. After the code is uploaded to the Arduino, the following message appears at the bottom of the window:

Learn more

For more information about the hardware and software you use in this activity, see:

  • No labels