adafruit / adafruit/Adafruit_CircuitPython_GPS

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

Open
#77 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
80
Forks
61
Avg merge
22d 17h
Merged PRs (30d)
1

Description

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

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the adafruit_gps.GPS API, especially GPS.update and the datetime property, and review how NMEA sentences update the timestamp. Document that datetime can remain from a previous update and that date information is available only from RMC sentences; done means users can recognize when the value may be stale and avoid setting an RTC from it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, embedded-iot
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.