PaulS:
Do you have a 12Gig card?
No, a 16 Gig card, but one year of data is 12 gigs.
How do you "clean the card structure"? Ajax and a scrub brush and a bucket of warm water?
This could be some way to do it, but I have not tried. I simply put the card in the lector of the MacBook Pro, and fix the structure with the diskUtility tool.
The code you didn't post?
No, I did not think it was necessary. It may distract you from the real question which is wether there is a general strategy to avoid these kind of corruption.
To satisfy your curiosity, I have nevertheless put below the code that concerns the SD card. Hope it is useful.
#include <SdFat.h>
void loop() {
long sec=0;
String file=String();
// acquisition des donnees
// testRTC ();
update_baro();
update_env();
outSD();
outserial();
// affichage ecran
lcdbar();
}
void outSD(void) {
// sauvegarde carte SD simple
// ouvreSDFX(fileName);
// ouvreSDF();
digitalWrite(ledSD,HIGH);
ouvreSDFX(fileName);
ecritureSD();
fermeSDF();
digitalWrite(ledSD,LOW);
}
void ecritureSD() {
// sauvegarde carte SD : ecritures seules
outbaro();
SDF.print(baraux);
// SDF.print(caux0);
SDF.print("\r\n");
}
void ouvreSDFX(char filena[]) {
if (!SDF.open(filena, O_RDWR | O_CREAT | O_AT_END)) {
sd.errorHalt();
Serial.println(F("opf failed"));
}
// clock : ajustement des dates de creation du fichier
now = rtc.now();
if (!SDF.timestamp(T_CREATE, (uint16_t)now.year(), (uint8_t)now.month(), (uint8_t)now.day(), (uint8_t)now.hour(), (uint8_t)now.minute(), (uint8_t)now.second())) {
Serial.println(F("set create time failed"));
}
if (!SDF.timestamp(T_WRITE, (uint16_t)now.year(), (uint8_t)now.month(), (uint8_t)now.day(), (uint8_t)now.hour(), (uint8_t)now.minute(), (uint8_t)now.second())) {
Serial.println(F("set write time failed"));
}
// set access date
if (!SDF.timestamp(T_ACCESS, (uint16_t)now.year(), (uint8_t)now.month(), (uint8_t)now.day(), (uint8_t)now.hour(), (uint8_t)now.minute(), (uint8_t)now.second())) {
Serial.println(F("set access time failed"));
}
// digitalWrite(pinSD,HIGH);
}
void fermeSDF(void) {
SDF.close();
// digitalWrite(pinSD,LOW);
}