Displaying Data on Serial Monitor using Xbee, Sensor, and Lilypad Simple board

Hi there,

I have been have trouble getting data to display on the serial monitor for a sensor relaying data to a PC via Xbees. I am using 2 Xbees (series 1), a Lilypad Arduiono Simple board, and a Lilypad Xbee. The sensor is a 6 degree of freedom IMU (SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 - SEN-10121 - SparkFun Electronics). I have one Xbee connected to my PC using an Xbee Explorer Dongle and the other is wired to the unit with the sensor like this:

Xbee on Lilypad Xbee
Lilypad Xbee connected to Lilypad Simple:
Rx --> pin 6
Tx --> pin 5
(+)--> (+)
(-)--> (-)

I know the IMU is wired and working correctly, because I can see the serial monitor displaying the data. The problem occurs when I look at the serial monitor associated with the com port of the PC-Xbee device. I also know the Xbees are configured properly because when I send a message from the one connected to the PC to the remote Xbee, the LED on the Lilypad Xbee lights up, indicating a received signal.

I don't know if the problem is in my code which is:

#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <SoftwareSerial.h>
#define DEBUG
#ifdef DEBUG
#include "DebugUtils.h"
#endif
#include "CommunicationUtils.h"
#include "FreeSixIMU.h"
#include <Wire.h>
// Set the FreeIMU object
FreeSixIMU my3IMU = FreeSixIMU();

SoftwareSerial xbee(5,6); //Rx, Tx 
/* Telling the Arduino Simple what the Rx and Tx Pins are*/

float q[4]; //hold q values
float SDOFvalues[6];

void setup() {
  Serial.begin(9600); 
  Wire.begin();
  xbee.begin(9600);
  Serial.println("Serial ready");
  xbee.println("Xbee ready");
  
  //delay(5);
  my3IMU.init();
  //delay(5);
}


void loop() { 
  //my3IMU.getQ(q);
  //serialPrintFloatArr(q, 4);
  my3IMU.getValues(SDOFvalues);
  Serial.print("Rot X: ");
  /*char a = */ Serial.print(SDOFvalues[0]);
  Serial.print(" Rot. Y: ");  
  /*char b = */Serial.print(SDOFvalues[1]);
  Serial.print(" Rot. Z: ");
  /*char c = */Serial.print(SDOFvalues[2]);
  Serial.print(" Accel X: ");
  /*char d = */Serial.print(SDOFvalues[3]);
  Serial.print(" Accel Y: ");
  /*char e = */Serial.print(SDOFvalues[4]);
  Serial.print(" Accel Z: ");
  /*char f = */Serial.println(SDOFvalues[5]);

   if(xbee.available()){
     char IMU = xbee.read();
     Serial.write(IMU);
   }
   if (Serial.available()){
     char IMU = (char)Serial.read();
     xbee.write(IMU); 
   }
}

If anyone knows what I'm doing wrong, I'd really appreciate any help and advice with this. Thanks a lot!

These:

Rx --> pin 6
Tx --> pin 5

and

SoftwareSerial xbee(5,6); //Rx, Tx

don't seem to agree.

Try swapping the wires or the values in the call.

Thanks, but after I tried both swapping the wires and the code values I still can't view the data on the serial monitor from the Xbees.

Am I using this piece of code correctly?

if(xbee.available()){
     char IMU = xbee.read();
     Serial.write(IMU);
   }
   if (Serial.available()){
     char IMU = (char)Serial.read();
     xbee.write(IMU); 
   }

Am I using this piece of code correctly?

Yes. Though one usually uses print() for character data. But, the print() method ends up calling the write() method, so what you have works.