Xbee + Accelerometer + Processing

Hello all!

I am having an issue with some connections and hoping to find some help with that.

I have an ADXL335 accelerometer connected to an XBEE series 2 (configured as Router AT), and another XBEE series 2 (configured as a Coordinator API) mounted on an Arduino R3 via Xbee Pro shield.

On the Router side, the DIO0, DIO1, DIO2, are connected to the ADXL335 X,Y,Z jacks and configured as ADC.

The Xbees are communicating information, which means values are showing up in my arduino Serial Monitor , however, i am completely lost as to how to separate the bytes of information that i am receiving, i.e. how do i separate the DIO0, DIO1, DIO2 inputs from the Xbee to X,Y,Z, float values in my serial monitor. My plan is to then read those values into Processing.

Here's the code in Arduino just to basic read inputs from the Xbee:

void setup() {
Serial.begin(9600);

}

void loop() {

if (Serial.available() >= 21) { // Wait until we have a mouthful of data

if (Serial.read() == 0x7E) { // Start delimiter of a frame

// Skip over the bytes in the API frame we don't care about
for (int i = 0; i < 18; i++) {
Serial.read();
}

// The next two bytes are the high and low bytes of the sensor reading
float analogHigh = Serial.read();
float analogLow = Serial.read();
float analogValue = analogLow + (analogHigh * 256);

Serial.println(analogValue);
}
}
}

Hopefully that's enough info, would be a gigantic step if anyone could help.

thanks!

// The next two bytes are the high and low bytes of the sensor reading
      float analogHigh = Serial.read();
      float analogLow = Serial.read();
      float analogValue = analogLow + (analogHigh * 256);

Serial.read() doesn't return a float. So, why are you storing the int in a float?

however, i am completely lost as to how to separate the bytes of information that i am receiving, i.e. how do i separate the DIO0, DIO1, DIO2 inputs from the Xbee to X,Y,Z, float values in my serial monitor.

Here's a clue:

      // Skip over the bytes in the API frame we don't care about
      for (int i = 0; i < 18; i++) {
        Serial.read();
      }

That's wrong. You DO care.

Part of the data that you are skipping includes how long the message is (not all messages are the same length), flags that indicate the source of the data (was it from digital pin x or analog pin x), etc.

Just skipping over it is the wrong thing to do. Doing so is fine IF the packet contains only one kind of data from one source. That is not the case for you.