Naming SD LOG FILE With Year,Date, and Time Stamp

Hello,

Im working with SparkFun's 9DoF IMU. The log files are name LOG0.csv / LOG1.csv........... I'm trying to find a good example code to incorporate this into my sketch and have yet to find one. Also, do I first need to activate a RTClib first to capture the data? The board uses the SAMD21 cpu for this IMU. Any suggestions?

Thanks,

Chris

char fn[15];
sprintf_P(fn, (const char*) F("%02d-%02d-%02d.CSV"), year(t) - 2000, month(t), day(t));
File file = FS.open(fn, FILE_WRITE);

Juraj:

char fn[15];

sprintf_P(fn, (const char*) F("%02d-%02d-%02d.CSV"), year(t) - 2000, month(t), day(t));
File file = FS.open(fn, FILE_WRITE);

Depending on your library and SD card format you might want to stick to a 8.3 type of file name (which is the case until 2100). If this needs to work longer then

sprintf_P(fn, (const char*) F("%d%02d%02d.CSV"), year(t), month(t), day(t));

will get you safely to 9999 as a 8.3

:slight_smile: :slight_smile: :slight_smile:

it is my sketch. I change it to -2100 in 2100 :slight_smile:

Juraj:
it is my sketch. I change it to -2100 in 2100 :slight_smile:

:slight_smile:

Hi Guys, Thanks for your replies. I am still having some trouble with both these codes tried. I am getting a " 't' was not declared in this scope" error. What am I missing. I have tried to include RTCZero and RTClib but still same error result from compiler. I am new to this and I am thinking I am missing something obvious being a rookie.

char fn[15]; This I have called out.

sprintf_P(fn, (const char*) F("%02d-%02d-%02d.CSV"), year(t) - 2000, month(t), day(t));
File file = FS.open(fn, FILE_WRITE); These other two lines I have in the void setup() where I am already opening the file , naming it, and then closing so its ready to start logging my data strings which works fine.I wish I could post my code you can see some of my attampts which are just commented out for the time being. The forum says my code iis beyond the allowed total character allowance. :frowning: Can someone point me in the right direction?

Thanks,

Chris