SD card file creation best practice Q

I understand that SD cards use Flash memory and that this type of memory has a finite number of write cycles in its lifetime.

My application will write data to a file every 10 seconds. Each file will hold 1 day's worth of data or 8640 entries.

Currently my code performs this segment every 10 seconds with the same value of filename

void createFileName(){
myFile = SD.open(filename, FILE_WRITE);
myFile.close();

Will this use up the lifetime of the directory area of the SD unnecessarily? (note I am not worried about the data area itself just the directory)
The alternative would be to search for the filename every 10 sec and only create a new one if the filename had changed to the one for the next day.
I'd rather not have the extra code as I predict that I may run out of program RAM with all the other code I want to include eventually.

TIA

Bob

Will this use up the lifetime of the directory area of the SD unnecessarily? (note I am not worried about the data area itself just the directory)

"The directory" would be the File Allocation Table. Opening the same file over and over doesn't cause a write to the FAT. Creating a new file, deleting a file, etc. does.

Thank you Paul.

9fingers:
Currently my code performs this segment every 10 seconds with the same value of filename

void createFileName(){

myFile = SD.open(filename, FILE_WRITE);
myFile.close();




Bob

I don't think you should be doing that. That code is for creating the filename. You are attempting to create a new file every ten seconds. This can't be a good idea and surely only needs to be done once a day. The stroke of midnight might be a good place.

so loop:

get time
if midnight or just after
create filename

get data
open file
write data
close file
tralala

I think what happens is that: if a file log.csv exists and you try to create another of that same name, Arduino just ignores you. So no harm done, but it's still not a good idea. What this means is that you don't have to wait till midnight either. You can create the file in the setup by calling the same subroutine and, in the event of a restart, data will be immediately written to the right file.