5

I want to use the ESP32 built-in RTC clock. In my situation, my ESP32 will not have access to an NTP server I do not want to use external RTC modules

ESP32 provides a pin VDD_RTC will powers the RTC domain exclusively My problem would be solved if I attach a coin cell to this pin. In this case, in the event of a brownout, the VDD_RTC will be powered and RTC clock preserved.

But, all dev kits I have seen seem to have VDD_CPU, VDD_DSIO and VDD_RTC connected together So, if I would use a battery or some sort of small ups to power my ESP32 during brownout, it will be depleted by the use of GPIOs and CPU and other functions.

Solution would be here to detect brownout and force ESP32 to go to deep sleep, and then wake it up after brownout. But this would require an external source attached to a ESP32 pin to trigger deep sleep, and I don't see any pin to trigger it

Maybe I could have a circuit that would give me a signal when there is a brownout. I could attach this signal to a GPIO pin and trigger an interrupt that makes ESP32 go into deep sleep

But it seems too much for something that I am sure is super basic and should be implemented already somehow in a more convenient way

Could anyone share with me any experiences of how to preserve RTC using minimum external circuitry?

2
  • 1
    have you looked at the ESP32 datasheet? ... or ESP32 application note ... one of then may have a recommended circuit schematic
    – jsotola
    Commented Nov 26, 2021 at 16:47
  • 1
    I did and I couldn't find anything interesting
    – mquevedob
    Commented Nov 27, 2021 at 23:44

1 Answer 1

1

You don't need to do anything special to detect Brownouts. ESP32 itself detects them, and would reset the chip automatically. The reset reason would then indicate a brownout (don't remember the exact name). So you only need to check for the reset reason at the start of your code, whether it is normal powerup, or brownout. The esp won't boot up until the brownout is over, so you don't even need to check when the brownout condition starts nor when it stops.

Moreover, in general (irrespective of brownouts) you don't need any external pins to set the esp32 to sleep, nor do you need them to wake it up. You simply call:

esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start();

The first line tells the esp how long to sleep. The second one initiates deep sleep. The esp32 (unlike the esp8266), will automatically wake itself back up. If a brownout happens while it is asleep, it will boot up again once the brownout is over, but the wake-up reason would be different depending on the case.

The default voltage that triggers the brownout condition is I think 2.8V. This is only configurable in esp-idf, not Arduino. But you don't have to worry about it. Above 2.8V the esp32 continues to keep time correctly. Below 2.8V, it halts, then wakes up once it rises above 2.8V. However, if you don't use an external RTC, and don't use a stable power source, there is no way to keep track of time after the brownout. You can't know how long the brownout was. There is no way to do this. The only option is then to find the pin that supplies the RTC alone, sever it, and wire it to a separate battery. This requires alot of SMD skills.

2
  • I think built-in brownout detector is not good for me because it resets the chip. I need it to go to sleep in order to keep the internal RTC running.
    – mquevedob
    Commented Jan 9, 2022 at 5:25
  • there was a discussion on this blog a while ago -- esp32.com/viewtopic.php?t=1558
    – mquevedob
    Commented Jan 9, 2022 at 5:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.