Go Down

Topic: Making sense of XBEE rx data (Read 881 times) previous topic - next topic

mstadtler

Code: [Select]
//xbee router
#include <SoftwareSerial.h>

;
SoftwareSerial mySerial(10, 11); // RX, TX
// the setup routine runs once when you press reset:
int led = 13;
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

I one have one xbee communicating to a second xbee (connected to UNO).   I am set up in API mode on the Coordinator. I am intersted in analog data on AD1 of the router.

I receive the following

0,1,2,0,3,FF,37,7E,0,A,83,0,0,42,0,1,2,0,3,FF,35,
7E,0,A,83,0,0,3D,0,1,2,0,3,FF,3A,7E,0,A,83,0,0,46,
0,1,2,0,3,FF,31,7E,0,A,83,0,0,58,0,1,2,0,3,FF,1F,
7E,0,A,83,0,0,4F,0,1,2,0,3,FF,28,7E,0,A,83,0,0,58,
0,1,2,0,3,FF,1F,7E,0,A,83,0,0,45,0,1,2,0,3,FF,32,
7E,0,A,83,0,0,58,0,1,2,0,3,FF,1F,7E,0,A,83,0,0,52,

I am expecting the analog data to be bytes 21 - 7e is the start byte

Looks like i am only getting 13 bytes.

Comments ?


---code-- here

void loop() {

  if (Serial.available()>=21){

    for (int i=1;i<22;i++){
      Serial.print(Serial.read(),HEX);
      Serial.print(",");
    }
    Serial.println();
  }
}

PaulS

Quote
I am expecting the analog data to be bytes 21

Why are you expecting this?

Why are you not using the XBee library? Why are you not posting all of your code?

GreyCon

As Paul said,
  use the library! The XBee world, in API mode, is not straighforward, and even using the library you will have your work cut out for you. I built a system around this 2 years ago, but have now become convinced that WiFi and MQTT is the way to go.

Elaborate a little more about what you are trying to do exactly, and post more code  :)

Go Up