ESP32 Troubleshooting Guide

ESP32 troubleshooting guide
This post is dedicated to troubleshooting the common ESP32 errors that we will come across as we work with it.

1: “An error occurred while uploading the sketch. A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header”

This is the first error we encountered and it took us a while to figure out what was going wrong. We followed the wiring instructions online but most of the common ones that were available were incorrect and not reliable for some of the ESP32 boards, particularly the ESP32-CAM board.

If you get the error shown above then this is most likely due to incorrect wiring or insufficient power being applied to the board which is causing it to boot-loop or not power at all. If you are using the ESP32-CAM board, then please make sure that you wire the board as shown below and do not forget to connect the 5V power source to the 5V pin.

ESP32-CAM Wiring For Sketch UploadESP32-CAM Wiring For Sketch Upload

If the error persists then measure the voltage at the 5V pin as it has to be close to 5V, we noticed inconsistent operation when the supply voltage drops to even 4.7V. So make sure you have a good 5V power source or use a USB breakout board to obtain it. Using the power from the FTDI (FT232 or other USB-serial) breakout board also leads to the error shown above, on some boards. If you are sure about the 5V power then make sure you have wired the Tx and Rx pins correctly, try swapping them to check.

How To Check If The ESP32-CAM Is Working Correctly

The simplest way to make sure that you have the wiring and power required to upload code to the ESP32 board (ESP32-CAM in this case) is to wire it as following, in the boot mode and then open up the serial monitor with a baud rate of 115200.

ESP32-CAM Wiring For Sketch UploadESP32-CAM Wiring For Sketch Upload

Then, press the reset button and make sure you get output similar to the one shown below:

ESP32 Serial Output Sketch Upload Boot ModeESP32 Serial Output Sketch Upload Boot Mode

If you receive an output like this, then you can be sure that the Tx, Rx pins are connected correctly and that the board is safely powered ON. Once you upload the sketch and remove the boot-mode jumper, the output will change and it is recommended to keep the serial monitor open to view any errors or resets. If sufficient power is not available then the board will reset itself and throw a “Brownout detector was triggered” error to the serial terminal.