Hi all!
I'm working on a datalogging system and I am using the Adafruit Ultimate GPS Logger Shield to write data to a SD-card.
The existing code example has the following lines of code for naming the logfiles:
char filename[15];
strcpy(filename, "GPSLOG000.CSV");
for (uint8_t i = 0; i < 1000; i++) {
filename[6] = '0' + (i/100)%10;
filename[7] = '0' + (i/10)%10;
filename[8] = '0' + i%10;
// create if does not exist, do not open existing, write, sync after write
if (! SD.exists(filename)) {
break;
}
}
logfile = SD.open(filename, FILE_WRITE);
if( ! logfile ) {
Serial.print("Could not create ");
Serial.println(filename);
error(3);
}
Serial.print("Writing to ");
Serial.println(filename);
While this is great, it only allows for a maximum of 100 unique logfiles, before things go haywire. I would like to increase this maximum number to 1000, and I tried to change the format as in the code below:
char filename[16];
strcpy(filename, "GPSLOG000.CSV");
for (uint8_t i = 0; i < 1000; i++) {
filename[6] = '0' + ((i/100)%10);
filename[7] = '0' + ((i/10)%10);
filename[8] = '0' + (i%10);
// create if does not exist, do not open existing, write, sync after write
if (! SD.exists(filename)) {
break;
}
}
logfile = SD.open(filename, FILE_WRITE);
if( ! logfile ) {
Serial.print("Could not create ");
Serial.println(filename);
error(3);
}
Serial.print("Writing to ");
Serial.println(filename);
However, it doesn't seem to work and I keep getting the 'Could not create' message in the serial monitor.
Does anyone have any ideas on how to tackle this?
Thanks!