We are trying to make communicate to Xbees Pro (Series 1): one is plugged to the UNO microcontroller, the other to the Mega 2560 microcontroller. At first we tried to plug one Xbee to a micro, and the other to the pc via an interfacing USB shield and it worked correctly, in both ways (emit from the pc towards the UNO or Mega, and vice versa).
But when we replaced the USB shield by the second microcontroller, nothing worked anymore. Do you have any idea what the reason could be? The programming commands we were using are: Serial.write() and Serial.read()
We used a baud rate of 115200.
Let me know if you need more information.
Thanks.
How are the XBees configured?
What code is running on each Arduino?
What happens, in terms of what lights on the Arduino and one the attached XBee shield, flash when one Arduino sends data? What lights flash on the other XBee shield and Arduino when the first one sends data?
Which shields are you using?
int message;
int led=13;
void setup(){
Serial.begin(9600);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
}
void loop(){
if (Serial.available()>0){
message=Serial.read();
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led,LOW);
}
}
The Xbees configuration is standard, we just ran X-CTU but we didn't change any parameter.
When we try to make everything work, with both arduinos connected to 9V batteries, the RSSI led switches on the shield connected to the Mega.
Then if we try to plug the arduinos to 2 computers and to open the Serial monitor, then the leds TX start to blink on both arduinos.
On the serial monitor connected to the UNO, we can see some "0" printed and on the serial monitor connected to the Mega we can see some "1" printed.
Regarding the shield we use, you can see them on those links:
On the serial monitor connected to the UNO, we can see some "0" printed and on the serial monitor connected to the Mega we can see some "1" printed.
You are sending the binary value 48 to the serial port, from the UNO, which should cause the character 0 to be printed on the serial monitor, and broadcast by the XBee on the UNO.
On the Mega, you are reading the data arriving on the serial port from the PC or from the onboard XBee. There is nothing in the code on the Mega that sends anything.
It is not clear how the XBee is connected to the Mega. The board that you linked to for the Mega is not a shield. How is that board connected to the Mega?
The pin Vin of the board is connected to the pin 5V of the Mega.
The pin Gnd of the board is connected to the pin Gnd of the Mega.
The pin Tx of the board is connected to the pin Tx of the Mega.
The pin Rx of the board is connected to the pin Rx of the Mega.
(actually I also have tried to connect Tx of the board with Rx of the Mega and Rx of the board with Tx of the Mega)
Do you think it could solve my problem to buy this shield?
No.
If the PC and the UNO can talk to each other, move that shield to the Mega, and see of the PC and Mega can talk. If so, buy another one of those shields.