SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By dervis
#199969
Hello,

I am using GPS receiver EM-406 with the GPS Shield and microSD shield (two shields on the top of the arduino board) to log GPS data. I am using the code from sparkfun website. By default, the CSV file that it opens are named as starting from 'GPSLOG00' to 'GPSLOG99'. I want to name these files as date, i.e. the day, month and year. For example, if the date of the day is August 7, 2018, I want the CSV file to be named as "2018.08.07". How can I do that? I know from the previous graduate student in my lab that it is possible. Some of his CSV files are named month/day (MM/DD), which is 08/07 for August 7.

Thank you very much and I look farward to hearing from you soon
Dervis
User avatar
By DanV
#199985
If you are using the example sketch from the hookup guide:

Then you can easily modify the last function to format the filename yyyymmdd.csv.
I'm nearly sure you are limited to 8.3 format for the filename.
I don't have a way to test this, but it could work.

change this line:
Code: Select all
    sprintf(logFileName, "%s%d.%s", LOG_FILE_PREFIX, i, LOG_FILE_SUFFIX);
to this:
Code: Select all
    sprintf(logFileName, "%04d%02d%02d.%s", tinyGPS.year.value(), tinyGPS.month.value(), tinyGPS.day.value(), LOG_FILE_SUFFIX);