MKR GPS Time: Leap Seconds?

I'm about to start a project using the MKR Zero with an MKR GPS Shield, but I have a question about the getTime() class. The documentation says it returns "epoch time" which I guess is the number of seconds since January 5, 1980 (rather than Unix epoch time). But is this GPS epoch time adjusted for leap seconds? If not, I have a challenge making the 19 or 20-second adjustment depending on what year it is currently.

The reason this is important is that my project involves anticipating a top-of-the-minute or bottom-of-the-minute starting time for a race (i.e., starting a timer and other functions at the next 30-second mark after an interrupt from a pushbutton).

Thanks for any insights.

I don't know. However, the GPS must get time including leap second adjustment from the satellites to calculate position.

So you could print the time and epoch seconds and do the math to see if it matches.

Hi wildbill, Thanks for the prompt reply. Your suggestion is exactly what I would do if I had the MKR GPS shield, but I don't yet have it, so I was hoping to get a head start on the problem. I do have the Adafruit GPS module, and it gives me the actual time in hours, minutes, and seconds, but the library for the MKR GPS doesn't seem to do that. Anyway, thanks again. I'll try to keep this updated with whatever I discover.

The GPS does indeed get the updated\current value of leap seconds from the GPS satellites.

Unfortunatly the updated value is in a navigation message which only goes out every 12.5 minutes.

So the 'actual' time reported by the GPS can be out some seconds until this navigation message is received.

Thus if the GPS reported time needs to be up to date, then you have to check that the leap seconds update has actually been received, rather than just assuming it has.

It looks like the usual ublox GPS module. I'd guess therefore that it will provide a leap second adjusted time and I certainly wouldn't worry about it until it was proved I had to. Worth checking the instant you have it in your hands of course.

Indeed it wiil, but only once it receives the leap seconds update message.

Agreed. I knew that! (because I read it in one of your posts a while back) :wink:

Hey srnet and wildbill - Many thanks for the information and insights! I'll keep my fingers crossed about getting the correct time from the MKR GPS when I test it out.

I got the MKR Zero and MKR GPS Shield. The MKR GPS had such a hard time acquiring a fix that I had to abandon that unit (imagine being at the start line for a race and your race computer is waiting forever for a GPS signal...). I'm using the Adafruit Ultimate GPS Breakout instead, and it gives correct time (hours, minutes, seconds). So, while I assume the MKR GPS Shield handles leap seconds, I never really tested it. Thanks for all your insights and help.

It would be unusual for a GPS not to handle leap seconds, its a fundamental part of the GPSs operation.

The issue is, you need to check if the update has been received, until it has, the time might be out by some seconds.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.