Home/Support/Support Forum/no synchronization between xbee
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

no synchronization between xbee

0 votes
hello
i have to xbee S2 , one as a coordinator API connected to an arduino and the other a router AT,
my project is about sending a command to the router to light up a led. the coordinator send the data if i clicked a button.
the problem is the router don't react immediately it takes a while to receive the data.
can anyone help me please
this the code i'am using
Code:
int led = 13; const int bouton = 2; void setup() { // put your setup code here, to run once: pinMode(led, OUTPUT); Serial.begin(9600); pinMode(bouton, INPUT); } void loop() { // put your main code here, to run repeatedly: if(digitalRead(bouton)==HIGH) { digitalWrite(led,HIGH); setRemoteState(0x5); delay(500); } if(digitalRead(bouton)==LOW) { digitalWrite(led,LOW); setRemoteState(0x4); delay(500); } } void setRemoteState(char value){ Serial.write(0x7E); // start byte Serial.write((byte)0x0); Serial.write(0x10); Serial.write(0x17); Serial.write((byte)0x0); // id of recipient or use 0xFFFF for broadcast Serial.write((byte)00); Serial.write((byte)00); Serial.write((byte)00); Serial.write((byte)00); Serial.write((byte)00); Serial.write((byte)00); Serial.write(0xFF); Serial.write(0xFF); // 16 bit of reciepent Serial.write(0xFF); Serial.write(0xFE); Serial.write(0x02); Serial.write('D'); Serial.write('2'); Serial.write(value); long sum = 0x17 + 0xFF + 0xFF + 0xFF + 0xFE + 0x02 + 'D' + '2' + value; Serial.write(0xFF - ( sum & 0xFF) ); Serial.print(sum,HEX); }
asked Apr 23, 2015 in Serial Cards by sawi New to the Community (2 points)
Frequent broadcasts run into resource limitations on the XBee. Does the system always have delays/lag? Or does it work for the first few button presses and then start with delay/lag?

Please log in or register to answer this question.

2 Answers

0 votes
yes it works for only the first button press and after the second press the delay begins.
answered Apr 24, 2015 by sawi New to the Community (2 points)
reshown Dec 9, 2016 by jeremym
0 votes
no it works in the first time and after that the delay begins
answered Apr 24, 2015 by sawi New to the Community (2 points)
Looking through your code it looks like it will send a broadcast every 500 milliseconds to refresh according to the button state. Definitely too fast so you will need to move to Unicasts or decrease the frequency. Updating code to only send on change might help a little but brings its own issues if a packet is dropped and likewise if you press the button too quickly in sequence.
...