I am not sure if this is a right place to put this question but if anyone is familiar with XBee and can help me with this problem, I highly appreciate your help.
I have two XBees, one configured as coordinator API and another configured as router API.
I have attached those two XBees with two arduinos just to test communication between them. The code for each one is very simple.
Code in arduino hooked to coordinator XBee
Description: This will simply check button press. Upon press it will send ZigBee transmit request frame.
int BUTTON1 = 3;
void setup()
{
pinMode(BUTTON1, INPUT);
Serial.begin(9600);
}
void loop()
{
if (digitalRead(BUTTON1) == HIGH)
{
sendData();
}
}
void sendData()
{
Serial.write(0x7E);
Serial.write(0x00);
Serial.write(0x16);
Serial.write(0x10);
Serial.write(0x01);
Serial.write(0x00);
Serial.write(0x13);
Serial.write(0xA2);
Serial.write(0x00);
Serial.write(0x40);
Serial.write(0x8C);
Serial.write(0xC6);
Serial.write(0xD4);
Serial.write(0x20);
Serial.write(0x01);
Serial.write(0x00);
Serial.write(0x00);
//data start
Serial.write(0x54);
Serial.write(0x78);
Serial.write(0x44);
Serial.write(0x61);
Serial.write(0x74);
Serial.write(0x61);
Serial.write(0x30);
Serial.write(0x41);
Serial.write(0x13);
delay(10);
}
Next is the code for arduino hooked to router XBee.
Description: This simply scans "0x54" byte and if it is there then lights up a LED. As you can see, coordinator sends this byte 0x54 along with other bytes.
int BELL = 5;
void setup()
{
pinMode(BELL, OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available() >= 25)
{
if(Serial.read() == 0x7E)
{
for(int i=0;i<24;i++)
{
if(Serial.read() == 0x54)
{
digitalWrite(BELL, HIGH);
}
}
}
}
}
I would like to add that, when I turn on serial monitor, and then press the button, the serial monitor displays correctly what data was passed. Also tx lights up. So my assumption is that the problem is in the router not getting the data rather than coordinator not sending the data. I have been trying to hunt this problem for couple of hours now with no success. Any help is highly appreciated!