SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By twwg
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.
By twwg
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?

User avatar
By pdm
Did you ever get it to work ? If so, I would be curious to hear what was wrong. I have a fairly large collection of Redboards, XBee shields, and XBee S2C modules, all of which have worked perfectly together since I got them for my project.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]