Sending data from coordinator XBee(API) to router XBee(AT)

987 views Asked by At

I've been trying to send data from coordinator XBee to Xbee in router AT mode. It works.

However there is too much delay at an unacceptable duration. How to solve the delay problem?

int led = 0;
int ledX = 13;
int pin = 5;
int bs;
String store[20];
void setup() {
 pinMode(led,OUTPUT);
 pinMode(pin,INPUT);
Serial.begin(9600);
}

void loop() {
 // bs = digitalRead(5);
  //if(bs == LOW){
  digitalWrite(led,HIGH);
  setRemoteState(0x05);
  delay(1000);

  //}
  //else if(bs == HIGH){
  digitalWrite(led,LOW );
  setRemoteState(0x04);
  delay(1000);
  //}

}
void setRemoteState(char value){
Serial.write(0x7E); //start of the frame
Serial.write((byte)0); // byte length
Serial.write(0x10); //high part 16 in decimal
Serial.write(0x17); // AT command request
Serial.write((byte)0); // frame ID dont need any ack
Serial.write((byte)0);
Serial.write((byte)0);
Serial.write((byte)0);
Serial.write((byte)0);
Serial.write((byte)0);
Serial.write((byte)0);
Serial.write(0xFF);
Serial.write(0xFF);

Serial.write(0xFF);
Serial.write(0xFE);

Serial.write(0x02); 

Serial.write('D');
Serial.write('3'); //change pin D3

Serial.write(value);

long sum = 0x17 + 0xFF + 0xFF + 0xFF + 0xFE + 0x02 + 'D' + '3' + value;
Serial.write(0xFF - (sum &0xFF) );

}

Above is my code that i have implemented inside my arduino

1

There are 1 answers

2
tomlogic On

How much delay are you seeing? After you transmit the last byte into the coordinator, how many milliseconds elapse before you see data on the router?

What's an acceptable level? This is low-speed (250kbps) radio network which may need to bounce your message across multiple nodes. Expecting latency under 100ms is probably unrealistic.

If you're running the XBee modules at 9600 baud, increase the baud rate to 115200bps to reduce the time spent sending into one XBee and receiving on the other.