Hi,
I'm trying to setup my XBee using Arduino, the thing is that, I want to set a Node Identifier everytime the Arduino boots up. The problem is that it not always does it, for example I load the arduino with the code I wait for it to configure the XBee and then from another XBee conected to the PC I use the ATND command to check if the Arduino configured the first XBee with the Node Identifier I told it to and it does it sometimes, then I unplug the arduino and connect it again and it might not do it this time.
I'm using the XBee Series 1 with the "new" firmware for Mesh networking for series 1.
here is the code
void setup(){
pinMode(13, OUTPUT);
Serial.begin(115200);
Serial.flush();
for (int x=0; x<=10; x++){
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(400);
}
setNI();
}
void loop(){
}
void setNI(){
int i=0;
Serial.print('x');
delay(1100);
Serial.print("+++"); // Command mode
//Waiting for "OK\r"
delay(1100);
char thisByte = 0;
while (thisByte != '\r') {
if (Serial.available() > 0) {
thisByte = Serial.read();
}
}
digitalWrite(13,HIGH); //Just to check that it has entered in command mode.
delay(1000);
digitalWrite(13,LOW);
Serial.flush();
delay(1100); //Guard Time
Serial.print("ATNI12345678\r");
digitalWrite(13,HIGH);
}
Thank You!