Hi, I have 2 series 1 xbees. 1 is setup as a remote sensor connected to an ADXL335 accelerometer (pins 0,1 & 2). The other as a Coordinator connected to an arduino uno via a funduino XBee shield.
I have setup the XBees and am receiving data to my serial port (I have connected the Coordinator XBee to my PC via a USB breakout and opened a connection on XCTU. This shows that i am receiving consistent frames every 20ms)
When i use the follwing code uploaded to my arduino (At the top i have written my XBee settings)
/*XBee Setups
*** Configuration ***
SENDER: (REMOTE SENSOR RADIO)
ATCH -> C
ATID -> 3332
ATDL -> 1
ATMY -> 2
ATNI -> SENSOR
ATBD -> 3 (9600)
ATAP -> 2 (API enabled w/PPP
ATD0 -> 2 (ADC)
ATD1 -> 2 (ADC)
ATD2 -> 2 (ADC)
ATIR -> 14 (20ms)
CORDINATOR:
ATCH -> C
ATID -> 3332
ATDL -> 2
ATMY -> 1
ATNI -> COORDINATOR
ATBD -> 3 (9600)
ATAP -> 2 (API enabled w/PPP
*/
void setup()
{
Serial.begin(9600); //Begin serial connection
}
void loop()
{
if (Serial.available()>=17){ //Check for a full API packet
if (Serial.read() == 0x7E){//If start delimiter is read
for(int i = 0; i < 17; i++){ //For the rest of the frame
Serial.print(Serial.read(),DEC); //Print each Byte read
Serial.print(","); //Print a comma between each
}
Serial.println(); //Println so the next packet starts on the next line
}
}
}
I get what i believe are correct frames from which I can retrieve my analogue data interspersed with random frames
0,14,131,0,2,51,0,1,14,0,1,243,1,252,2,123,202
0,14,131,0,2,51,0,1,14,0,1,243,1,252,2,123,202
0,50,0,124,202,126,0,2,0,14,243,252,124,126,0,131,0
50,0,1,1,2,202,126,14,0,50,14,1,1,203,126,131,2
The top two shown above are what i expected, but then i will get a whole bunch of frames that do not look like what i’m expecting.
Any help in trying to understand why i’m getting this seemingly inconsistent output would be greatly appreciated. I have tried to give all the information I have about my setup, but if you feel I have missed something please let me know and I will provide anything you require.