No Communication with Two XBee Series 1's Point to Point + SoftwareSerial

I am currently building a rover that is controlled with a PS2 controller. The controller part works fine, and I am able to control the rover no problem with a direct wired connection. I am adding the XBee link in, and I've hit a snag. The problem is that my Xbee on the rover is not receiving any data, or that the controller is not transmitting it.

I've done the following things to isolate the issue:

  • As stated before, the controller interface portion works just fine.
  • The rover motor drivers are downstream and thus not a concern, but they work fine too.
  • I have attached the two XBee Series 1 modules to the arduino through the Adafruit Xbee Adapter (http://www.adafruit.com/products/126), and verified that they can talk to X-CTU just fine through the adapter.
  • Both XBee modules are receiving power when connected to their respective Arduinos.
  • Both XBee modules have the same PAN ID (default) and baud rate (9600).
  • Both XBee modules are programmed with the correct source and destination addresses via X-CTU

I suspect a code issue. This is my first time working with the SoftwareSerial Library. I am aware of the differences between the current one in Arduino 1.0 (based on NewSoftSerial) and the previous implementation. My code seems simple enough, but I'll be damned if I can figure out what is wrong. See the controller and rover code below.

//Wireless Robot Controller/Transmitter Code
//Input from a standard Playstation2 controller – Analog sticks used for motor speed
//Output to xBee

#include <PS2X_lib.h>
#include <SoftwareSerial.h>

//PS2 controller pins
#define ClkPin 10
#define CmdPin 9
#define AttPin 11
#define DatPin 8

//xBee pins
#define RxPin 2
#define TxPin 3

//create PS2X controller class
PS2X ps2x;

//create xBee serial port interface via software
SoftwareSerial xBee(RxPin, TxPin);

//create controller data array. Element [0] is x-axis, element [1] is y-axis.
byte controllerData[2] = {0, 0};


void setup() {

  //opens serial port
  Serial.begin(9600);
  
  //Opens SoftwareSerial Port to XBee
  xBee.begin(9600);

  //configs PS2 controller with previously-defined pins
  ps2x.config_gamepad(ClkPin, CmdPin, AttPin, DatPin);	

  delay(1000);

}//end setup


void loop() {

  //read controller
  ps2x.read_gamepad();

  //gets position from the y-axis of each analog controller stick
  controllerData[0] = ps2x.Analog(PSS_LY);
  controllerData[1] = ps2x.Analog(PSS_RY);

  //Print the stick position 

  if(controllerData[0] < 100 || controllerData[0] > 155) {
    Serial.print(controllerData[0]);
    xBee.print(controllerData[0]);
  }
  else{
    Serial.print("DEAD");
  }

  Serial.print(", ");

  if(controllerData[1] < 100 || controllerData[1] > 155) {
    Serial.println(controllerData[1]);
    xBee.print(controllerData[1]);
  }
  else{
    Serial.println("DEAD");
  }

  delay(50);

}//end loop
//Wireless Rover Code
//Input from xBee
//Output to Motor Controller

#include <SoftwareSerial.h>

//xBee pins
#define RxPin 2
#define TxPin 3

//create xBee serial port interface via software
SoftwareSerial xBee(RxPin, TxPin);


void setup() {

  //opens serial port
  Serial.begin(9600);   

  //Opens SoftwareSerial Port to XBee
  xBee.begin(9600);

}//end setup


void loop() {

  if (xBee.available() > 1) {
    
    int leftMotor = xBee.read();
    int rightMotor = xBee.read();

    Serial.print(leftMotor);
    Serial.print(", ");
    Serial.println(rightMotor);
  }

}//end loop

Appreciate any insight that you can give.

Both XBee modules are programmed with the correct source and destination addresses via X-CTU

Not that I don't trust you, but what are those values, for each XBee?

You are using SoftwareSerial::print() on the sender, which converts the value to a string to send.

You are expecting to read the while string AS AN INT on the receiver. Fail!

PaulS:
Not that I don't trust you, but what are those values, for each XBee?

You're right, I should have posted that initially. The configuration information for each xBee is attached.

PaulS:
You are using SoftwareSerial::print() on the sender, which converts the value to a string to send.

You are expecting to read the while string AS AN INT on the receiver. Fail!

Good catch. I'll update as soon as I get the damn things talking to one another.

xBee 1.PNG

xBee 2.PNG

I'll update as soon as I get the damn things talking to one another.

The only proof you seem to have that they are no talking to each other is that the receiver doesn't do what you expect it to do, based on the data sent. Or, did I miss something?

I've also seen no indication as to what connections you've made between the Adafruit adapters and the Arduinos.

PaulS:
The only proof you seem to have that they are no talking to each other is that the receiver doesn't do what you expect it to do, based on the data sent. Or, did I miss something?

Yup, I don't really have any other proof right now. I'm working on the loopback test using the X-CTU software right now, but I have yet to confirm that they communicated to one another at all.

The only thing I know 100% is that they can communicate Rx/Tx just fine with my PC through their wired serial interface via the Adafruit XBee adapter (plus the USB to FTDI adapter).

PaulS:
I've also seen no indication as to what connections you've made between the Adafruit adapters and the Arduinos.

Adafruit Tx -> Arduino Dig Pin 3
Adafruit Rx -> Arduino Dig Pin 2
Adafruit GND -> Arduino GND
Adafruit +5V -> Arduino 5V

That's about it for connections. I have wired both XBees in the exact same way.

OK, I have confirmed that the XBees will talk to one another when I place one in loopback mode (tie Tx and Rx pins together on Adafruit adapter), and run a range test on the X-CTU software with the other XBee connected to the PC. The Adafruit adapter also has a LED that lights whenever it's receiving data, so I was able to verify visually that both XBees are able to transmit and receive. Now it's just a matter of getting them to talk to the Arduinos.

Also, I've just confirmed that I can communicate via the hardware serial ports (pins 0 and 1) and output to the XBee with successful wireless communication.

Seems like I'm not implementing the SoftwareSerial library correctly.