Learn how to fix the: “Failed to connect to ESP32: Timed out waiting for packet header” error when trying to upload new code to your ESP32 board once for all.
Why are you getting this error?
This means that when you try to upload a new sketch to your ESP32, the Arduino IDE fails to connect to your board, and you get the following error message:
Holding the BOOT/FLASH button
One of the ways to solve this is holding-down the “BOOT/FLASH” button in your ESP32 board while uploading a new sketch at the same time. But having to worry about this every time you want to upload new code can be tedious, specially when you’re testing and debugging your code. There is a way to fix this once for all – no need to hold down the “BOOT/FLASH” button anymore.
How to fix the Error?
To make your ESP32 board go into flashing/uploading mode automatically, you can connect a 10 uF electrolytic capacitor between the EN pin and GND.
You may want to test this setup first on a breadboard to make sure it works for your ESP32 development board.
Note: electrolytic capacitors have polarity. The white/grey stripe indicates the negative lead.
If it works, then you can solder the 10 uF electrolytic capacitor to the board. Since the EN and GND pins are far apart from each other, you can simply connect the capacitor between the EN and the GND of the ESP32 chip as shown in the schematic diagram below:
The following figure shows how my ESP32 looks like after soldering the capacitor. It doesn’t occupy much space, and fortunately you won’t get more trouble connecting to the ESP32 when uploading new code.
Before trying to upload a new code, you should check the connections with a multimeter in continuity mode – check that you haven’t inadvertently solder anything to the next pin.
If everything is soldered properly, you won’t need to press the BOOT button when uploading new code. You also won’t get the “Failed to connect to ESP32: Timed out waiting for packet header” error.
We hope you’ve found this trick useful and it solved your problem. Thanks to Ben Hall for the suggestion.