I'm having issues with datalogging. I'm building on this older thread. I created an array of files and I want to open it these files to write on them. However, I get an error to opening the file. I don't know if this is because I am supposed to use an array of pointers to files instead of an array of files, or if it is due to the name of the file, or due to any other issue. I made sure that the filenames were short (less than 8 characters) and contained only letters and numbers. Here is the code snippet (within the loop() function and within a state):
File filePointers[CellN]; //Array of 4 files, one for each cell
char filename_cell[32];
char completefilename_cell[40];
sprintf (filename_cell, "S%02iC%02i.CSV", NN, thisCell + 1); //create filename
sprintf (completefilename_cell, "%s/%s/%s", foldername, datafoldername, filename_cell); //this uses previously made foldernames and gives: /201216/Data/S01C01.CSV
filePointers[thisCell] = SD.open(completefilename_cell, "r");
if (filePointers[thisCell]) {
//write stuff
}
else {
Serial.println("error opening log.csv"); // this is the error that pops up!
}
Hi, thanks a lot. I did this - the filename in my comment line //this uses previously made foldernames and gives: /201216/Data/S01C01.CSV is actually a copy-paste of the serial monitor - so the completefilename_cell is built how I expected it
I don't know what happens if the folder doesn't exist.
You could try eliminating the folder file path and just try opening the file at the root level to see if it works.
you could also test for folder existence with