1

We are using ESP32 with arduino sdk for developing our application. In our application we need to implement BOD to detect with specific voltage level.

Basically we want to set specific voltage level and when device goes to power off it will detect and trigger interrupt. How I can set interrupt for brown out detect?

we have only this code:

#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"

void setup() {
  Serial.begin(115200);
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1); //enable brownout detector
}

void loop() {
  Serial.println("Start BOD");
  delay(1000);
}
1
  • You need to explain a bit better what you're trying to do. Do you want to execute some code when the power fails? Without additional hardware, that could be difficult, since when the power is off, the board is off, too.
    – PMF
    Jan 20 at 7:52
1

The ESP32's on-board BOD is mainly intended to inhibit operations that might cause corruption if they happened with too low a voltage. There is a very unpredictable amount of time for the code in the ESP32 to do anything but effectively halt.

If that's what you want, then you have enabled it in your code above.

If you want to detect a power outage, for example, and log something, then you need two things:

  1. A reliable detector that the power has failed.
  2. A battery or capacitor-based circuit that will continue the ESP32's power for long enough for you to do what you need to do.

So when "1" happens you set a GPIO pin on the ESP32 which triggers your interrupt and you do what you need to do while the power remains stable.

1
  • Are you talking mains power or some other source of power (AC or DC)? Is the ESP powered from that source or another source? How much time will be left from when the power browns out until you lose control? Do you plan on using the A/D or an external comparator?
    – Gil
    Jan 20 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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