According to the manufacturer's link below, the default RTC timekeeping in the ESP32 is supposedly based on Internal 150 kHz RC oscillator.

Apparently, there is another option called Internal 8.5 MHz oscillator, divided by 256 (~33 kHz) that has better stability without needing an external crystal. That link goes on to say that

To modify the RTC clock source, set CONFIG_RTC_CLK_SRC in the project configuration.

All good information but NO EXAMPLES given. Can anyone point me to an example showing

  1. how I can prove what the current clock source is, and
  2. how to set actually it?


  • The default is 150kHz RC, see docs.espressif.com/projects/esp-idf/en/latest/esp32/…
    – hcheung
    Commented Apr 11, 2023 at 3:57
  • @hcheung Please don't answer questions with links that you have not read. I know all about the defaults and other options. The document does not show how to go about changing it.
    – Randy
    Commented Apr 12, 2023 at 5:22
  • Please don't assumed that I didn't read the document just because you don't understand it. The document is clearly said that "To modify the RTC clock source, set CONFIG_RTC_CLK_SRC in project configuration", it further provide the link to CONFIG_RTC_CLK_SRC page which again clearly indicated that the configuration is part of Component config > Hardware Settings > RTC Clock Config which you can find it here.
    – hcheung
    Commented Apr 12, 2023 at 6:14
  • In summary, you are presuming that it can be dynamically change via programming, but it is not, you need to Edit sdkconfig.defaults file, set CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256=y and run idf.py to build it.
    – hcheung
    Commented Apr 12, 2023 at 6:26
  • 1
    @hcheung my apologies then. Too many people post a link assuming it answer the OP question. The is no "sdkconfig.defaults" on my system,. There plenty of sdkconfig.h for each board, and there is one file "sdkconfig" file with no extender. The .h files indeed have macros defining those options. I did make the change you suggested in that file, also commenting out the default one. But I do not have an idf.py file, and would not know how to run it. Is there a document that offers all the steps and where to get the needed tools? Thanks in advance.
    – Randy
    Commented Apr 12, 2023 at 14:29


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.