Skip to content

adafruit_gps.GPS gives no indication how current the value of the datetime property is #77

Description

@jwfmcclain

Because not all of the NMEA sentences include the time:

    if gps.update():
        rtc.RTC().datetime = gps.datetime

can set the RTC to a timestamp read from a previous update() call.

This gets worse when you consider the date. Only RMC sentences have the date, so processing (for example) an GAA sentence and then doing rtc.RTC().datetime = gps.datetime just after midnight will wind the RTC back almost 24 hours. Arguably this would be a short term effect, as the next RMC sentence will fix the date, but I have run into situations where my GPS Featherwings get into a state where they are setup to return both RMC and GAA sentences, but GPS.update seem to only get/process GAA sentences for 1000s of calls.

Signaling the age of the datetime, could significantly complicate the interface, and I can imagine that being a bad trade-off. The best solution might be just to document the issue.

FWIW, the workaround I settled on for my code is to a) configure the GPS to only return RMC sentences, and (because the GPS does not seem to always obey the PMTK314 sentences) b) use this subclass:

class TimeSettingGPS(adafruit_gps.GPS):
    def _update_timestamp_utc(self, time_utc, date=None):
        adafruit_gps.GPS._update_timestamp_utc(self, time_utc, date)
        if date is not None:
            rtc.RTC().datetime = self.datetime

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions