Skip to content

Fix: Reset ESP32 RTC clock on software reset #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

rightup
Copy link
Contributor

@rightup rightup commented Aug 6, 2025

Updated ESP32RTCClock::begin() to treat software reset (ESP_RST_SW) the same as power-on reset (ESP_RST_POWERON), ensuring the clock resets to the default time (15 May 2024, 8:50pm) when triggered via the CLI reboot command or any other software-initiated reset.

No personal issues with a good old-fashioned power cycle, but some have reported their clock getting accidentally set far into the future. Probably less funny when the device is zip-tied 8m up a tree ... not exactly reset-button friendly!

Updated `ESP32RTCClock::begin()` to treat software reset (`ESP_RST_SW`) the same as power-on reset (`ESP_RST_POWERON`), ensuring the RTC clock resets to the default time when triggered via CLI reboot command.
@rightup
Copy link
Contributor Author

rightup commented Aug 6, 2025

Hey, just a note: I used Fix: in the commit message, but it’s possible the original behavior was by design, so feel free to treat this as a merge suggestion rather than a bug fix, depending on intent.

Either way, resetting the clock on soft reboot feels like the safer option in the field, especially when devices are zip-tied to trees 😅

@ripplebiz
Copy link
Collaborator

Yeah, this one is a little tricky. It was intentional to keep the ESP system time across soft resets, and I seem to recall it being handy in various contexts. But am struggling to rummage through my memory and figure out if this really should be changed...

@rightup
Copy link
Contributor Author

rightup commented Aug 7, 2025

Totally fair, I figured this might’ve been intentional, which is why I hesitated on calling it a “fix”.

I haven’t personally seen the time set incorrectly, but I’ve noticed a few user reports where the clock jumped a few hours into the future. If that does happen, the only way to reset it is via a power cycle or physically pressing the reset button — which isn’t ideal when the device is mounted somewhere creative.

No problem at all — happy to drop this if it risks interfering with other use cases. I know timing in embedded is always tricky… there’s a reason even Doc Brown had issues with it. 🤣

@recrof
Copy link
Collaborator

recrof commented Aug 13, 2025

if this is not the best solution, can we introduce another command that will reboot with clock reset?

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.

3 participants