[Resolve] Failed to connect to ESP32: Timed out while waiting for packet header

Learn how to resolve the Fatal Error that Occurred: “Failed to connect to ESP32: Timed out waiting for packet header” error while trying to upload new code to your ESP32 board once and for all.

Why are you getting this error?

When uploading new code, some ESP32 development boards may not automatically enter flashing or uploading mode.

This means that the Arduino IDE fails to connect to your board when you try to upload a new sketch to your ESP32, and you see the following error message:

timed out waiting for packet header

Holding the BOOT/FLASH button

One way to fix this is to simultaneously upload a new sketch and hold down the “BOOT/FLASH” button on your ESP32 board. However, worrying about this each time you upload new code may be tiresome, particularly when you're testing and debugging your code. There is a way to resolve this issue once and for all: no longer do you need to hold down the “BOOT/FLASH” button.

How to fix the Error?

Connect a 10 uF electrolytic capacitor between the EN pin and GND to put your ESP32 board into flashing or uploading mode automatically.

To make sure it works for your ESP32 development board, you may want to test this setup on a breadboard first.

esp32 capacitor flashing mode automatic

Note: Electrolytic capacitors have polarity. The white/grey stripe indicates the negative lead.

If it works, solder the 10 uF electrolytic capacitor on the circuit board. Because the EN and GND pins of the ESP32 chip are so far apart, you may simply connect the capacitor between the EN and GND, as shown in the schematic diagram below:

esp32 capacitor flashing mode automatic 2

The following image shows how my ESP32 looks after soldering the capacitor. It doesn't occupy much space, and thankfully, you won't have any more trouble connecting to the ESP32 when you upload new code.

fix timed out waiting for packet header capacitor f

Check the connections with a multimeter in continuity mode to make sure you haven't inadvertently soldered something to the next pin before trying to upload a new code.

check connections capacitor fix timed out packet header

When uploading new code, you won't need to press the BOOT button if everything is correctly soldered. You will also not get the Fatal Error: “Failed to connect to ESP32: Timed out waiting for packet header” message.

done uploading esp32

Conclusion

We hope you’ve found this trick useful and that it solved your problem. Thanks to Ahmed Samir for the suggestion.

If you like ESP32, you may also like:

We hope you find this tutorial useful. Thanks for reading.

Oh hi there It’s nice to meet you.

Sign up to receive awesome content in your inbox, every month.

We don’t spam! Read our privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *

Developing IoT Projects with ESP32

Automate your home or business with inexpensive Wi-Fi devices