Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Multiexcerpt include
nopaneltrue
MultiExcerptNameonlyTroubleshootingInfo
DisableCachingtrue
PageWithExcerptRFKitsCommon:More excerpts

Numbered Headings
skip-headingsh3, h4
start-numbering-ath2
Section
Column

Requirements

Panel
borderColor#efefef
bgColorwhite
titleBGColor#efefef
borderWidth0
titleHardware

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

Column
width325px
Panel
borderColorwhite
bgColor#efefef
titleColorwhite
titleBGColor#4f5454
borderWidth2
borderStylesolid
titleSteps

Table of Contents
maxLevel2
minLevel2
stylenone
classtoc

Panel
borderColor#efefef
bgColorwhite
titleBGColor#efefef
borderWidth0
titleSoftware

Multiexcerpt include
nopaneltrue
MultiExcerptNamearduinoSoftwareRequirements
DisableCachingtrue
PageWithExcerptMore excerpts

Multiexcerpt include
nopaneltrue
MultiExcerptNameXCTUWalktroughTip
DisableCachingtrue
PageWithExcerptRFKitsCommon:More excerpts

Add the XBees to XCTU

Include Page
Add the XBees to XCTU
Add the XBees to XCTU

Configure the XBees

  1. Multiexcerpt include
    nopaneltrue
    MultiExcerptNamerestoreDefaultsInfo
    DisableCachingtrue
    PageWithExcerptRFKitsCommon:More excerpts


  2. Use XCTU to configure the following parameters:

    Param110px|Seeker110px|HiderEffect
    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. Multiexcerpt include
    nopaneltrue
    MultiExcerptNamewriteSettingsInfo
    DisableCachingtrue
    PageWithExcerptRFKitsCommon:More excerpts
Info

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

Expand
titleWhat 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.

Info
titleThe 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.

Connect the components

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

    Note

    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.

    Seeker

    Click to expand diagram

    Hider

    Note

    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.

    Hider


    Click to expand diagram

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
    Digi external link macro
    nameXBee/Arduino Compatible Coding Platform release
    hrefhttps://github.com/digidotcom/XBeeArduinoCodingPlatform/releases
    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).

    Code Block
    themeEclipse
    languagecpp
    // The address of the remote XBee that we're seeking
    XBeeAddress64 remote = XBeeAddress64(0x0013a200, 0x40c179e2);
  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.

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.

Troubleshooting

If you are encountering problems, these suggestions may help:

Include Page
Troubleshooting
Troubleshooting

Learn more

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

  • Digi external link macro
    nameUsing XCTU to configure an XBee
    href../XCTU/Configure+your+modules
  • Digi external link macro
    nameMore about 802.15.4 networks
    hrefhttp://en.wikipedia.org/wiki/IEEE_802.15.4
  • Digi external link macro
    nameMore about XBee digital I/O
    href../WirelessConnectivityKit/Ins+and+Outs
  • Digi external link macro
    nameMore about breadboards
    hrefhttps://learn.sparkfun.com/tutorials/how-to-use-a-breadboard
  • Digi external link macro
    nameConnecting power
    hrefhttps://learn.sparkfun.com/tutorials/how-to-power-a-project
  • Digi external link macro
    nameWiring an LED
    hrefhttps://learn.sparkfun.com/tutorials/light-emitting-diodes-leds