Skip to content

Add CRSF GPS Date/Time from Serial connected GPS - #3662

Merged
mha1 merged 3 commits into
ExpressLRS:masterfrom
pkendall64:4.1/serialgps-datetime
Jun 16, 2026
Merged

mha1 merged 3 commits into
ExpressLRS:masterfrom
pkendall64:4.1/serialgps-datetime

Conversation

@pkendall64

Copy link
Copy Markdown
Collaborator
  1. Parse RMC GPS message which contains the date & time.
  2. The time is also updated from the existing GGA message.
  3. Send CRSF GPS Time message once we have seen an RMC message

This was requested as a comment on #3642

@pkendall64 pkendall64 added enhancement 🪄 New feature or request V4.1 🍑 labels May 31, 2026
@zhouruixi

zhouruixi commented May 31, 2026 •

Copy link
Copy Markdown

Thanks for your quick response. I have tested on an MT12 (EdgeTX v2.12.1) + Helloradio HR8E, and able to successfully retrieve the date and time from GPS.

Since the RTC battery in my radio has run flat, my primary objective in using this feature is to set the radio's date and time via GPS. Because EdgeTX can set the GPS time zone, So I don't really care whether it's UTC time or not.

1 2 3

@CapnBry

CapnBry commented May 31, 2026

Copy link
Copy Markdown
Member

You never let anyone else have any fun! 😠 I also implemented this this morning haha

I have two differences though I think are improvements:

  • Should not parse the time from the GGA sentence. The full date and time are in the RMC sentence and your code also requires this, so why double up on parsing the value?
  • Only send the time every 10 seconds instead of with every GPS update. I don't think it should be appended to every position update, which guarantees that it has higher latency due to the queuing mechanism putting the position packet in first, and then the time update. It isn't a big deal considering it always has a pretty high latency anyway, but it doesn't need to be sent every second and delay the position updates. It should just be published at the end of the splitSentenceFields() call, doesn't need a hasDateTime boolean (just check that the year is non-zero)

I also made it autobaud with 115000 fallback if no data is received in 10 seconds, but I can make a separate PR for that or I can tack it on here after you're done if you want?

@ot0tot

ot0tot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

EdgeTX recently added support for setting the handset RTC from CRSF GPS Time frames (EdgeTX/edgetx#7317), and I recently added support to Betaflight to forward these frames also (betaflight/betaflight#15167). In testing, however, the handset RTC ends up 2–9 seconds behind actual UTC. I believe most of this is due to the delay between when the GPS time message is received and when it is enqueued, sent, and read at the handset. Using normal packets, the 11-byte GPS Time frame would take 3 telem packets to send, which depending on packet rate, telemetry ratio, retries, etc, could add appreciable delay.

I think the most common use case for this is when the RTC battery is low/dead or people want accurate time on the handset to sync logs between multiple platforms. Thus having an accurate RTC is desirable.

Would it be possible to add a timestamp and shift the GPS time at the RX side between when the GPS message enters the telemetry queue and when it is sent, and at the TX side between when the first chunk is received and when HasFinishedData() fires? I am working on a potential solution, but am unsure of the best way to implement it. Do you have any thoughts?

Edit: Potential solution in: #3664

@pkendall64

Copy link
Copy Markdown
Collaborator Author

@CapnBry happy for you to make whatever changes you feel are required.

@CapnBry

CapnBry commented Jun 1, 2026

Copy link
Copy Markdown
Member

After copying my changes in and testing, I think every 10s is too long because that could become a "sensor lost" message on EdgeTX when the transmission starts taking too long. At every 5s, that's gives more fudge factor but every 5s vs every 1s isn't really enough I feel to warrant the extra code.

Instead I split the publish into two functions rather than doing them at the same time, and publish immediately after the RMC sentence. I dunno. This could be reverted, both the old and new code are basically the same.

I did remove the UTC time update from GGA, since the date and the time are split across sentences you theoretically could have an RMC that's configured to come every N GGA messages, which could split the time across a new date and make the reported time non-monotonic. It would quickly fix itself, but I think it is safer to have the RMC be fully atomic. The old code could also keep sending the wrong date if RMC stopped coming for some reason after the first one so now it will only send the telemetry item immediately following a successful date parse.

Again these changes are so incredibly minor that I contemplated not even submitting any, and I'd have no issue with you reverting them if you feel the original was better.

@mha1
mha1 merged commit 1436a19 into ExpressLRS:master Jun 16, 2026
26 checks passed
@pkendall64
pkendall64 deleted the 4.1/serialgps-datetime branch June 23, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 🪄 New feature or request V4.1 🍑

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants