ESP32 Cam - working!

Hi

I recently purchased two ESP32 camera modules from Banggood and cannot get them to show any video feed with esphome. This is the yaml file

esphome:
  name: esp32_cam_1
  platform: ESP32
  board: esp32cam

wifi:
  ssid: !secret wifi_network
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32 Cam 1 Fallback Hotspot"
    password: !secret wifi_password

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret api_password
  
esp32_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
  power_down_pin: GPIO32

  # Image settings
  name: Test Cam 1
  
output:
  - platform: gpio
    pin: GPIO4
    id: gpio_4
light:
  - platform: binary
    output: gpio_4
    name: $hostname light

And this is the error i’m seeing when booting after flashing:

[18:09:41][I][app:105]: ESPHome version 1.16.0 compiled on Feb  6 2021, 17:49:17
[18:09:41][C][wifi:443]: WiFi:
[18:09:41][C][wifi:303]:   SSID: [redacted]
[18:09:41][C][wifi:304]:   IP Address: 192.168.1.88
[18:09:41][C][wifi:306]:   BSSID: [redacted]
[18:09:41][C][wifi:307]:   Hostname: 'esp32_cam_1'
[18:09:41][C][wifi:311]:   Signal strength: -53 dB ▂▄▆█
[18:09:41][C][wifi:315]:   Channel: 7
[18:09:41][C][wifi:316]:   Subnet: 255.255.255.0
[18:09:41][C][wifi:317]:   Gateway: 192.168.1.1
[18:09:41][C][wifi:318]:   DNS1: 192.168.1.1
[18:09:41][C][wifi:319]:   DNS2: 0.0.0.0
[18:09:41][C][gpio.output:010]: GPIO Binary Output:
[18:09:41][C][gpio.output:011]:   Pin: GPIO4 (Mode: OUTPUT)
[18:09:41][C][logger:185]: Logger:
[18:09:41][C][logger:186]:   Level: DEBUG
[18:09:41][C][logger:187]:   Log Baud Rate: 115200
[18:09:41][C][logger:188]:   Hardware UART: UART0
[18:09:41][C][light:178]: Light '$hostname light'
[18:09:41][C][esp32_camera:043]: ESP32 Camera:
[18:09:41][C][esp32_camera:044]:   Name: Test Cam 1
[18:09:41][C][esp32_camera:045]:   Board Has PSRAM: NO
[18:09:41][C][esp32_camera:047]:   Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[18:09:41][C][esp32_camera:048]:   VSYNC Pin: 25
[18:09:41][C][esp32_camera:049]:   HREF Pin: 23
[18:09:41][C][esp32_camera:050]:   Pixel Clock Pin: 22
[18:09:41][C][esp32_camera:051]:   External Clock: Pin:0 Frequency:20000000
[18:09:41][C][esp32_camera:052]:   I2C Pins: SDA:26 SCL:27
[18:09:41][C][esp32_camera:053]:   Reset Pin: -1
[18:09:41][C][esp32_camera:074]:   Resolution: 640x480 (VGA)
[18:09:41][E][esp32_camera:093]:   Setup Failed: ERROR
[18:09:41][C][captive_portal:169]: Captive Portal:
[18:09:41][C][ota:029]: Over-The-Air Updates:
[18:09:41][C][ota:030]:   Address: esp32_cam_1.local:3232
[18:09:41][C][ota:032]:   Using Password.
[18:09:41][W][ota:036]: Last Boot was an unhandled reset, will proceed to safe mode in 4 restarts
[18:09:41][C][api:095]: API Server:
[18:09:41][C][api:096]:   Address: esp32_cam_1.local:6053

I’m not sure what to do. Any suggestions?

-Cheers,

Can you point to the device you bought?

Hi @nickrout

These were the ones I bought here.

I have the same ones, change your board to
board: esp-wrover-kit

2 Likes

I’ve got my ESP32 Cam (Ai-Thinker lookalike) setup after scratching my head and numerous repeat uploads of the firmware thinking why my router is not picking up the camera device.

The wifi signal, with a Ubiquiti AP 2-3 ft away, is low at -66dB, but it does have capacity to use an external antenna.

I should have paid close attention to that line where it say ‘2-3 ft away’ wifi range.

I would like to add my device and initial config setup for anyone who may have question with theirs.

This is the ESP32 Cam I’ve got.

esphome config:

# ESP32 CAM
substitutions:
  name: security_cam
  platform: ESP32
  board: esp-wrover-kit

esphome:
  name: $name
  platform: $platform
  board: $board

wifi:
  ssid: 'rice_dwarf'
  password: !secret ssid_pass
  manual_ip:
    static_ip: 192.168.1.94
    subnet: 255.255.255.0
    gateway: 192.168.1.1

# Fallback portal 
captive_portal:
# Logging
logger:
# Uncomment this if you use Home Assistant
api:
  password: !secret ota_pass

ota:
  password: !secret ota_pass

esp32_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
  power_down_pin: GPIO32

# Image settings
  name: security

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

light:
  - platform: binary
    output: gpio_4
    name: $name light


2 Likes

Ok, did that change and this is what I am getting still…

[08:54:17][I][app:105]: ESPHome version 1.16.0 compiled on Feb  7 2021, 08:52:33
[08:54:18][C][wifi:443]: WiFi:
[08:54:18][C][wifi:303]:   SSID: [redacted]
[08:54:18][C][wifi:304]:   IP Address: 192.168.1.88
[08:54:18][C][wifi:306]:   BSSID: [redacted]
[08:54:18][C][wifi:307]:   Hostname: 'esp32_cam_1'
[08:54:18][C][wifi:311]:   Signal strength: -58 dB ▂▄▆█
[08:54:18][C][wifi:315]:   Channel: 7
[08:54:18][C][wifi:316]:   Subnet: 255.255.255.0
[08:54:18][C][wifi:317]:   Gateway: 192.168.1.1
[08:54:18][C][wifi:318]:   DNS1: 192.168.1.1
[08:54:18][C][wifi:319]:   DNS2: 0.0.0.0
[08:54:18][C][gpio.output:010]: GPIO Binary Output:
[08:54:18][C][gpio.output:011]:   Pin: GPIO4 (Mode: OUTPUT)
[08:54:18][C][logger:185]: Logger:
[08:54:18][C][logger:186]:   Level: DEBUG
[08:54:18][C][logger:187]:   Log Baud Rate: 115200
[08:54:18][C][logger:188]:   Hardware UART: UART0
[08:54:18][C][light:178]: Light 'Light'
[08:54:18][C][esp32_camera:043]: ESP32 Camera:
[08:54:18][C][esp32_camera:044]:   Name: Test Cam 1
[08:54:18][C][esp32_camera:045]:   Board Has PSRAM: NO
[08:54:18][C][esp32_camera:047]:   Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[08:54:18][C][esp32_camera:048]:   VSYNC Pin: 25
[08:54:18][C][esp32_camera:049]:   HREF Pin: 23
[08:54:18][C][esp32_camera:050]:   Pixel Clock Pin: 22
[08:54:18][C][esp32_camera:051]:   External Clock: Pin:0 Frequency:20000000
[08:54:18][C][esp32_camera:052]:   I2C Pins: SDA:26 SCL:27
[08:54:18][C][esp32_camera:053]:   Reset Pin: -1
[08:54:18][C][esp32_camera:074]:   Resolution: 640x480 (VGA)
[08:54:18][E][esp32_camera:093]:   Setup Failed: ERROR
[08:54:18][C][captive_portal:169]: Captive Portal:
[08:54:18][C][ota:029]: Over-The-Air Updates:
[08:54:18][C][ota:030]:   Address: esp32_cam_1.local:3232
[08:54:18][C][ota:032]:   Using Password.
[08:54:18][C][api:095]: API Server:
[08:54:18][C][api:096]:   Address: esp32_cam_1.local:6053

Light still works but camera does not.

hmmm, I would try without the lights just to be sure but I think your camera might be dead… Double check that it is plugged in with a good connection.
This is mine (looks the same as yours)

esphome:
  name: garagecam
  platform: ESP32
  board: esp-wrover-kit

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


# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80
  
esp32_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
  power_down_pin: GPIO32
  name: Garage Camera
  vertical_flip: false
  horizontal_mirror: false

switch:
#This is the Relay
- platform: gpio
  restore_mode: RESTORE_DEFAULT_OFF
  pin:
    number: GPIO2
    inverted: True
  id: garage_door_relay

- platform: restart
  name: 'Garage Door REBOOT'
    

binary_sensor:
- id: garage_door_sensor
  internal: true
  platform: gpio
  pin:
    number: GPIO13
    mode: INPUT_PULLUP
    inverted: False
  device_class: garage_door
  filters:
    - delayed_on_off: 20ms

    
cover:
  - platform: template
    name: "Garage Door"
    lambda: |-
      if (id(garage_door_sensor).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - switch.turn_on: garage_door_relay
      - delay: 0.2s
      - switch.turn_off: garage_door_relay
    close_action:
      - switch.turn_on: garage_door_relay
      - delay: 0.2s
      - switch.turn_off: garage_door_relay
    stop_action:
      - switch.turn_off: garage_door_relay
    optimistic: true

    
output:
#flashlight
  - platform: gpio
    pin: GPIO4
    id: gpio_4
#statuslight
  - platform: gpio
    pin:
      number: GPIO33
      inverted: True
    id: gpio_33
light:
#flashlight
  - platform: binary
    output: gpio_4
    name: Garage Cam flash
#statuslight
  - platform: binary   
    output: gpio_33
    name: Garage Cam status    

And the camera part of the log looks like this

[10:21:18][C][esp32_camera:043]: ESP32 Camera:
[10:21:18][C][esp32_camera:044]:   Name: Garage Camera
[10:21:18][C][esp32_camera:045]:   Board Has PSRAM: YES
[10:21:18][C][esp32_camera:047]:   Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[10:21:18][C][esp32_camera:048]:   VSYNC Pin: 25
[10:21:18][C][esp32_camera:049]:   HREF Pin: 23
[10:21:18][C][esp32_camera:050]:   Pixel Clock Pin: 22
[10:21:18][C][esp32_camera:051]:   External Clock: Pin:0 Frequency:20000000
[10:21:18][C][esp32_camera:052]:   I2C Pins: SDA:26 SCL:27
[10:21:18][C][esp32_camera:053]:   Reset Pin: -1
[10:21:18][C][esp32_camera:074]:   Resolution: 640x480 (VGA)
[10:21:18][C][esp32_camera:099]:   JPEG Quality: 10
[10:21:18][C][esp32_camera:101]:   Contrast: 0
[10:21:18][C][esp32_camera:102]:   Brightness: 0
[10:21:18][C][esp32_camera:103]:   Saturation: 0
[10:21:18][C][esp32_camera:104]:   Vertical Flip: OFF
[10:21:18][C][esp32_camera:105]:   Horizontal Mirror: OFF
[10:21:18][C][esp32_camera:122]:   Test Pattern: NO
~~~
1 Like

Finally got around to playing with this again. I had bought 2 of these:

Including the MB with the cheapo CH340G usb to serial. I was a bit disappointed when I plugged it in to my workstation and there was no respons in dmesg… I have a FT232RL to program them with if I need to but I’m afraid my eye sight is not what it used to be + the first time I used it took me a long time to get working, just to read somewhere that if you program them on a breadbord you need to use a resistor to short the pins :man_facepalming: So was looking for an easy solution…

I finally got it running compiling the driver from here: https://github.com/juliagoda/CH341SER

But to my surprise this thing works straigt from HA, and I’m not even running this on a raspberry, I’m running on a nuc:

So yeah pretty happy with this, only downside now is the MB has a red led, that I cannot figure out how to turn off:

So if anyone has some tips for that?

Try GPIO4 for the led, but it may be different on your board.

Thanks but gpio4 is already configured for the onboard flash (white led) on the esp32-cam itself. The red led is attached to the MB:

I think you’ll need to either trace it, or trial and error it.

if all else fail, use a black tape.

1 Like

I was thinking the same thing… cause of my poor eyes the only option I have is to take a picture and blow it up, so might as well share it…

Can see no trace to the CH340G, goes straight from one of the inner lines of the usb connector to ‘CN1’ to the smd led to the shield… ah some tape works wonders too… Or I can wire the power straight to the cam too…

I got some of these glasses/magnifiers. Geeky as hell, the family laugh…

EDIT Sorry that link is now broken

2 Likes

That looks impressive! and funny I admit :laughing:

Have one like these: https://www.amazon.co.uk/Magnifying-Adjustable-Magnifier-Diameter-Workbench/dp/B08F3JT3FR/ref=sr_1_36?dchild=1&keywords=Magnifying+Glasses+with+Light&qid=1613263749&sr=8-36 and a smaller similar model. And one of these: https://www.amazon.com/Pixnor-Folding-Illuminated-Magnifier-Magnifying/dp/B00TZPEPAW/ref=sr_1_54?dchild=1&keywords=magnifier+jewelry&qid=1613263904&s=hpc&sr=1-54 normally for jewelry. But I think they hurt my eyes after a while…

I’ve been struggling with the same issue for several days. Have tried everything you have and still get the exact same error. Tried different resolutions (all that work with other code). Everything works except the video. I’d post my yaml, but it’s exactly the same as yours and won’t provide any useful information. Using the same Geekcreit ESP32-CAM from Banggood.

Camera works just fine if I flash it with anything besides the ESPHome code.

What software/firmware are you using then? I’ll try anything at this rate.

Hi Derrick, regarding the error, did you check if the lens is connected well? Another possibility is a not powerful power supply I tried with the 1A ones and it did not work well, with the 2A ones no problem, another possibility is that the lens does not work, even to me it happened one like this and once replaced it worked. For a quick check you can try flashing this https://randomnerdtutorials.com/esp32-cam-video-streaming-web-server-camera-home-assistant/

1 Like

I was going to tell you the ESP32-CAM webserver over at randomnerdtutorials.com worked as a web cam, you just provide HA with the URL, but then I saw echopage’s post about the power supply and switched from a 1.5A to a 2.4A PS.
So, still not working, but problems are different. ESPHome log show it initializing just fine, and say it’s receiving images. HomeAssistant now says device is unavailable and nothing works. Before I could see the status and wifi signal levels, and toggle the light off and on. Now I get nothing at all in HomeAssistant.

sounds like that could be a dns/docker network issue… are you running on a raspberry?

While setting up I noticed I had to remove the discovered entities from HA and add them again if I changed the hostname of one of the esp’s… check configuration > integrations > esphome. Remove the ‘bad’ esp from there and add it again

I’m running on a nuc and I get the images loaded. One of the espcams stopped working, but I see there’s more people complaining about the seller on amazon…

The other one sometimes stops sending images, I think I’m going to replace the camera’s with something different, and with at least a longer cable so I can cool them better