Hi,
I'm trying to create a text file on the SD card with a variable name defined with the date and time (ex: 170504-12h59.txt) but the code line myFile.open(filename, O_RDWR | O_CREAT | O_AT_END) is returning me an error and I can't find why...
The filename variable is array of character and its value is the same as the example above.
There is the code I use to format the filename and create the file:
readDS1307time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
day=int(dayOfMonth);
mont=int(month);
String strnomfichier =" ";
String strmois =" ";
String strjour =" ";
String strminute =" ";
if(month < 10){
strmois = '0'+String(mont);
}
else{
strmois = String(mont);
}
if(day < 10){
strjour = '0'+String(day);
}
else{
strjour = String(day);
}
if(minute < 10){
strminute = '0'+String(minute);
}
else{
strminute = String(minute);
}
strnomfichier = String(year) + strmois + strjour +'-'+ String(hour) + 'h' + strminute;
strnomfichier = strnomfichier + ".txt";
Serial.println(strnomfichier);
char filename[strnomfichier.length()+1];
strnomfichier.toCharArray(filename, sizeof(filename));
Serial.println(filename);
// open the file for write at end like the Native SD library
if(!myFile.open(filename, O_RDWR | O_CREAT | O_AT_END)) {
lcd.setCursor(0,1);
lcd.print("Error");
sd.errorHalt("opening file for write failed");
}
If some one sees something I missed, I would need a hand,
Thanks