I have several XBee's running using the Adafruit adapters, one coordinator and several end devices which works fine. So I decided to try the Sparkfun explorer on my Mega2560 to see if I could get into the network with the others. Didn't happen...The coordinator hears the Mega/XBee sending messages but the Mega/XBee can't hear the coordinator. When I hook the Sparkfun board up to XCTU, it hears the coordinator just fine and sends messages as well. I am stumped!
End Device Code
#include <SoftwareSerial.h>
#define TxPIN 18
#define RxPIN 19
#define bzero(b,len) (memset((b),'\0',(len)),(void) 0)
String Command;
SoftwareSerial xbeeSerial(RxPIN,TxPIN);
void setup() {
xbeeSerial.begin(9600);
Serial.begin(115200);
}
void loop() {
int cnt = 0;
Command = "";
xbeeSerial.print("I AM HERE"); //this shows up on the coordinator
while (!xbeeSerial.available() && cnt < 5) {
Serial.println("not avail yet");
delay(100);
cnt++;
}
While (xbeeSerial.available()) {
//Serial.print((char) xbeeSerial.read());
Command += (char) xbeeSerial.read();
Serial.print("serial available"); //Got command from Coordinator
}
delay(1000); // Delay a bit...
}
I get stuck in the "While(!xbeeSerial.available())" loop, it seems like it never comes available, thereby missing the messages that ae send by the coordinator. Pins connected on the Sparkfun XBee board - GND, +5, DIN, DOUT. What am I missing???
Ya, I know, I can just go out and buy more of the Adafruit devices and you won't have a problem..But then it wouldn't be fun!