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

Learn how to fix the Fatal Error Occurred: “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.

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

Why are you getting this error?

Some ESP32 development boards (read Best ESP32 boards) don’t go into flashing/uploading mode automatically when uploading a new code.

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:

Recommended: ESP32 Pinout Reference: Which GPIO pins should you use?

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.

fix timed out waiting for packet header with capacitor testing

If everything is soldered properly, you won’t need to press the BOOT button when uploading new code. You also won’t get the Fatal Error Occurred: “Failed to connect to ESP32: Timed out waiting for packet header”.

Wrapping Up

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


Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »


Enjoyed this project? Stay updated by subscribing our weekly newsletter!

18 thoughts on “[SOLVED] Failed to connect to ESP32: Timed out waiting for packet header”

  1. I wonder what would occur if I used a 100uf Capacitor instead of the 10uf one as recommended in the post above? Would it hurt the ESP board?

  2. I have an ESP32 with this problem. I have added the capacitor as described in the article. Now the upload start automatically, but the software does not start. I I press the reset I obtain the following message
    rst:0x1 (POWERON_RESET),boot:0x0 (DOWNLOAD_BOOT(UART0/UART1/SDIO_FEI_FEO_V2))
    waiting for download

    the only way to start the program is to switch off and the switch on again the esp32.
    Any Idea?

  3. I have resolved the problem in my previous post by adding a resistor of one 1kohm between the pin EN and the 3v.
    Now the upload runs automatically and the reset maintain its function.

  4. I would like to add that in some cases, with some esp32 I must add a 47 uF capacitor + resistence of 1Kohm for resolving the problem.

  5. Muito Obrigado pelo excelente post, me ajudou e muito e tenho certeza que vai ajudar muitas outras pessoas. “Compartilhar conhecimento só enriqueci o nosso saber”

  6. Hello, thanks for the info.

    I have the same problem, but the device I’m using is ESP-32 CAM, so the pinouts are different from the original ESP-32. Do you have a solution for this? Thanks again in advance.

  7. I have a Lolin D32 board which was giving this error. It has only one button(Reset). I put the capacitor like suggested above but the error was persistent. As a last ditch effort I used a jumper on GPIO0 to GND during compile and upload(I use Arduino IDE). Now the code is uploaded without a problem. I remove this jumper and the board functions as programmed.

    • Hi.
      Thank you for sharing your solution. It will certainly be useful for other readers that use the Lolin D32 board.
      Regards,
      SAra

  8. Thank you for the article. I have exactly the same board as in your pictures. It was enough to use 2.5 uF and no resistor was needed. However I didn’t like the metal can of the capacitor so close to the antenna. An alternative location is negative to the pin of the AMS1117 that is closest to the USB connector, positive to the middle pin of the transistor closest to D2. And of course if project allows, the capacitor can be applied on the underlying project PCB.

  9. Many thanks, it worked!
    Is this for esp8266 or is it just in case of this error in esp32? Well, I noticed that the sketch loads faster.

Leave a Comment

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.