arduinoxbeeftdi

Initializing Xbee S1 by an Arduino mini pro


I am trying to configurate my XBee module by an Arduino pro mini that is connected to my computer by de FTDI basic from sparkfun. I already can write and send data from the Xbee to another Xbee module by the Arduino. My problem is that I want to configure the Xbee by the arduino. I am sending ‘+++’ with the arduino to my Xbee and want to receive the ‘OK’ from the Xbee with the serial monitor from the arduino editor. The problem is that I can send it but never receive and ‘OK’, and when I am trying to configure the Xbee the configuration never happened. So I cant reach the Xbee command line.

    uint8_t pinRx = 0, pinTx = 1; //Initialise pins on the Arduino
    char GotChar;
    long BaudRate = 4800;
    int incomingByte=0;
    SoftwareSerial mySerial( pinRx , pinTx );  //Initialise SoftwareSerial
    
    void init_USB()
    {
      Serial.begin(BaudRate);    
      Serial.println("Start");   
      mySerial.begin(BaudRate);  
    }
    
    void init_XBee()
    {
      Serial.begin(9600);
      int check = 0;
      while(T_XBEE_CONTROLLER_CheckOK() == 0)
      {
        Serial.println("CheckOK");
        Serial.write("+++");
        delay(2000);
      }
      Serial.println("ATCH 8\r");
      delay(2000);
      Serial.write("ATID 1234\r");
      delay(2000);
      Serial.write("+++");
      delay(2000);
      Serial.write("ATPL 0\r");
      delay(2000);
      
      Serial.write("+++");
      delay(2000);
      Serial.write("ATAP 2\r");
      delay(2000);
    }

    int T_XBEE_CONTROLLER_CheckOK()
    {
            char ch[2];
            ch[0] = 0x00;
        while(! ((ch[0] == 'O' ) && (ch[1] == 'K')  ))
        {
                ch[0] = mySerial.read();
                ch[1] = mySerial.read();
                if((ch[0] != 'O') && (ch[1] != 'K') && (ch[2] != '\r'))
                {
                  Serial.println("FAILED");
                        return 0;
                }
                Serial.println("SUCCES");
                return 1;
        }
        return 0;
}

Solution

  • Thanks for the response and the help, and also sorry for the late response.

    I already solved the problem. The problem was the function write(). If you want to reach the command mode from the XBee you should only send "+++". If there is some kind of character behind the "+++" you can't reach the command line. The function write put a (for me) unknown character behing the "+++". So that's the problem for not reaching the command line.

    To resolve this problem just use the function print("+++"). After using this function it is possible to reach the command line.