ESPHOME ESP32CAM not working (Component esp32_camera is marked FAILED)

Hi,
(this is my first post here so I apologize its not in the correct place)

I am trying to use ESP32CAM with ESPHOME, but failing…
I know my ESP32CAM is not faulty (if I upload arduino example sketch for AI-Thinker ESP32CAM in arduino IDE, cameraWebServer.ino, it works ok. Board selected is “AI-Thinker ESP32-CAM”).

These are the steps I have followed:

  • In HA > ESPHome, I create new device,
  • write xaml code (see code below),
  • compile and download to computer using Manual option (legacy),
  • then use this ESP flasher to upload firmware to the device:
    https://github.com/Jason2866/ESP_Flasher/releases/tag/v.1.3
  • In HA the device is detected and a notification shows up to add it.

The device shows up as ONLINE in ESPHome tab in HA, but in dashboard it shows no image and idle state. (but the led switch works ok)

If I click on Logs in ESPHome tab, this is the output:
(note the 2 lines with error:
[14:55:42][E][esp32_camera:123]: Setup Failed: ESP_ERR_NOT_FOUND
[14:55:42][E][component:082]: Component esp32_camera is marked FAILED

INFO ESPHome 2024.6.6
INFO Reading configuration /config/esphome/esp32camtest.yaml...
WARNING GPIO0 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 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
INFO Starting log output from 192.168.1.45 using esphome API
WARNING Can't connect to ESPHome API for esp32camtest @ 192.168.1.45: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.1.45', port=6053))]: [Errno 111] Connect call failed ('192.168.1.45', 6053) (SocketAPIError)
INFO Trying to connect to esp32camtest @ 192.168.1.45 in the background
INFO Successfully connected to esp32camtest @ 192.168.1.45 in 0.013s
INFO Successful handshake with esp32camtest @ 192.168.1.45 in 0.128s
[14:55:42][I][app:100]: ESPHome version 2024.6.6 compiled on Jul  7 2024, 14:30:42
[14:55:42][C][wifi:599]: WiFi:
[14:55:42][C][wifi:427]:   Local MAC: C8:C9:A3:F9:7D:14
[14:55:42][C][wifi:432]:   SSID: [redacted]
[14:55:42][C][wifi:435]:   IP Address: 192.168.1.45
[14:55:42][C][wifi:439]:   BSSID: [redacted]
[14:55:42][C][wifi:440]:   Hostname: 'esp32camtest'
[14:55:42][C][wifi:442]:   Signal strength: -36 dB ▂▄▆█
[14:55:42][C][wifi:446]:   Channel: 1
[14:55:42][C][wifi:447]:   Subnet: 255.255.255.0
[14:55:42][C][wifi:448]:   Gateway: 192.168.1.1
[14:55:42][C][wifi:449]:   DNS1: 80.58.61.254
[14:55:42][C][wifi:450]:   DNS2: 80.58.61.250
[14:55:42][C][logger:185]: Logger:
[14:55:42][C][logger:186]:   Level: DEBUG
[14:55:42][C][logger:188]:   Log Baud Rate: 115200
[14:55:42][C][logger:189]:   Hardware UART: UART0
[14:55:42][C][ledc.output:176]: LEDC Output:
[14:55:42][C][ledc.output:177]:   Pin GPIO4
[14:55:42][C][ledc.output:178]:   LEDC Channel: 2
[14:55:42][C][ledc.output:179]:   PWM Frequency: 1000.0 Hz
[14:55:42][C][ledc.output:180]:   Phase angle: 0.0°
[14:55:42][C][ledc.output:181]:   Bit depth: 16
[14:55:42][C][light:103]: Light 'espcam_02 light'
[14:55:42][C][light:105]:   Default Transition Length: 1.0s
[14:55:42][C][light:106]:   Gamma Correct: 2.80
[14:55:42][C][esp32_camera:048]: ESP32 Camera:
[14:55:42][C][esp32_camera:049]:   Name: My Camera
[14:55:42][C][esp32_camera:050]:   Internal: NO
[14:55:42][C][esp32_camera:052]:   Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[14:55:42][C][esp32_camera:053]:   VSYNC Pin: 25
[14:55:42][C][esp32_camera:054]:   HREF Pin: 23
[14:55:42][C][esp32_camera:055]:   Pixel Clock Pin: 22
[14:55:42][C][esp32_camera:056]:   External Clock: Pin:0 Frequency:20000000
[14:55:42][C][esp32_camera:060]:   I2C Pins: SDA:26 SCL:27
[14:55:42][C][esp32_camera:062]:   Reset Pin: 32
[14:55:42][C][esp32_camera:080]:   Resolution: 640x480 (VGA)
[14:55:42][E][esp32_camera:123]:   Setup Failed: ESP_ERR_NOT_FOUND
[14:55:42][E][component:082]:   Component esp32_camera is marked FAILED
[14:55:42][C][psram:020]: PSRAM:
[14:55:42][C][psram:021]:   Available: YES
[14:55:42][C][psram:024]:   Size: 4095 KB
[14:55:42][C][captive_portal:088]: Captive Portal:
[14:55:42][C][mdns:115]: mDNS:
[14:55:42][C][mdns:116]:   Hostname: esp32camtest
[14:55:42][C][esphome.ota:073]: Over-The-Air updates:
[14:55:42][C][esphome.ota:074]:   Address: esp32camtest.local:3232
[14:55:42][C][esphome.ota:075]:   Version: 2
[14:55:42][C][esphome.ota:078]:   Password configured
[14:55:42][C][safe_mode:018]: Safe Mode:
[14:55:42][C][safe_mode:020]:   Boot considered successful after 60 seconds
[14:55:42][C][safe_mode:021]:   Invoke after 10 boot attempts
[14:55:42][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[14:55:42][C][api:139]: API Server:
[14:55:42][C][api:140]:   Address: esp32camtest.local:6053
[14:55:42][C][api:142]:   Using noise encryption: YES

and this is xaml code:

esphome:
  name: esp32camtest
  friendly_name: esp32camtest

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  - platform: esphome
    password: "c7a0ea8286d4751e45f4ad4e939658f6"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32Camtest Fallback Hotspot"
    password: "JyJmZmwEeh"

captive_portal:
  


# Example configuration entry
esp32_camera:
  name: My Camera
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  reset_pin: GPIO32
  resolution: 640x480
  jpeg_quality: 10


output:
  - platform: ledc
    pin: GPIO4
    channel: 2 # channel 1 is used for esp32_camera
    id: led
light:
  - platform: monochromatic
    output: led
    name: espcam_02 light

Check your pin definitions against the .ino which works. There are many many varieties of these things.

If you are sure the pins are correct, then try cleaning the connectors. They are fiddly, be careful.

The error is probably in the line
reset_pin: GPIO32
supposed to be with Ai-Thinker
power_down_pin: GPIO32