Debugging XBEE Doorbell

Hi,
I’m using the book Wireless Sensor Networks and trying to do the second doorbell example.
I have 2 arduinos and 2 XBEEs. Pushing the button makes the piezzo buzzer go off, so the doorbell actually works. An XBEE coordinator is used for the buzzer and An XBEE router is used for the button.

What I can’t seem to get is the LED to light up on pin 11. This is supposed to light up after receiving the letter K back from the buzzer XBEE, confirming to the button pusher that the buzzer went off.
Am I missing anything in my code or should I look elsewhere as to why the LED doesn’t light up?
Here is my code for the button end.
Thanks for any suggestions.
As a side note, this book is awesome for any XBEE beginners like me.

/*
 * ********* Doorbell Basic BUTTON ********
 * requires pre-paired XBee Radios
 * and the BELL program on the receiving end
 * by Rob Faludi http://faludi.com
 */

#define VERSION "1.00a0"

int BUTTON = 2;

void setup() {
  pinMode(BUTTON, INPUT); 
  pinMode(11, OUTPUT); 
  digitalWrite(BUTTON,HIGH);
  Serial.begin(9600);
}


void loop() {
  // send a capital D over the serial port if the button is pressed
  if (digitalRead(BUTTON) == LOW) {
    Serial.print('D');
    delay(10); // prevents overwhelming the serial port
  }

 if (Serial.available() > 0) {
    if (Serial.read() == 'K'){      
       digitalWrite(11, HIGH);
       
  }
   digitalWrite(11, HIGH);
 }
   if (digitalRead(BUTTON) == HIGH) {
       digitalWrite(11, LOW);
  }
}

Code for buzzer end

/*
 * ********* Doorbell Basic BELL ********
 * requires pre-paired XBee Radios
 * and the BUTTON program on the receiving end
 * by Rob Faludi http://faludi.com
 */

#define VERSION "1.00a0"

int BELL = 5;


void setup() {
  pinMode(BELL, OUTPUT);
  Serial.begin(9600);
}


void loop() {
  // look for a capital D over the serial port and ring the bell if found
  if (Serial.available() > 0) {
    if (Serial.read() == 'D'){
     Serial.print('K');
     //ring the bell briefly
       digitalWrite(BELL, HIGH);
        delay(10);
    digitalWrite(5,LOW);
   
    }
    else
    digitalWrite(5,LOW);
  }
}

I have 2 arduinos and 2 XBEEs.

There are quite a few different XBees. You really need to tell us which ones you have, and how they are configured.

An XBEE coordinator is used for the buzzer and An XBEE router is used for the button.

This implies that the XBees are NOT series 1 XBees, which are designed for point-to-point use. I was never able to get the Series 2 models to communicate bi-directionally. One could send, and the other could receive, but not reply. There have been posts, a bit short on details, that imply that bi-directional communication IS possible, but using the right kind of radios makes it so much easier.

I am using series 2 XBees that are configured for AT commands. http://search.digikey.com/scripts/DkSearch/dksus.dll?WT.z_header=search_go&lang=en&site=us&keywords=602-1098-ND&x=0&y=0

I can see the XBee set up as the coordinator sending the letter K through the serial terminal, but then I'm not sure if the XBee setup as a router is receiving the message as the LED never lights up.

I've experienced the same problem. Can someone please help?

thanks

I've had no problems sending messages between two series 2 XBees. To send a message from an end node or router to the coordinator, use the ZigBee Transmit Request (page 103 of the XBee Series 2 Manual) and set the 64bit destination address to 0x0 and the 16bit network address to 0xFFFE. To send a message from the coordinator to a router or end node, set the 64bit desintation address to the address of the router or end node and the 16bit net address to 0x0. Note if you know the 16bit net address for the router or end node then you can use that instead (set 64bit address to 0x0). You can get the 16bit net address from the Receive Packet when the coordinator receives a packet from the router/end node.

To debug your problems I'd suggest adding some debugging to your code and checking that the coordinator is receiving the packet as expected, and that it is sending the response as expected. Then add some debugging to the router and check that it is receiving the packet.

Edit: After properly reading your code I've realised that you're not using API mode with the XBees, so this post won't help unless you want to try using API mode.

Thanks for the reply dhunt.

I've just started getting myself familiar with AT command and yes not using API at the moment. I got it working by swapping the destination address of the coordinator and router modems.

cheers!