File Time Stamp from GPS

Would some one know how where I can find a sketch to produce a file with a time stamp derived from GPS?
Kindest Regards,
Mari

Use tiny GPS library and you will be able to get time stamp from your GPS. Then write the time stamp to an SD file following an SD library sample code.

Thanks. I got as far as the TinyGPS, but could not find any example in the SD or SDFat library to add the file time stamp to the file. Would you have any specific reference in mind?
Mari

As far as I remember, the library has an optional callback which it uses to obtain the timestamp values it applies to files.

I am using Adafruit’s RTClib for real time clock.

//This function returns the date and time for SD card file access and modify time. One needs to call in setup() to register this callback function: SdFile::dateTimeCallback(file_date_time);
void file_date_time(uint16_t* date, uint16_t* time) 
{
  DateTime now = RTC.now();
  *date=FAT_DATE(now.year(),now.month(),now.day());
  *time=FAT_TIME(now.hour(),now.minute(),now.second());
}

In your setup():

  SdFile::dateTimeCallback(file_date_time); // Attach callback function to provide date time to files.

I have not been able to implement your suggestion. My date and time come from a GPS shield called I2C GPS Shield Rev2 from DSS Cirquits for a Due such as:

long          utcTime    = 111503.3;
long          date       = 251113;

uint16_t* utcTimeX=utcTime;
uint16_t* dateX= date;

SdFile::dateTimeCallback(dateX,utcTimeX);

The problem is apparently in the conversion from long to an uint16_t. I was unable to get TinyGPS or the RTC library to work here.

Would you have any suggestions?

Kindest Regards,
Mari

mjmes:
Would you have any suggestions?

If you're using the library I'm thinking of, the callback is supposed to be a function pointer, not a variable. Look for real examples using dateTimeCallback() to understand how to use it. If you have trouble getting your implementation to compile, post the code and the actual error messages output by the compiler.

How do you get date and time as integers (or long) from your library? Give me a few lines of code that do that. My sample needs to be changed to use YOUR library calls to get date and time. Yes, as Peter said, the callback is directed to a function, not grabbing a number.

I am using the DUE IED 154R2 that comes with a wire.h library (which I include, although I am told there are serious problems with this wire library).

The GPS unit from dsscircuits.com is for sale | HugeDomains produces the date and time as long numbers without the use of any library such as TinyGPS and such or any transformation. The reason is that the unit has its own processor that can spit out any GPS parameter as needed on request.

Hope this clarifies your questions.
Kindest Regards,
Mari

produces the date and time as long numbers without the use of any library

What, then, is the code to get time and date from this module? Post your code. Don't make us search for sample code :slight_smile: