Accelerometer (ADXL377) to XBee connection issue


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:
// set the data rate for the SoftwareSerial port
void loop() // run over and over
void readADC(){
if (mySerial.available() <= 18) {
// Start Bit
if (
// read the value we do not need out of the buffer
for(i=1 ; i<=18; i++){
// x-value
x =;
Serial.print(“x-count: “);
Serial.print(x, DEC);
// discard all other bits
byte discard =;

Please stop cross-posting. Replies go here.