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.
2. Add the XBees to XCTU
Ensure that the XBee is seated firmly in the XBee USB adapter.
Plug the XBee USB adapter into your computer using the mini-USB cable provided.
Make sure you are in Configuration working mode.
Click Discover radio modules from the toolbar.
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.
In the Set port parameters window, maintain the default values and click Finish.
As XCTU locates radio modules, they appear in the Discovering radio modules… dialog box. Once the discovery process has finished, click Add selected devices.
- 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
- Restore the default settings of all XBees with the Load default firmware settings
Use XCTU to configure the following parameters:
Param 110px|Seeker 110px|Hider Effect ID 2015 2015 Defines the network that a radio will attach to. This must be the same for all radios on your network. CE Coordinator  — Defines the role of the XBee module. A1 — 0110b  Auto-associate (bit 2)
Scan channels for matching coordinator (bit 1)
A2 110b  — Allow End Device association (bit 2)
Allow channel reassignment (bit 1)
SM — Cyclic Sleep Remote  Enables the cyclic sleep remote mode. Sleep on a schedule determined by SP and ST. ST C8 C8 Defines 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.
SP 14 14 Defines 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.
DP — C8 Defines the period to re-associate.
C8 (hexadecimal) = 200 (decimal) x 10 = 2 seconds.
AP API enabled w/PPP  — Enables API mode with escaping. D7 Disabled  — 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.
- 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.
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
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
- 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.
- 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.
- Insert the seeker XBee into the XBee Shield.
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
- Connect the USB cable between the computer and the Arduino.
- Download and extract the latest zip archive from the XBee/Arduino Compatible Coding Platform release page.
- Open the Arduino IDE.
- From the File menu select Open.
- Browse to the
rssi_seekfolder in the extracted zip archive, and select the
rssi_seek.inofile. Click Open.
Find the line below in the sketch and edit the address to match the address of your hider XBee (the SH and SL values).
- Press the Upload button to program the Arduino.
- Disconnect the USB cable.
Power things up
Apply power using the 9V battery clips and batteries.
6. Play the game
Have one person hide the hider.
- Have another person use the seeker to see if s/he can find the hiding location. More lit LEDs indicate a better signal.
If you are encountering problems, these suggestions may help:
For more information about the hardware and software you use in this activity, see: