Pages: [1]   Go Down
Author Topic: XBee Doorbell not working Newbee  (Read 709 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Trying to learn using "Building Wireless Sensor Networks" by Robert Fahudi. Chapter 3 - Building A Doorbell and having problems.

Setup:
2 Arduino UNOs
2 Serries 2 XBees
Switch on pin 2 of one UNO sends a letter "D" to the second UNO over Serial.print. I call this the BUTTON UNO. When the other UNO gets a "D" across the serial it activates pin 5 (the bell). I call this the BELL UNO. I'm not using API only AT passing serial data. (I learn to walk before I run.)

Problem: The switch doesn't seem to send the letter "D". If I type a "D" in the terminal emulator of the BUTTON UNO the bell rings like it should but the button doesn't ever send the D. The terminal emulator does show a D on the BUTTON UNO but it never shows on the BELL UNO

My trouble shooting:
I get it to partially work by typing the letter "D" in the terminal emulator of the BUTTON UNO. And I also have to reverse the TX-RX pins only on the BELL's XBee. Then the bell will ring.
The book always shows
UNO pin 0 (RX) to XBee pin 2
UNO pin 1 (TX) to XBee pin 3
but I connect
UNO 0 (RX) to XBee pin 2
UNO 1 (TX) to XBee pin 3 and the terminal emulator typed "D" rings the bell!  (This I find Strange?)

The Sketch:
On the BUTTON UNO:

/*
* ********* 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);
Serial.begin(9600);
}
void loop() {
// send a capital D over the serial port if the button is pressed
if (digitalRead(BUTTON) == HIGH) {
Serial.print('D');
delay(10); // prevents overwhelming the serial port
}
}

And the sketch on the BELL UNO:

/*
* ********* 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'){
//ring the bell briefly
digitalWrite(BELL, HIGH);
delay(10);
digitalWrite(BELL, LOW);
}
}
}

Note: Tested both XBees as properly configured by chatting between them.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 50182
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are the XBees connected to the Arduinos? Can you use SoftwareSerial to talk to the XBee, keeping Serial for debugging?
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Note: Tested both XBees as properly configured by chatting between them.

What is hooked to what in this case?

Also, you need to be really careful when following Faludi's book. He shows the XBee modules
interfaced improperly, and also his first schematic has the Rx/Tx connections crossed. See
last couple of posts in the following thread,

http://arduino.cc/forum/index.php/topic,126530.15.html

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I changed the program to use softwareSerial instead of the hardware serial and the Doorbell program now works. Still not sure why I can't get it to work with the hardware serial.

I attempted to debug using the hardware serial to pass comments at various points as the program runs but I never got anything across my serial monitors. I didn't even see the letter "D" that the BELL Arduino obviously received since otherwise it never would have buzzed.

As for how the XBees are hooked up when I was testing them with chatting I tried to duplicate this test just now but was not successful, wouldn't pass the characters from one Serial Monitor to the other. I think I need a sketch to pass the characters sent in the Serial Monitor. I thought this chat test was done successfully independent of the sketch running on the Arduinos. Before the two Arduinos were running the Blink sketch as I was chatting.
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You cannot use the RX/TX pins on the Arduino to do both USB comms to the PC and XBee comms
at the same time. The signals clash.
Logged

Pages: [1]   Go Up
Jump to: