Accelerometer (ADXL377) to XBee connection issue

Hello,

I am having trouble verifying the connection between the accelerometer and xbee transmitter.

So far I have been able to get data from the accelerometer when it is just connected to my arduino mega, which is connected to the computer.

The issue I am having is with the connection between the accelerometer and xbee(S1).
My transmitter module consists of the accelerometer connected to the xbee through a sparkfun breakout board (xbee explorer), which is powered by the computer.

The pin connections between the two devices are as follows (x->DIO0, y->DIO1, etc) : (ADXL377: x, y, z, Vin, Gnd // XBee: DIO0, DIO1, DIO2, 3.3V, Gnd)

My receiver module consists of an Xbee on another Xbee explorer, which is connected to an arduino mega 2560.

The main problem I am having is with the code. Using SoftwareSerial, I was able to see that the receiving module is receiving some data from the transmitter module with the accelerometer, but with the following code I’m unable to actually verify the data and get any sort of useful count out of it.

Any help on the following code is helpful!

My code on the receiving end is as follows.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 12); // RX, TX
int x , y , z;
int analogHigh, analogLow ;
int i;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
delay(100);
}
void loop() // run over and over
{
readADC();
}
void readADC(){
if (mySerial.available() <= 18) {
// Start Bit
if (mySerial.read()==0x7E)
// read the value we do not need out of the buffer
for(i=1 ; i<=18; i++){
// x-value
if(14){
x = Serial.read();
Serial.print(“x-count: “);
Serial.print(x, DEC);
Serial.println(”\t”);
}
// discard all other bits
else{
byte discard = Serial.read();
}
}
}
}

Please stop cross-posting. Replies go here.