Skip to main content
  • esp32
  • boot loop
  • reset diagnosis
  • power faults
  • watchdog
  • embedded debugging

ESP32 Boot Loop: Read the Reset Before Fixing It

The Boss Factory9 min read

An ESP32 boot loop is rarely fixed by changing random delays or reflashing the same firmware. Read the reset reason first, then remove the loads and cut the program back until the failure has nowhere left to hide.

Read the reset reason before changing code

On an ESP32 running ESP-IDF, the reset reason is recorded and readable at start-up through the reset-reason API, commonly esp_reset_reason(). It separates a brownout from a watchdog reset or a software reset caused by a crash immediately at the next boot. That classification determines which branch to test first.

Print the result before starting Wi-Fi, mounting a filesystem, or launching application tasks. If the boot message itself consumes too much time or depends on the failing peripheral, store the result in a small retained record and print it on the next successful start.

The useful first split looks like this:

  • Brownout: supply voltage fell below the brownout detector threshold. The board may recover as soon as the load disappears.
  • Watchdog: a task, interrupt path, or startup routine failed to yield or blocked for too long. A peripheral driver can cause this without having a power problem.
  • Crash or panic: invalid memory access, failed assertion, stack failure, or another software fault caused the processor to stop. The reset reason may identify the resulting software reset, while the panic output identifies the failing code path.
  • External reset: the enable pin, reset circuit, or another controller restarted the board.

The exact reset names depend on the ESP32 family and framework version. Read the enum and startup log for the chip variant in use rather than matching a shortened label from a different board. A reset reason identifies the class of failure, not automatically the bad component.

Prove whether the load is electrical

A board that boots with all peripherals disconnected points at the load rather than the firmware. That is the most valuable isolation result in this entire test. Reconnect one peripheral at a time, and keep the wiring short enough that you know which device changed the result.

Start with the parts that create sharp current changes: radios, displays with backlights, motors, servos, relays, heaters, addressable LEDs, and sensors with their own regulators. A USB cable can run the board successfully while the installed supply fails, because the cable and host provide a different source impedance and current limit.

The electrical failure path:

  • A regulator reaches its current limit during radio transmission or LED startup.
  • A thin trace, jumper, breadboard contact, or connector adds resistance between the regulator and the board.
  • A peripheral pulls the rail low during inrush, even though its average current looks acceptable.
  • A motor or relay sends noise through a shared ground or supply path.
  • A long cable picks up interference or develops enough voltage drop under load to trigger brownout.
  • Heat raises regulator resistance or reduces available output current until the fault appears only after several minutes.
  • Moisture or contamination creates leakage between pins, especially around high-impedance inputs and exposed connectors.

Measure voltage at the ESP32 module's supply pins during the failure, not only at the power supply. A steady reading at the supply terminals proves little if the return path is poor. Use a meter, checking idle voltage, startup voltage, and the voltage during the exact event that causes the device keeps restarting message.

Do not buy an oscilloscope yet just because the board reboots. A meter, a known-good supply, a few temporary wires, and a methodical disconnect test answer the first question more cheaply. An oscilloscope becomes useful when the meter misses a short voltage dip, reset-line spike, or switching-noise event.

ObservationMost likely branchWhat to test nextTypical failure mode
Brownout with peripherals attachedPower path or loadSupply pins during startup and peak activityVoltage sag from inrush, resistance, or current limiting
Brownout with no peripheralsBoard supply, regulator, or wiringKnown-good supply and short power leadsWeak regulator, damaged board, or bad return path
Watchdog with one driver enabledFirmware or blocked peripheral transactionDisable that task, then test timeouts and yieldsI2C, SPI, network, or interrupt path blocks too long
Crash or panic before peripheral setupFirmwareMinimal program and panic outputInvalid access, stack exhaustion, or bad initialization
Stable boot with all loads removedAttached load or its wiringReconnect one device at a timeInrush, pin conflict, level mismatch, or noisy ground
Reset after heat or moisture exposureThermal or environmental faultReproduce warm, dry, and under loadRegulator derating, condensation, leakage, or corrosion

Cut the firmware back to a known boot

If disconnecting peripherals does not stop the reset, reduce the software until it contains only startup, a serial message, and a long idle loop. Do not leave the old initialization code commented around the test. Remove it from the build or place it behind a compile-time switch so that constructors and background tasks cannot still run.

Then add one subsystem per test:

  1. Boot the minimal program repeatedly from the same power source.
  2. Add the GPIO setup, but leave external devices disconnected.
  3. Add the bus driver without its transaction loop.
  4. Add one peripheral initialization call.
  5. Add its read or write operation with a timeout.
  6. Add the task, timer, interrupt, or callback that normally services it.
  7. Add networking, storage, display updates, and other high-activity work last.

This order distinguishes a bad pin configuration from a bad transaction and a bad transaction from a scheduling fault. It also prevents the common mistake of blaming the last line printed. The last message is only the last operation completed before the reset, not necessarily the operation that caused it.

For watchdog resets, inspect blocking calls, loops that wait for a flag forever, interrupt handlers that do too much work, and tasks with insufficient stack. For crashes, keep the panic output and use the reset reason as the first classification. Do not replace a crash with a longer delay and call the result fixed. A delay can hide a race while leaving the invalid access intact.

A device that boots only when logging is enabled deserves suspicion. Serial output changes timing, task scheduling, and sometimes power consumption. Treat that change as evidence of a race, marginal supply, or uninitialized state, not as a cure.

Find the physical weak point

Once the failing subsystem is known, follow its complete load path. Current leaves the regulator, crosses a trace or wire, passes through a connector or breadboard contact, enters the peripheral, and returns through ground. Every joint in that path can create a voltage drop or an intermittent connection.

The stress risers in a small electronics build are often mechanical rather than electrical. A board mounted against a warped panel can flex when a cable is inserted. A solder joint can crack where a heavy wire leaves the board. A connector can carry cable movement directly into a header pin. Repeated thermal expansion can fatigue a marginal joint even when the board works on the bench.

Secure cables independently, support heavy parts, and keep high-current paths short and wide enough for the actual load. Separate noisy loads from sensitive logic supplies where practical. Add local bypass capacitance according to the board and peripheral datasheets, but do not use a larger capacitor as a substitute for an undersized regulator or a bad ground path.

For a heat-related failure, measure the regulator and nearby components after the fault appears. Ventilation, lower duty cycle, a regulator with suitable thermal capacity, or a lower-current peripheral may be the right fix. For moisture, remove the source, clean contamination, improve enclosure drainage and cable entry, and check for corrosion under connectors. Conformal coating is not a repair for trapped water or an inaccessible connector.

Make the fix survive service

The fastest bench fix is not always the design that survives repeated power cycles. Once the cause is known, retest the complete system in the conditions that produced it: cold start, warm restart, maximum radio activity, brightest LED state, motor or relay switching, cable movement, and the intended enclosure.

Our preferred design change is to make the fault visible and the load path boring. Keep reset logging in the startup path, give each major peripheral a controlled initialization step, set transaction timeouts, and avoid allowing one failed device to hold the whole application in an endless wait. Feed high-current loads from a supply path sized for their peak demand, with logic power and returns arranged so load pulses do not pass through sensitive ground connections.

A reset counter and last-known subsystem marker are useful service records. They should survive long enough to explain the next failure without masking the original reset reason. Clear them only after a clean boot and a deliberate acknowledgment, not on every startup.

The cheap fix is good enough when the test proves a loose jumper or overloaded breadboard contact is the only problem. Replace that connection and retest before designing a custom power board. The upgrade is not automatically better. A new regulator, larger capacitor, or faster microcontroller fixes a problem you do not have if the actual cause is a watchdog waiting forever on a disconnected sensor.

Frequently asked questions

Why does my ESP32 boot loop stop when I unplug the sensor?

The sensor or its wiring is now the leading suspect, not the firmware alone. Check the supply voltage at the ESP32 during sensor startup, confirm shared ground, inspect pull-ups and logic levels, and reconnect the sensor only after the minimal firmware boots reliably.

Can a watchdog reset be caused by low power?

Yes, indirectly. A voltage disturbance can corrupt a transaction or stall code long enough for a watchdog to fire, and some peripherals can lock a bus when their supply is unstable. Read the reset reason, then test the rail and the blocked code path separately.

Should I disable the brownout detector?

No, not as a repair. Disabling it can turn a visible supply fault into corrupted data, unpredictable peripheral behavior, or repeated crashes. Fix the supply path first, then change the detector only for a controlled experiment with a documented reason.

We build custom electronics, smart systems, and software to order through this request form.

Related services

All services →

Have a project in mind?

Tell us what you want built — we reply within 24–48 hours.

Request a quote

Keep reading