I want to use xbee's to communicate between two different arduinos. I'm using this tutorial as a guide to setup my xbee's. I've already used XCTU to setup one xbee as a router and another as a coordinator (both in ZIGBEE AT mode). I used XCTU's terminal feature to verify that info was being sent and received properly.
Basically, I have both arduinos connected to the same PC via USB cables, but the communication is taking place through the Xbee's. I also made sure to disconnect the TX & RX wires when uploading the sketches to avoid an AVRDUDE error.
I wanted to test the communication by sending a "hello world" message once every five seconds, from the router to the coordinator. To do this, I wrote the following code:
//Code for Arduino attached to Xbee in Router AT mode
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println("Hello World!");
delay(5000);
}
and
//Code for Arduino attached to Xbee in Coordinator AT mode
void setup(){
Serial.begin(9600);
}
void loop(){
if (Serial.available()>0){
Serial.write(Serial.read());
}
}
I checked the serial monitor for the arduino connected to the router, and it does exactly what I expected to see: a new Hello World message once every 5 seconds. However, the serial monitor on the arduino connected to the coordinator does not produce the desired effect: the "hello world" message instantly displays the message over a hundred times per second and repeats without end, each time on a separate, new line. Sometimes, when I turn the serial monitor on, the message instantly appears with a few repetitions before displaying some strange characters and stopping altogether.
I'm not sure if the problem is with the serial monitor or with the xbee. Any help with this problem would be greatly appreciated.