
You’ve built a beautiful IoT project. The code uploads perfectly. But the exact second the code reaches WiFi.begin(), the board abruptly dies, restarts, and prints this error:
Brownout detector was triggered
Your ESP32 isn’t broken; it’s just starving. Wi-Fi draws a massive spike of power, and your USB cable is too weak to feed the beast. Let’s fix your sad power supply.
A brownout is not a software bug; it is a power supply failure.
The ESP32 is a very power-hungry chip compared to an Arduino Uno. While idling, it draws very little current. However, the moment the Wi-Fi radio activates to connect to your router, it draws a massive spike of current (often over 400mA for a fraction of a second).
If your power supply (or USB port) cannot provide that burst of current quickly enough, the voltage on the board sags (drops from 3.3V down to maybe 2.5V). The ESP32’s internal safety circuitry detects this voltage drop and immediately resets the chip to protect itself.
1. Ditch the Cheap USB Cables The most common culprit is a long, thin, cheap USB cable. Thin wires create high resistance, which causes voltage drop during current spikes. Try a high-quality, thick, and short USB cable.
2. Don’t Rely on Unpowered USB Hubs If your ESP32 is plugged into an unpowered USB hub, or the front panel of a desktop computer, it might be starving for current. Plug it directly into a USB 3.0 port on the motherboard or a dedicated phone charger.
3. Use an External Power Supply
If you are running the ESP32 alongside relays, servos, or sensors, USB power isn’t going to cut it. You need a dedicated 5V power supply (like we covered in our Bench Power Supplies Showdown). Feed the 5V directly into the VIN or 5V pin on the dev board, rather than relying on the USB port.
4. The Band-Aid Fix (Not Recommended)
You can disable the brownout detector in code by including #include "soc/soc.h" and #include "soc/rtc_cntl_reg.h", and adding WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); to your setup. However, this doesn’t fix the power issue; it just forces the chip to keep running on unstable power, which can lead to corrupted flash memory and bizarre behavior. Fix the hardware first!