Trouble with a pair of XBees

All things pertaining to wireless and RF links

Moderator: phalanx

Post Reply
Posts: 2
Joined: Wed May 16, 2018 7:02 pm

Trouble with a pair of XBees

Post by twwg » Wed May 16, 2018 7:26 pm

I have a pair of XBee Series 2 radios which are causing me fits.

2x XBee radios, Series 2
- Latest Firmare
- One acting as a Coordinator and the other as a Router
- Product Family: XB24-ZB
- Function Set: ZigBee {Coordinator, Router} AT
Sparkfun RedBoard
Sparkfun XBee shield
Sparkfun Wireless Joystick kit

Arduino Code:

Code: Select all


Set up a software serial port to pass data between an XBee Shield
and the serial monitor.

Hardware Hookup:
  The XBee Shield makes all of the connections you'll need
  between Arduino and XBee. If you have the shield make
  sure the SWITCH IS IN THE "DLINE" POSITION. That will connect
  the XBee's DOUT and DIN pins to Arduino pins 2 and 3.

// We'll use SoftwareSerial to communicate with the XBee:
#include <SoftwareSerial.h>

// XBee's DOUT (TX) is connected to pin 2 (Arduino's Software RX)
// XBee's DIN (RX) is connected to pin 3 (Arduino's Software TX)
SoftwareSerial XBee(2, 3); // RX, TX

void setup()
  // Set up both ports at 9600 baud. This value is most important
  // for the XBee. Make sure the baud rate matches the config
  // setting of your XBee.

  Serial.println("Starting Serial");

  Serial.println("Starting serial connection to XBee");


void loop() {
  if (Serial.available() > 0) { // If data comes in from serial monitor, send it out to XBee

  if (XBee.available() > 0) { // If data comes in from XBee, send it out to serial monitor
Wireless Joystick controller code:

Code: Select all

/* Wireless Joystick Tank Steering Robot Example
 * by: Alex Wende
 * SparkFun Electronics
 * date: 9/28/16
 * license: Creative Commons Attribution-ShareAlike 4.0 (CC BY-SA 4.0)
 * Do whatever you'd like with this code, use it for any purpose.
 * Please attribute and keep this license.
 * This is example code for the Wireless Joystick to control a robot
 * using XBee. Plug the first Xbee into the Wireless Joystick board,
 * and connect the second to the SparkFun Serial Motor Driver.
 * Moving the left and right joystick up and down will change the
 * speed and direction of motor 0 and motor 1. The left trigger will
 * reduce the maximum speed by 5%, while the right trigger button
 * will increase the maximum speed by 5%.
 * Connections to the motor driver is as follows:
 * XBee - Motor Driver
 *   5V - VCC
 *  GND - GND
 * DOUT - RX
 * Power the motor driver with no higher than 11V!

#define L_TRIG 6        // Pin used for left trigger
#define R_TRIG 3        // Pin used for right trigger
#define L_JOYSTICK A3   // Pin used for left joystick
#define R_JOYSTICK A0   // Pin used for right joystick

int8_t speedLevel = 20; //Maximum speed (%) = speedLevel * 5 (units are percent)

void setup() {  
  Serial1.begin(9600); // Start serial communication with XBee at 9600 baud

  Serial1.print("W7001\r\n"); // Set the bit in enable register 0x70 to 0x01

  pinMode(L_TRIG,INPUT_PULLUP); // Enable pullup resistor for left trigger
  pinMode(R_TRIG,INPUT_PULLUP); // Enable pullup resistor for right trigger

void loop() {
  int16_t leftStick, rightStick;    // We'll store the the analog joystick values here
  char buf0[10],buf1[10]; // character buffers used to set motor speeds

  // Reduce top speed
  if(digitalRead(L_TRIG) == 0)
    speedLevel -= 2;
    if(speedLevel < 2) speedLevel = 2;
    while(digitalRead(L_TRIG) == 0)
  // Increase top speed
  if(digitalRead(R_TRIG) == 0)
    speedLevel += 2;
    if(speedLevel > 20) speedLevel = 20;
    while(digitalRead(R_TRIG) == 0)

  // Read joysticks
  // Convert analog value range to motor speeds (in %)
  leftStick = (5-(analogRead(L_JOYSTICK)/93))*speedLevel;
  rightStick = (5-(analogRead(R_JOYSTICK)/93))*speedLevel;

  // Build motor 0 buffer
  if(leftStick > 0)

  // Build motor 1 buffer
  if(rightStick > 0)

  // Send motor speeds

When I connect one XBee to the Joystick controller, and the other to a Sparkfun USB XBee explorer, I can see the stream of commands from the controller to the other XBee in X-CTU. This confirms that the two can talk to each other just fine.

I followed the Sparkfun XBee shield hookup guide here: ... okup-guide. I have the switch on the shield set to DLINE. I have connected one of the XBees to the joystick controller, and the other to the XBee shield.

The problem is that I am not seeing anything on the Arduino Serial Monitor as described in the Hookup guide, except for the two lines which get printed out by the setup function.

Posts: 2
Joined: Wed May 16, 2018 7:02 pm

Re: Trouble with a pair of XBees

Post by twwg » Mon May 21, 2018 12:36 pm

Here's an update.

I purchased a pair of Series 1 radios, on the off chance that something in the slightly more complex feature set was causing a problem. No dice.

I connected a Digilent Analog Discovery 2 (first real use of this, and it was slick) to pins 2 and 3, which are supposed to be connected to DIN and DOUT on the XBee on the XBee Shield. Nothing.

Next, I connected the XBee to an XBee breakout I had lying around, to the AD2, with 3.3v and GND, and two digital connections, I could verify the radio was working just fine. I switched it over to directly connect the breakout to the Arduino, and everything started working the way I expected.

I then went back and did continuity tests on the XBee shield between DIN and DOUT with the headers, and nothing appeared to be connected to either of those pins.

I suspect I have a broken shield, or I have severely misunderstood how the shield is supposed to work. In the meantime, we are bypassing the XBee shield, and just using the breakout board. It's more janky than the shield, but it's better than nothing.

Could someone else who has a Sparkfun XBee Shield which is working verify that DIN and DOUT on the XBee connect to pins 2 and 3 on the Arduino headers?


Post Reply