How do i fix "Setup Failed: ESP_FAIL" with M5Stack M5Cam?

Hi. I have a issue with esp32_camera.
Logs:

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/esphome-web-6e83dc.yaml...
WARNING GPIO5 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO15 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing esphome-web-6e83dc (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
Compiling .pioenvs/esphome-web-6e83dc/src/main.cpp.o
Linking .pioenvs/esphome-web-6e83dc/firmware.elf
RAM:   [=         ]  13.9% (used 45416 bytes from 327680 bytes)
Flash: [=====     ]  54.0% (used 990457 bytes from 1835008 bytes)
Building .pioenvs/esphome-web-6e83dc/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/esphome-web-6e83dc/firmware.bin"], [".pioenvs/esphome-web-6e83dc/firmware.elf"])
Wrote 0x103380 bytes to file /data/build/esphome-web-6e83dc/.pioenvs/esphome-web-6e83dc/firmware-factory.bin, ready to flash to offset 0x0
========================= [SUCCESS] Took 77.45 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.117
INFO Uploading /data/build/esphome-web-6e83dc/.pioenvs/esphome-web-6e83dc/firmware.bin (996224 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 6.69 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.117 using esphome API
INFO Successfully connected to esphome-web-6e83dc @ 192.168.1.117 in 7.301s
INFO Successful handshake with esphome-web-6e83dc @ 192.168.1.117 in 0.098s
[19:22:31][I][app:102]: ESPHome version 2023.12.9 compiled on Jan 29 2024, 19:21:11
[19:22:31][C][wifi:573]: WiFi:
[19:22:31][C][wifi:405]:   Local MAC: 98:F4:AB:6E:83:DC
[19:22:31][C][wifi:410]:   SSID: [redacted]
[19:22:31][C][wifi:411]:   IP Address: 192.168.1.117
[19:22:31][C][wifi:413]:   BSSID: [redacted]
[19:22:31][C][wifi:414]:   Hostname: 'esphome-web-6e83dc'
[19:22:31][C][wifi:416]:   Signal strength: -46 dB ▂▄▆█
[19:22:31][C][wifi:420]:   Channel: 11
[19:22:31][C][wifi:421]:   Subnet: 255.255.255.0
[19:22:31][C][wifi:422]:   Gateway: 192.168.1.1
[19:22:31][C][wifi:423]:   DNS1: 192.168.1.1
[19:22:32][C][wifi:424]:   DNS2: 0.0.0.0
[19:22:32][C][logger:439]: Logger:
[19:22:32][C][logger:440]:   Level: DEBUG
[19:22:32][C][logger:441]:   Log Baud Rate: 115200
[19:22:32][C][logger:443]:   Hardware UART: UART0
[19:22:32][C][esp32_camera:048]: ESP32 Camera:
[19:22:32][C][esp32_camera:049]:   Name: espcam
[19:22:32][C][esp32_camera:050]:   Internal: NO
[19:22:32][C][esp32_camera:052]:   Data Pins: D0:17 D1:35 D2:34 D3:5 D4:39 D5:18 D6:36 D7:19
[19:22:32][C][esp32_camera:053]:   VSYNC Pin: 22
[19:22:32][C][esp32_camera:054]:   HREF Pin: 26
[19:22:32][C][esp32_camera:055]:   Pixel Clock Pin: 21
[19:22:32][C][esp32_camera:056]:   External Clock: Pin:27 Frequency:20000000
[19:22:32][C][esp32_camera:060]:   I2C Pins: SDA:25 SCL:23
[19:22:32][C][esp32_camera:062]:   Reset Pin: 15
[19:22:32][C][esp32_camera:080]:   Resolution: 640x480 (VGA)
[19:22:32][E][esp32_camera:123]:   Setup Failed: ESP_FAIL
[19:22:32][C][psram:020]: PSRAM:
[19:22:32][C][psram:021]:   Available: NO
[19:22:32][C][captive_portal:088]: Captive Portal:
[19:22:32][C][mdns:115]: mDNS:
[19:22:32][C][mdns:116]:   Hostname: esphome-web-6e83dc
[19:22:32][C][ota:097]: Over-The-Air Updates:
[19:22:32][C][ota:098]:   Address: esphome-web-6e83dc.local:3232
[19:22:32][C][api:139]: API Server:
[19:22:32][C][api:140]:   Address: esphome-web-6e83dc.local:6053
[19:22:32][C][api:142]:   Using noise encryption: YES

My YAML is

esphome:
  name: esphome-web-6e83dc
  friendly_name: esp cam

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "[redacted]"

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-6E83Dc"
    password: "[redacted]"

captive_portal:

esp32_camera:
  external_clock:
    pin: GPIO27
    frequency: 20MHz
  i2c_pins:
    sda: GPIO25
    scl: GPIO23
  data_pins: [GPIO17, GPIO35, GPIO34, GPIO5, GPIO39, GPIO18, GPIO36, GPIO19]
  vsync_pin: GPIO22
  href_pin: GPIO26
  pixel_clock_pin: GPIO21
  reset_pin: GPIO15
  name: "espcam"
  

Bump. I need this to work :slight_smile: