-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Is there any easy way to change the RTC clock source? #8073
Comments
Probably true.
There may be function calls to change the RTC clock source, but I'm not aware of them. FYI changing RTC clock source to main oscillator may increase current consumption and may not work properly with sleep mode. |
Thanks mrengineer777, and I suspect what you're saying is true. I'm thinking my post might be better placed as a feature request. I can't see any reasonable reason why the clock source options could not be made into a simple core api call. In the mean time I'm a biz suspicious as to what th real default is in every board. I say that because I ran a test where I sync my systemtime to an NTP source, disconnect from WiFI to prevent any more resycing, and then displaying the system time every 5 minutes, using the "show timestamp" option in the arduino serial monitor. In 24 hours it only goes off by a few seconds, which sounds unbelievably good for an "RC Oscillator". And along with not having an api call to set the source, there doesn't seem to be one to test what it is currently. |
The RTC on my demo board loses about 30 seconds per day. Not great, which is why I keep SNTP service on. |
@mrengineer7777 Right! Honestly I got so used to using one of those cheap battery backed RTC add ons that use the DS3231 chips, from back in the days when WiFi connectivity wasn't a given, This project is the first time I though about using the NTP service. But this particular project only needs to send a daily email report, and the time is not the least bit critical. So I'm hoping to be able to just connect on a pre-programmed hour to send the daily report, and do an NTP time sync while I'm connected, and then disconnect. So anything within even a couple of minutes/day is tolerable. Just seems silly to not be able to depend on the better clock source option. In fact, even if I wanted to try the 32Khz crystal option I could not, because setting the clock source is not part of the API. Well it is what it is, so I'll make do. :-) |
Feature request to add functions to control RTC clock source. Can someone verify these don't already exist? |
There was a discussion about ESP32 deep sleep timing instability here: @tomocchi3411 provided some nice code to assign the RTC to the 8M/256 source, as well as code to calibrate the RTC. |
Hello, Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket. Thanks. |
Board
ESP32 (DOIT ESP32 DEVKIT V1)
Device Description
as above. On connections to external components right now
Hardware Configuration
Nothing connected. General feasibility question
Version
latest master (checkout manually)
IDE Name
Arduino
Operating System
Windows 10
Flash frequency
Don't know
PSRAM enabled
yes
Upload speed
115200
Description
The document at https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html explains that "To modify the RTC clock source, set CONFIG_RTC_CLK_SRC in project configuration". The document also tells that the default clock source is "Internal 150 kHz RC oscillator" and that another more stable option is "Internal 8.5 MHz oscillator, divided by 256 (~33 kHz)". Am I correct in saying there is no way to se the latter option programmatically from within a sketch done in the arduino IDE? By poking around I have found options for these clock sources in a header file called "sdkconfig.h", and there is another file I found, "sdkconfig" (with no extension) which sates in comments that is a file that was built, and should not be edited. That file does indeed show what clock source is enabled and which other ones aren't set. But no changes to either of those files affect anything when I compile a project in the IDE.
So again, just to confirm: First, is setting the clock source withing an arduino built sketch impossible? and Second, is there any way short of installing expressif's entire toolset, including python that could accomplish the clock source change?
Sketch
Debug Message
Other Steps to Reproduce
I don't know
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: