Garbled data output from sensor through XBEE?

I have a fio v3 + a 9DOF sensor hooked up to an XBEE. On another UNO board, I have a GSM shield and another XBEE board.

The fiov3 is supposed to sample data from the sensor, send it through the xbee. The receiving XBEE will then receive and pass the data to the UNO. The UNo then activates the GSM shield on condition.

However my resulting output on the UNO is as shown :



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.

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


#include <SPI.h> // Included for SFE_LSM9DS0 library
#include <Wire.h>
#include <SFE_LSM9DS0.h>

#define LSM9DS0_XM  0x1D // Would be 0x1E if SDO_XM is LOW
#define LSM9DS0_G   0x6B // Would be 0x6A if SDO_G is LOW
// Create an instance of the LSM9DS0 library called `dof` the
// parameters for this constructor are:
// [SPI or I2C Mode declaration], [gyro I2C address], [xm I2C address]

const byte INT1XM = 4; // INT1XM tells us when accel data is ready
//const byte INT2XM = 8; // INT2XM tells us when mag data is ready
//const byte DRDYG = 7;  // DRDYG tells us when gyro data is ready
const int buttonPin = 15;     // the number of the pushbutton pin

int buttonState = 0;    

void setup(){

  pinMode(INT1XM, INPUT);
  //pinMode(INT2XM, INPUT);
  // pinMode(DRDYG, INPUT);
  pinMode(buttonPin, INPUT);  


  Serial.begin(115200); // Start serial at 115200 bps
  // Use the begin() function to initialize the LSM9DS0 library.
  // You can either call it with no parameters (the easy way):

  uint16_t status = dof.begin();
  // Or call it with declarations for sensor scales and data rates:  
  //uint16_t status = dof.begin(dof.G_SCALE_2000DPS, dof.A_SCALE_6G, dof.M_SCALE_2GS);

  // begin() returns a 16-bit value which includes both the gyro and
  // accelerometers WHO_AM_I response. You can check this to make sure
  // communication was successful.
  // Serial.println(status, HEX);


void loop(){


   buttonState = digitalRead(buttonPin);

  if (buttonState == 1) {   

    //  Serial1.println("Hello!"); 


  //if (Serial1.available()){
     // Serial.write(;
//  }


void printAccel()
  // Only read from the accelerometer if the accel interrupts,
  // which means that new data is ready.
  if (digitalRead(INT1XM))
    // Use the readAccel() function to get new data from the accel.
    // After calling this function, new values will be stored in
    // the ax, ay, and az variables.

    Serial.print("A: ");

    // Using the calcAccel helper function, we can get the
    // accelerometer readings in g's.
    Serial.print(", ");
    Serial.print(", ");

    Serial1.print("A: ");

    // Using the calcAccel helper function, we can get the
    // accelerometer readings in g's.
    Serial1.print(", ");
    Serial1.print(", ");


It looks like you might have a second data stream being mixed in with the accelerometer data. Do you by chance have a third XBee that might be sending a different data stream to the receiving XBee?

Can you look at the output data of the Fio, and make sure it's going into the sending XBee correctly?

Can you look at the output of the receiving XBee and see if it's coming out correctly?

If you have an FTDI cable plugged into your computer, you can just hook up ground to the device ground, and put a wire on the input data pin of the cable and probe the comm lines - any output should show up in a terminal emulator on your computer.

The XBees need time to do packet acknowledgement, etc. You are jamming data out faster than the XBees can send it. Add a small delay (like 10 milliseconds) after sending the accelerometer data before you send again. See it that doesn't help the situation.