Skip to content

Conversation

@weebl2000
Copy link

@weebl2000 weebl2000 commented Jan 9, 2026

After running with powersaving ON running ESP32-S3 I have noticed that the RTC can run hours ahead after only a few days and it's not possible to set time in the past. Very annoying. According to the specs drift can be 5-10% when in deep sleep.

I understand it might be a security concern, but it's only admins/owners of companion nodes that can set the time anyway.

If somebody knows a better solution than this please let me know. I also don't quite get why GPS time is only synced once automatically. I understand power is a concern but it might be worthwhile looking into it.

Especially with powersaving on the RTC can run hours ahead after only a
few days.
When the RTC drifts ahead and is corrected via clock sync, stored
timestamps can appear to be in the future, causing underflow in
"time ago" calculations (wrapping to ~4 billion seconds).

Changes:
- Add safeElapsedSecs() helper that clamps to 0 if timestamp > now
- Apply to neighbor "heard X ago" displays in simple_repeater
- Apply to UI time displays in companion_radio
- Apply to TimeSeriesData calculations in simple_sensor
- Switch BaseChatMesh connection expiry from RTC to millis()

The connection expiry change is the most important: using monotonic
time (millis) makes it immune to RTC adjustments from GPS, NTP, or
manual sync.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant