Hello, I need to use Xbee communication in my project and I am facing a problem, I set up a reader part and a writer part then I want both to communicate, but it doesn't work.
- I plugged both Xbee S1 devices in my PC, I used XCTU and I could communicate with both of them.
- I plugged one Xbee S1 device in an arduino controller as a listener and the other in my computer as the writer, and I can see the messages on my Serial Monitor.
But when I try to do it with 2 arduinos, it just doesn't work.
I put the same PAN ID and the same channel, both are end points, I tried with coordinator too but no change. I did it with broadcast first, then I also tried to put the specific address.
At some point when I reset the controller, I get the first bytes of the protocol, like when I send "HI", I get the 126, 0, 2, 138, 0, 117 (I guess the 2 is for the message length ) but no trace of my message.
Here's the reader code
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(A3, A4); // CONNECT BT RX PIN TO ARDUINO 11 PIN | CONNECT BT TX PIN TO ARDUINO 10 PIN
void setup()
{
Serial.begin(9600);
BTSerial.begin(9600);
Serial.println("zigbee reader");
}
void loop()
{
while(BTSerial.available()>0){
Serial.println(BTSerial.read());
}
}
Here's the writer part
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(A3, A4); // CONNECT BT RX PIN TO ARDUINO 11 PIN | CONNECT BT TX PIN TO ARDUINO 10 PIN
void setup()
{
Serial.begin(9600);
BTSerial.begin(9600);
BTSerial.print("HI");
Serial.println("zigbee writer");
}
void loop()
{
BTSerial.print("HI");
delay(2000);
}
If anyone can has any idea about this, I'd appreciate your help, thanks