XBee + Arduino

Hi !
I have 2 XBee Pro with one a shield ( Wireless shield for Arduino ) and a ftdi with a Xbee connected on it.

So, I have created a datalogger which saved some data on a sd card. When I receive 5 char from my XBee server ( on the ftdi, remote by XCTU ), normally i receive the sd card data on the XCTU software.
But ! It doesn’t work…

however, i’ve set all my XBee with XCTU the 9600 baud and it works…
When i changed it with 115200 It doesn’t work… But, one day it was working… not today…

My code : ( Commentaries are in french but it’s not important )

// Première version du programme ///
////////////////////////////////////

// Librairies //////////////////////
#include // SD
#include // SD

#include // RTC
#include “RTClib.h” // RTC

#include // XBee

////////////////////////////////////
// Declaration des variables ///////
////////////////////////////////////
int DHAB_val=0; // Permet de sotcker la valeur qui sera lue dans le DHAB
int DHAB_val_count=0; // Permet de compter le nombre de fois que la valeur est lue dans le DHAB
String XBee_val=“”; // Permet de stocker la valeur qui sera lue dans XBee ( Reception )
int Total_DHAB_val=0; // Permet de stocker les valeurs du DHAB lues qui seront ensuite traitées pour en faire une moyenne
int DHABpin=0; // Ici un potentiomètre
File myFile; // Fichier créé dans la microSD
String filename;
RTC_DS1307 RTC; // Declaration du module RTC
SoftwareSerial XBee(0, 1);// RX, TX pour le XBee

// Variables “Debug” ///////////////
int DELpinRouge=7;
int DELpinVerte=6;

void setup() {
initialiser_rtc();
initialiser_fichier();
initialiser_xbee();
pinMode(DELpinRouge, OUTPUT);
pinMode(DELpinVerte, OUTPUT);
}

void loop() {
digitalWrite(DELpinVerte, LOW);
if(XBee.available()==5){ // Si XBee reçu
digitalWrite(DELpinVerte, HIGH); // Pour l’instant on allume juste une led

//On va envoyer le fichier
XBee.println("Debut de l'envoie...");
myFile = SD.open(filename, FILE_READ);
while(myFile.available()){
  XBee.write(myFile.read());
}
myFile.close();
XBee.println("");
XBee.println("Fin de l'envoie...");

while(XBee.available()){
  XBee.read();                                                            // Vide le buffer
}

}
else{ // Sinon, on enregistre les données

  if(DHAB_val_count<=1000){
    DHAB_val_count=DHAB_val_count+1;                                      // Le but étant de faire une moyenne toutes les 1000 valeurs ( soit une moyenne toutes les secondes )
    DHAB_val=float(analogRead(DHABpin))*400.0/1023.0-200.0;               // On converti la valeur en A
    Total_DHAB_val=Total_DHAB_val+DHAB_val;                               // On additionne avec les valeurs lues précedemment
    DHAB_val=0;                                                           // On reset
    
  }
  else{
    DHAB_val_count=0;                                                     // La boucle étant dépassée, on reset
    Total_DHAB_val=Total_DHAB_val/1000.0;                                 // On fait la moyenne
    sauvegarder_dans_fichier(Total_DHAB_val);                             // On sauvegarde dans le fichier
    Total_DHAB_val=0;                                                     // On reset
  }    

}
}

void initialiser_fichier(){
SD.begin(4);
DateTime now = RTC.now();

int jour=now.day();
int mois=now.month();
int annee=now.year();
int heure=now.hour();
int minute=now.minute();
filename=String(heure)+String(mois)+String(jour)+".CSV";                   //BUG je n'arrive a donner le nom que je veux... Donc format HHMMAA.csv

if(!SD.exists(filename)){
  myFile = SD.open(filename, FILE_WRITE);
  myFile.println("Reception depuis XBee");
  myFile.println("Date (JJ/MM/AA);Heure (HH/MM/SS);Donnees (A);");         // Donc 3 informations par ligne : Date/Heure/Donnee
  myFile.close();      
}

}

void initialiser_rtc(){
Wire.begin();
RTC.begin();
RTC.adjust(DateTime(DATE, TIME)); //Met à jour l’heure directement depuis le PC
}

void initialiser_xbee(){
XBee.begin(115200);
}

void sauvegarder_dans_fichier(int Total_DHAB_val){
myFile = SD.open(filename, FILE_WRITE);
DateTime now = RTC.now();

myFile.print(now.day(), DEC);
myFile.print(“/”);
myFile.print(now.month(), DEC);
myFile.print(“/”);
myFile.print(now.year(), DEC);
myFile.print(“;”);

myFile.print(now.hour(), DEC);
myFile.print(“:”);
myFile.print(now.minute(), DEC);
myFile.print(“:”);
myFile.print(now.second(), DEC);
myFile.print(“;”);

myFile.print(String(Total_DHAB_val)+“;”);

myFile.println(“”);
myFile.close();
}

Some idea ?
How Can i configure my XBee ? Coordinator, end devices it’s important ?
Thanks !

which xbee modules and firmware versions are you working with?

Hi !
XCTU says :
product family XBP24
Frimware version 10ef

Both are like it
any idea ?
thanks

The radio in question is defaulted at a baud rate of 9600. If you want it to communicate at a different rate, you must not only change the baud rate on your processor but you also need to enter command mode and change the baud rate (BD) on the radio.

How? By XCTU?
When all is set on 9600, it’s work.
But when i change it by 115200 on XCTU for the 2 XBee, sending works but not receiving ( By XCTU )

I must configure it on Windows?
Thanks!

XCTU is not for sale. It is downloadable from Digi’s support site. https://www.digi.com/support/productdetail?pid=3352&type=documentation

Yes, you would also need to configure your Windows com port to also be at that rate for it to work.