Skip to end of metadata
Go to start of metadata

In this activity, you create a multiplayer bomb defuser game.

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

1. Requirements

Hardware

Three XBee 802.15.4 modules
 

One Arduino Leonardo


One XBee Shield


Two XBee breadboard adapters

One XBee USB adapter


to configure the XBees

Two solderness breadboards
 

Two LEDs

Two 330Ω resistors



Jumper wires

Two 9V battery clips


Two 9V batteries

 

Two breadboard power supplies

One micro USB cable


One min USB cable

Steps

Software

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

Select two of the XBee modules to be the remote modules. The third and final module will be connected to the Arduino, and we refer to it as the local XBee.

  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:

    Param110px|Local XBee110px|Remote XBee 1110px|Remote XBee 2Effect
    CHCCCDefines the frequency to use to communicate. This must be the same for all radios on your network.
    ID201520152015Defines the network that a radio will attach to. This must be the same for all radios on your network.
    DH00DH and DL combined form the destination address. This is where the notifications are sent when the button value changes. The address being configured here is known as a short address. A short address is assigned during configuration. An XBee also has a long address (SH and SL combined) which is assigned permanently when the unit is manufactured.
    DL12341234
    MY123412351236Defines the XBee's short address.
    APAPI enabled w/PPP [2]Enables API mode with escaping.
    D0DI [3]DI [3]Sets the DIO0/AD0 pin as digital input in the remote XBees. This pin is connected to GND.
    D1DI [3]DI [3]Sets the DIO1/AD1 pin as digital input in the remote XBees. This pin is connected to GND.
    D2DI [3]DI [3]Sets the DIO2/AD2 pin as digital input in the remote XBees. This pin is connected to GND.
    D3DI [3]DI [3]Sets the DIO3/AD3 pin as digital input in the remote XBees. This pin is connected to GND.
    D7DO Low [4]DO Low [4]Sets the DIO7 pin as digital output low in the remote XBees. This pin is connected to an LED.
    IC0F0FConfigures the remote XBees to transmit an I/O sample when any pin changes.
    00001111 (binary) = 0F (hexadecimal) 

    — 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.

4. Connect the components

  1. Create the following circuit with each of the XBee breadboard adapters.

    Ensure that you connect each wire to the same column on the breadboard as the indicated pin of the XBee breadboard adapter footprint. This ensures that the signals to the XBee are correct.

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

    Click to expand diagram

  2. Push down firmly on each breadboard adapter to ensure they are seated properly on the breadboards.
     
  3. Insert the remote XBees into the breadboard adapters. Push down firmly on each XBee to ensure they are seated properly on the adapter boards. Do not be afraid to use a little force.
     
  4. Double check that the breadboard adapters and XBees are positioned in the correct location and oriented the same as the image below.
    Incorrect placement can result in damage to components.

    Click to expand diagram

5. Put it all together

  1. Place the local XBee on the XBee Shield connected to the Arduino.

  2. Apply power to the remote XBees using the 9V battery clips and batteries.

  3. Connect the Arduino to your computer using the micro USB cable.

  4. Download and extract the latest zip archive from the XBee/Arduino Compatible Coding Platform release page.

  5. Open the Arduino IDE.

  6. From the File menu select Open.

  7. Browse to the bombgame folder in the extracted zip archive, and select the bombgame.ino file. Click Open.

  8. Find the following section at the top of the file and modify it to include the MY values for your remote nodes.

  9. Press Upload to upload the sketch to the Arduino and run it.

6. Play the game

  • Disconnect one of the jumper wires (connected to DIO0-3) on player 1's board from ground.
  • Disconnect a different jumper wire on player 2's board. If player 2 pulls the same wire, they lose (the bomb "explodes" and the LED lights up).
  • Disconnect yet another wire on player 1's board and continue disconnecting wires, each player pulling one wire at a time, until the bomb "explodes." 
  • Once the bomb has exploded, do the following to restart the game:
    • Reconnect all jumper wires on each of the bombs.
    • Press the Reset button on the Arduino.

7. Troubleshooting

If you are encountering problems, these suggestions may help:

General
 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.

XCTU
 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.

Arduino
 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 http://www.arduino.cc/en/Guide/Troubleshooting#upload 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