Low Power

  • low_power
  • sleep
  • rtc

esp_timer_get_time() returns only the time elapsed since boot. If the device has no external RTC, how can the system sleep time be obtained?

esp_timer_get_time() returns a microsecond timer value accumulated only during the current software runtime. After the chip enters deep sleep, most hardware is powered down and the internal timer stops running, so the timer does not continue increasing while the device is asleep.

In other words, esp_timer_get_time() cannot provide a total elapsed time that includes deep-sleep duration.

If the device does not have an external RTC, the recommended approach is to obtain standard time through NTP after the device connects to the network. For more information, refer to the ESP-IDF system time documentation:
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/api-reference/system/system_time.html