Search code examples
esp32arduino-ide

ESP32 CAM module: A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header


I am getting the error below. I pressed the reset button of the esp32 cam but it didn't work. Kindly help. Arduino: 1.8.12 (Windows 10), Board: "AI Thinker ESP32-CAM, 160MHz (WiFi/BT), QIO, 80MHz"

Sketch uses 699158 bytes (22%) of program storage space. Maximum is 3145728 bytes.
Global variables use 38104 bytes (11%) of dynamic memory, leaving 289576 bytes for local variables. Maximum is 327680 bytes.
C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0/esptool.exe --chip esp32 --port COM4 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/partitions/boot_app0.bin 0x1000 C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/bin/bootloader_qio_80m.bin 0x10000 C:\Users\DELL\AppData\Local\Temp\arduino_build_210700/WiFiScan.ino.bin 0x8000 C:\Users\DELL\AppData\Local\Temp\arduino_build_210700/WiFiScan.ino.partitions.bin 
esptool.py v3.0-dev
Serial port COM4

Connecting........_____....._____....._____....._____....._____....._____....._____


**A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header**


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Solution

  • Because the ESP32-CAM doesn't have a USB port, you must use an FTDI adapter to connect it to your computer to program it. To do this, you must flash it properly.

    To flash it properly, first follow this wiring from your FTDI adapter to your ESP32-CAM: FTDI to ESP32-CAM wiring

    Then upload the code. You should see a message in the Arduino IDE saying that it is compiling. At some point during that process, the FTDI adapter should start flashing, during which you want to press the reset button on the ESP32-CAM.

    Once the code has fully uploaded, you need to remove the jumper cable connect the IO pin 0 to GND, and then press the reset button again.

    After this, the code should start working and you can disconnect the ESP32-CAM from the FTDI adapter. You need to repeat this process every time you want to upload code onto the ESP32-CAM.

    This is a YouTube video of someone demonstrating it in more detail: https://www.youtube.com/watch?v=JYchUapoqzc

    Good Luck!