problem with Arduino /xbee

Hi ,
please , i'm stack here for a week :confused:
So i want to save the informations executed by the ATND command.
I have a network of 8 nodes , i wrote an arduino code to read the result of ATND command executed by each node,
then i'll use a data logger to save it into a file.

So my proble , the code is good for 4 nodes, but any extensino of number of nodes , i can't get enough informations in the serial :confused: :confused:

Please Has anyone any idea how to resolve it.
I'm guessing maybe it's a problem of time, cause when i write the command manually in the terminal , there's no problem,
And cause when i change the delay time , i get always a different result :frowning:

help!!
Thanks =(

So i want to save the informations executed by the ATND command.

The information isn't executed. It's allowed to live. It is returned by the ATND command. How depends on how you execute the ATND command.

So my proble , the code is good for 4 nodes, but any extensino of number of nodes , i can't get enough informations in the serial :confused: :confused:

Why not? The amount of information you can read from the serial port has no relation to the size of the buffer, unless you are diddling around taking too long before reading it.

And cause when i change the delay time

The "delay time" should be zero/zip/zilch/nada.

Please Sir, here is my code, I don't find out why it doesn't work :confused: :confused:

PS : it still works for 4 sensor nodes, but no more than 4 :confused: And when i deleted all the delays, it doesn't work for even the 4 nodes, Help !!

char recu[100]; 
int i; 

void setup(){ 
      Serial.begin(9600); 
      delay(1000);
      command_mode();
      } 

void loop()	{ 
      
      i = 0 ; 
      while ( Serial.available()==0 ){}
      while ( Serial.available()>0 )      { 
            recu[i] = Serial.read(); 
           char octet = recu[i]; 
           i++; 
           if (i>0)	{ 
                  Serial.print(octet); 
                  delay(300);
            } 
      }
     	
}

void command_mode(){

delay(1200);
  Serial.print("+++");
  delay(1200);
  bool bOK = false;
  while (Serial.available() > 0) {
    Serial.write(Serial.read());
     bOK = true;
  }
  
  if(bOK)
  {
    
    Serial.println();
    Serial.println("ATNI");
    delay(1000);
    read_data();
    delay(500);
    
    Serial.println("ATND");
}
}
void read_data(){
  byte data;
  while(Serial.available()){
    data=Serial.read();
    delay(1000);
    Serial.print(char(data));
    delay(500);
  }
Serial.flush();
}
      while ( Serial.available()>0 )      { 
            recu[i] = Serial.read(); 
           char octet = recu[i]; 
           i++;

Writing to the array, when i exceeds the length of the array is really not a good idea.

Why is it necessary to copy the ith element to another variable? Why not just print the i-1 value?

Why are you delay()ing after printing one character? During that time, you could easily be overflowing the serial buffer.

  while (Serial.available() > 0) {
    Serial.write(Serial.read());
     bOK = true;
  }

What is this doing? What purpose is served by sending the same data back to the sender?

It looks to me like you are trying to use the hardware serial port to talk to the PC and to the XBee, hoping like hell that each ignores the data meant for the other. That is a quite unrealistic hope.

OK Thank you Sir for your help
And here is my new code, But I get a new problem : the arduino UNO board resets automatically in few seconds :confused:
Attached is a link for the picture i took as a result of the code.

void setup(){ 
      Serial.begin(9600); 
      delay(1000);
      command_mode();
      } 

void loop()	{ 
            while ( Serial.available()>0 )      { 
            byte ch = Serial.read(); 
                  Serial.print(char(ch)); 
      }
     	
}

void command_mode(){
byte ok;
delay(1200);
  Serial.print("+++");
  delay(1200);
  bool bOK = false;
  while (Serial.available() > 0) {
    ok=Serial.read();
    Serial.print(char(ok));
     bOK = true;
  }
  
  if(bOK)
  {
    
    Serial.println();
    Serial.println("ATNI");
    delay(1000);
    read_data();
    delay(500);
    
    Serial.println("ATND");
    
    
}
}
void read_data(){
  byte data;
  while(Serial.available()){
    data=Serial.read();
    delay(1000);
    Serial.print(char(data));
    delay(500);
  }
Serial.flush();

}
byte ok;

    ok=Serial.read();
    Serial.print(char(ok));

If you typed ok correctly, there would be no need to cast it.

  while(Serial.available()){
    data=Serial.read();
    delay(1000);
    Serial.print(char(data));
    delay(500);
  }

There's a bunch of data to read. Read one character. Wait an eternity. Print it. Wait half an eternity. See if there is more data to read. Repeat as required. No!

PS. Isyourspacekeybroken?