Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Why Does My ESP32 Keep Restarting or Crashing After Upload?

Introduction

Uploaded your sketch successfully, but the ESP32 just keeps restarting again and again? Or maybe it runs for a few seconds and then crashes? Don’t worry — you’re not alone. In this post, we’ll break down the most common reasons why your ESP32 keeps resetting or crashing after uploading code, and how you can fix it quickly.

What Does “Restarting” Look Like?

You’ll often see messages like these in the Serial Monitor:

ets Jun  8 2016 00:22:57  
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)  
...

Or sometimes you see:

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

These are clear signs that something is going wrong after code upload.

Common Reasons Why Your ESP32 is Restarting or Crashing

1. Power Supply Issue

If you’re powering your ESP32 from a weak USB port or a bad cable, it may not be getting enough current — especially during Wi-Fi or Bluetooth startup.

Fix:

  • Use a high-quality USB cable and connect to a proper USB 3.0 port.
  • Try using a 5V 1A power supply (phone charger + USB cable).

2. Watchdog Timer Resets

ESP32 has watchdog timers that reset the chip if code gets stuck in a loop or takes too long in one task.

Fix:

  • Make sure you use delay() or yield() in long loops to prevent watchdog resets.
  • Avoid infinite while loops without breaks.

3. Faulty Peripherals or Sensors

If something connected to the GPIO pins is shorted or drawing too much power, the ESP32 might crash or enter a reboot loop.

Fix:

  • Disconnect everything from GPIO pins and test with only USB connected.
  • Reconnect peripherals one by one to find the culprit.

4. Code Consumes Too Much RAM

Memory overflows can lead to crashes, especially if you’re using large arrays, images, or web server libraries.

Fix:

  • Use the ESP.getFreeHeap() function to monitor RAM usage.
  • Optimize code: use String carefully, minimize global variables.

5. GPIO Conflicts During Boot

Certain pins on the ESP32 must be in specific states at boot time. Using them incorrectly can cause boot loops.

Fix: Avoid using these pins during startup:

  • GPIO 0, 2, 15 – used for boot mode selection
  • GPIO 6–11 – connected to flash memory internally

6. Exception or Panic Errors

Guru Meditation Errors or panic dumps usually mean a memory or code execution problem.

Fix:

  • Recheck your code logic
  • Use Serial.print() debugging to find the crashing line
  • Simplify your code to isolate the problem

Quick Checklist to Fix Restarting Issues

Check What to Do
Power Supply Use good USB cable / external 5V
Peripherals Disconnect sensors & modules
Code Avoid infinite loops, delays, large data
GPIO Pins Don’t use 0, 2, 15 wrongly
Serial Monitor Watch for crash messages
Flash Settings Re-upload with correct board settings

Bonus Tip: Use esp_reset_reason() in Code

Want to know why your ESP32 reset? Use this:

#include "esp_system.h"

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("Reset reason: ");
  Serial.println(esp_reset_reason());
}

It will show messages like POWERON_RESET, SW_CPU_RESET, or DEEPSLEEP_RESET — helping you diagnose better.

Conclusion

Crashes and restart loops may look scary, but most of the time the fix is simple: clean power, clean code, and correct pin usage. If your ESP32 is crashing right after upload, don’t panic — use the tips above to track down the cause, one step at a time.

    Leave a Reply

    Your email address will not be published.

    Need Help?