ESP32-CAM works on Web Server, but not in HA

Hi All,

I have been following this guide for the past few days trying to get this ESP32-CAM (MB, with attached usb connector) working with Home Assistant:

youtubeDOTcom/watch?v=qspHm1RKsPc
Sorry, I can’t put more than 2 links in a post.

I compiled the arduino code, connected to the temporary AP made by the esp32, and was able to take still images (confirming the camera is working).

I then added the device to ESPHome and installed the following code on top of the standard ESP32 ESPHome code:

https://i.imgur.com/F1WUrXC.png

I use OTA to push the code and it completes successfully, but does give one small error line inside the logs:

https://i.imgur.com/aoObjc7.png

At this point I am able to see the device on my router management page, the device shows as online in ESPHome, and I have 2 entities added (camera and camera light). Adding the camera entity to a Picture Entity card just shows the status as “Idle” and no picture:

image

BUT, the device must be talking with HA and ESPHome because I am able to toggle the camera light on and off.

What am I doing wrong here? Any suggestions? My ultimate goal is to have an ESP32-cam integrated into HA such that I can setup automations to take a snapshot once a day (time lapse of indoor garden plants).

1 Like

well for a start you are posting screenshots of text files. Please please copy and paste!

Here’s the code used:

esphome:
  name: esp-cam-4

esp32:
  board: esp32cam
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: ""

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Cam-4 Fallback Hotspot"
    password: ""

captive_portal:

# Example configuration entry
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
  resolution: 800x600
  
  # Image settings
  name: esp32-cam-4

output:
  - platform: gpio
    pin: GPIO4
    id: gpio_4

light: 
  - platform: binary
    output: gpio_4
    name: esp32-cam-4 light

And here’s the logs once the device connects to ESPHome dashboard:

INFO Reading configuration /config/esphome/esp-cam-4.yaml...
WARNING GPIO15 is a Strapping PIN and should be avoided.
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 GPIO4 is a Strapping PIN and should be avoided.
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 esp-cam-4.local using esphome API
INFO Successfully connected to esp-cam-4.local
[08:31:38][I][app:102]: ESPHome version 2022.1.2 compiled on Feb 11 2022, 22:14:23
[08:31:38][C][wifi:488]: WiFi:
[08:31:38][C][wifi:350]:   Local MAC:  [redacted]
[08:31:38][C][wifi:351]:   SSID: [redacted]
[08:31:38][C][wifi:352]:   IP Address: 192.168.1.157
[08:31:38][C][wifi:354]:   BSSID: [redacted]
[08:31:38][C][wifi:355]:   Hostname: 'esp-cam-4'
[08:31:38][C][wifi:357]:   Signal strength: -68 dB ▂▄▆█
[08:31:38][C][wifi:361]:   Channel: 10
[08:31:38][C][wifi:362]:   Subnet: 255.255.255.0
[08:31:38][C][wifi:363]:   Gateway: 192.168.1.1
[08:31:38][C][wifi:364]:   DNS1: 192.168.1.1
[08:31:38][C][wifi:365]:   DNS2: 0.0.0.0
[08:31:38][C][logger:233]: Logger:
[08:31:38][C][logger:234]:   Level: DEBUG
[08:31:38][C][logger:235]:   Log Baud Rate: 115200
[08:31:38][C][logger:236]:   Hardware UART: UART0
[08:31:38][C][gpio.output:010]: GPIO Binary Output:
[08:31:38][C][gpio.output:011]:   Pin: GPIO4
[08:31:38][C][light:098]: Light 'esp32-cam-4 light'
[08:31:38][C][esp32_camera:049]: ESP32 Camera:
[08:31:38][C][esp32_camera:050]:   Name: esp32-cam-4
[08:31:38][C][esp32_camera:051]:   Internal: NO
[08:31:38][C][esp32_camera:053]:   Data Pins: D0:17 D1:35 D2:34 D3:5 D4:39 D5:18 D6:36 D7:19
[08:31:38][C][esp32_camera:054]:   VSYNC Pin: 22
[08:31:38][C][esp32_camera:055]:   HREF Pin: 26
[08:31:38][C][esp32_camera:056]:   Pixel Clock Pin: 21
[08:31:38][C][esp32_camera:057]:   External Clock: Pin:27 Frequency:20000000
[08:31:38][C][esp32_camera:058]:   I2C Pins: SDA:25 SCL:23
[08:31:38][C][esp32_camera:059]:   Reset Pin: 15
[08:31:38][C][esp32_camera:080]:   Resolution: 800x600 (SVGA)
[08:31:38][E][esp32_camera:096]:   Setup Failed: ERROR
[08:31:38][C][psram:020]: PSRAM:
[08:31:38][C][psram:021]:   Available: YES
[08:31:38][C][captive_portal:144]: Captive Portal:
[08:31:38][C][ota:082]: Over-The-Air Updates:
[08:31:38][C][ota:083]:   Address: esp-cam-4.local:3232
[08:31:38][C][ota:086]:   Using Password.
[08:31:38][C][api:134]: API Server:
[08:31:38][C][api:135]:   Address: esp-cam-4.local:6053
[08:31:38][C][api:139]:   Using noise encryption: NO
[08:31:38][C][mdns:084]: mDNS:
[08:31:38][C][mdns:085]:   Hostname: esp-cam-4

UPDATE: Solution found here:

1 Like