ESP32 Cam - working!

So you have tried both those solutions and they have worked.

Great.

Yup. Main problem is (or maybe better to say “was”) I cannot make it work when compile the code with latest version of ESPHome, because I really would like to use them as up to date ESPHome devices. But, hey, until some ESPHome update, which will probably come and fix the thing, I can live with them as Arduino devices, integrated to HA as MJPEG IP cam.

But you are not using the standard library, correct?
I think my problem with the custom_component and your problem with the camera is due to the change here:

Breaking Changes
Update esp32 arduino and platform versions esphome#3564 by @jesserockz (notable-change) (breaking-change)

Correct, I am not using standard library. I am pretty sure that problem is what you mentioned, since this is the breaking change from 2022.12.0 and my boards were worked with previous 2022.11.5 and older releases. They updated Arduino framework, and most probably not all boards are compatible with it (guesses again).

It is not a big deal, if they not release a fix soon, I can anyway downgrade ESPHome to 2022.11.5, compile the firmware and flash cameras, then upgrade ESPHome to latest again, cause I like ESPHome, it gives me more freedom and possibilities but Arduino, according my programming skills (it is easier). Or I can run another one ESPHome 2022.11.5 docker container on different port, which would serve me for ESP32cam playing with firmware only. Cameras will work, just with “update available” flag in ESPHome dashboard.

I can confirm that my camera is working with dev branch of ESPHome.
As said before, I’m using whole stack of Home Assistant and other related software from docker. I simply changed:

image: esphome/esphome

to:

image: esphome/esphome:dev,

re-downloaded ESPHome container and compiled ESP32 Camera firmware from ESPHome v2023.1.0-dev
Nothing changed in .yaml, below you can find my basic code, so these are good news, cause we should expect that everything is working in the next official release. Didn’t played so much, cause I’m on job currently and have no time, but it seems to me that performance are not so special, but hey, it is working and this is something for beginning.

esphome:
  name: camera-hall

esp32:
  board: esp32cam
  framework:
    type: arduino

logger:

api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "Camera-Hall Fallback Hotspot"
    password: "<some password here>"

captive_portal:

web_server:
  port: 80

esp32_camera:
  name: Camera Hall
  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
  resolution: 640x480
  jpeg_quality: 10

esp32_camera_web_server:
  - port: 8080
    mode: stream
  - port: 8081
    mode: snapshot
2 Likes

I keep getting a
“[18:23:42][E][esp32_camera:099]: Setup Failed: ESP_ERR_NOT_FOUND”

Working with esp-wrover-kit, tried the esphome dev version as suggestion of @stiw47 but no solution yet.
Somebody any idea ?

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: ${display_name} security
# Image settings
  max_framerate: 5 fps
  resolution: SXGA
  jpeg_quality: 20
  contrast: 2
  brightness: 2
  saturation: 2

I had the same error and it turned out to be a failed camera. Have you another camera to try?

1 Like

Cannot tell for sure, but I think that main problem here is lot of different manufacturers and their different implementations on the device. I mean we have (most probably) some “official” manufacturer and devices (IDK this, never bought “official”, I’m buying on Aliexpress), from other side we have plenty of Chinese no name manufacturers. So I believe there is no issue and/or explanation which can cover all of them and explain why is not working, cause most probably ESPHome not covering all of them yet.

I want to say: What I suggested for ESPHome dev branch, was valid month ago or so, for my certain devices, and cannot guarantee it would work on all devices. In mean time after last updates, my devices are working again on regular stable version of ESPHome.

Yes, plus quality of some factories, some components. And the seating problems with the cameras.

1 Like

True story. For example, all 3 of my devices are very poor quality in my opinion. Video stream is very choppy even in 400x296 resolution, so I’m not using these devices “in production” at all. On the other hand, I cannot know are “official” devices better, since I have just these 3 and never had anything else. To be honest, I’m just playing and experimenting with 1 of these 3, and other 2 I’m using as regular ESP32 without camera, one for WLED, another one for some Arduino code for Tetris, Snake, etc. on LED matrix I made, until regular ESP’s32 arrives. Same time, I’m seeking for some cheap and good local WiFi cameras (of course, this is not exist in price range of ESP32 camera).

Hi folks,

I’m in trouble with the first setup, I can connect to the EPS32-Cam but I can’t upload the image
I have the ESP32-CAM-MB with the 0OI and RST button,

I tried esphome-flasher

Connecting........_____....._____....._____....._____....._____....._____....._____
Unexpected error: ESP Chip Auto-Detection failed: Failed to connect to Espressif device: Invalid head of packet (0x1B)

I can see the logs if I connect using web.esphome.io

h�ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6968
load:0x40078000,len:13072
ho 0 tail 12 room 4
load:0x40080400,len:3896
entry 0x40080688
I (31) boot: ESP-IDF v4.1-dirty 2nd stage bootloader
I (31) boot: compile time 16:15:01
I (31) boot: chip revision: 3
I (34) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 40MHz
I (46) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 nvs              WiFi data        01 02 00009000 00005000
I (79) boot:  1 otadata          OTA data         01 00 0000e000 00002000
I (86) boot:  2 app0             OTA app          00 10 00010000 00300000
I (94) boot:  3 spiffs           Unknown data     01 82 00310000 000f0000
I (101) boot: End of partition table
I (106) boot_comm: chip revision: 3, min. application chip revision: 0
I (113) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1d2048 (1908808) map
I (849) esp_image: segment 1: paddr=0x001e2070 vaddr=0x3ffbdb60 size=0x04d3c ( 19772) load
I (857) esp_image: segment 2: paddr=0x001e6db4 vaddr=0x40080000 size=0x00400 (  1024) load
I (858) esp_image: segment 3: paddr=0x001e71bc vaddr=0x40080400 size=0x08e54 ( 36436) load
I (880) esp_image: segment 4: paddr=0x001f0018 vaddr=0x400d0018 size=0x9df74 (647028) map
I (1127) esp_image: segment 5: paddr=0x0028df94 vaddr=0x40089254 size=0x0b6a0 ( 46752) load
I (1159) boot: Loaded app from partition at offset 0x10000
I (1159) boot: Disabling RNG early entropy source...
E (60) psram: PSRAM ID read error: 0xffffffff

E (114) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
Card Mount Failed
PSRAM Initialization Failure
[E][camera.c:1113] camera_probe(): Detected camera not supported.
[E][camera.c:1379] esp_camera_init(): Camera probe failed with error 0x20004

any ideas?
regards

You got a datasheet or even an advertising page?

this is what I have :frowning:

1pcs Esp32-cam Wifi Wifi Module Esp32 Serial To Wifi Esp32 Cam Development Board 5v Bluetooth With Ov2640 Camera Module - Integrated Circuits - AliExpress

Good evening and excuse my bad English, I use a translator to write…

After trying with Esphome and Tasmota (Firmware version 10, the last one doesn’t work) for the ESP32-CAM + the ESP32-CAM-MB module , I decided to use the arduino Ide with Camerawebserver (It is the one with more configuration options and is more stable. With the others there are delays and cuts in the streaming which makes the camera unusable).

The problem came when I wanted to do the streaming from homeassistant, as suggested in many forums use the image card, but homeassistant left the connection taken (Arduino Camerawebserver only supports one client at a time), so when I closed the mobile client and open it again the streaming did not load more (For some strange reason home assistant does not close the connection), so I had to unplug the camera and plug it again.

The solution to this was:

In integrations add “MJPEG IP CAMERA”, in “MJPEG URL” add “http://ip_camera:81/stream” without the quotes.

This integration allows to click on the entity and when closing homeassistant, the connection to the camera is stopped leaving the espcam32 free for a new connection.

Finally, to boot the espcam32 with the ESP32-CAM-MB module, you must press the ESP32-CAM reset button and not the ESP32-CAM-MB reset button.

I also leave you a link where someone used esphome with an api and lambdas to control all the options of the esp32-cam (I did not test this configuration).

Link: Cheap ESP32-CAM Home Assistant ESPHome Camera Guide

I hope someone will find it useful, greetings.

1 Like

hi @Jervomalo , can you give me some more details? I tried, but even when I press the reset button on the EPS32-CAM I can’t upload code. what are the steps you perfomed?

Hello Bremby,

I had several times problems to load the firmware in the ESP32-CAM, as I commented it is solved by pressing the RST of the camera board and not the reset of the ESP32-CAM-MB module.

The above solves the simplest failure that this module gives…

The most complicated thing was; On one occasion when loading the scketch from the Arduino IDE to the board (I had already loaded it several times before), the com port stopped working and in the Windows coms appeared 3 com ports when I connected the camera, 2 com bluetooth and 1 of the CH and something that is of the ESP32-CAM-MB module, after changing ports and pressing reset several times, it did not work.

I solved it by deleting the com driver from Windows and restarting the PC, then it automatically recognized the com port but it still didn’t work, so in the device manager I deleted the com port driver again and checked the option “try to delete the driver too”, after that I disconnected the ESP32-CAM-MB module and went to device manager again and in com port properties I clicked on update driver and manually selected some drivers I downloaded from the Internet for the ESP32-CAM-MB module (they are easy to find), I did it from properties because if you do it directly does not load the manual drivers and uses the windows update, after that the module returned to recognize a single com port and it was not even necessary to press the RST camera to load the scketch, although it is a somewhat cumbersome procedure at least it worked for me, this module gives enough problems to load a new firmware.

I hope it helps you and I remain attentive if you have any doubt.

Edit:

I leave you a page from where to download the drivers:

You would have to try if they work for you, you can look at how Windows recognizes the com port, it should say something like CHXXX, the ones in the link are for the CH341 board.

I have the ESP32-cam up and running. Only thing is I do not get any cam stream. It says the cam is not available. What to do to get the cam working? This is my yaml. Seems ok I guess.
Ii have this item: https://www.amazon.de/-/nl/gp/product/B0BGCJQ5YR/ref=ppx_od_dt_b_asin_title_s00?ie=UTF8&psc=1

esphome:
  name: esp32-camera
  platform: ESP32
  board: esp32dev  

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "+jfh8A2Aa6YWkN25IQuhsY+friG2667XefvkoMJugM8="

ota:

web_server:
  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect : true
  power_save_mode: none
  manual_ip:
    static_ip: 192.168.0.141
    subnet: 255.255.255.0
    gateway: 192.168.0.1

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

captive_portal:

time:
  - platform: homeassistant
    id: time_homeassistant
    on_time_sync:
      - component.update: sensor_uptime_timestamp

sensor:
  - platform: uptime
    id: sensor_uptime
  - platform: template
    id: sensor_uptime_timestamp
    name: "Esp32-cam Uptime"
    device_class: "timestamp"
    accuracy_decimals: 0
    update_interval: never
    lambda: |-
      static float timestamp = (
        id(time_homeassistant).utcnow().timestamp - id(sensor_uptime).state
      );
      return timestamp;
  - platform: wifi_signal
    name: "Esp32-cam Signal"
    update_interval: 60s

button:
  - platform: restart
    name: "Esp32-cam Restart"

esp32_camera:
  external_clock:
    pin: GPIO13
    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
  resolution: 640x480
  name: Esp32-cam
  jpeg_quality: 20

The log file from espHome: there is one line which worries me. [20:02:59][E][esp32_camera:123]: Setup Failed: ESP_ERR_NOT_FOUND

INFO ESPHome 2023.6.4
INFO Reading configuration /config/esphome/esphome-web-304e60.yaml...
INFO Detected timezone 'Europe/Amsterdam'
INFO Starting log output from 192.168.0.141 using esphome API
INFO Successfully connected to 192.168.0.141
[20:02:59][I][app:102]: ESPHome version 2023.6.4 compiled on Jul  6 2023, 15:00:48
[20:02:59][C][wifi:543]: WiFi:
[20:02:59][C][wifi:379]:   Local MAC: 7C:87:CE:30:4E:60
[20:02:59][C][wifi:380]:   SSID: 'HocomAdvies'[redacted]
[20:02:59][C][wifi:381]:   IP Address: 192.168.0.141
[20:02:59][C][wifi:383]:   BSSID: 74:AC:B9:24:78:4C[redacted]
[20:02:59][C][wifi:384]:   Hostname: 'esp32-camera'
[20:02:59][C][wifi:386]:   Signal strength: -87 dB ▂▄▆█
[20:02:59][C][wifi:390]:   Channel: 11
[20:02:59][C][wifi:391]:   Subnet: 255.255.255.0
[20:02:59][C][wifi:392]:   Gateway: 192.168.0.1
[20:02:59][C][wifi:393]:   DNS1: 0.0.0.0
[20:02:59][C][wifi:394]:   DNS2: 0.0.0.0
[20:02:59][C][logger:301]: Logger:
[20:02:59][C][logger:302]:   Level: DEBUG
[20:02:59][C][logger:303]:   Log Baud Rate: 115200
[20:02:59][C][logger:305]:   Hardware UART: UART0
[20:02:59][C][uptime.sensor:031]: Uptime Sensor 'sensor_uptime'
[20:02:59][C][uptime.sensor:031]:   Device Class: 'duration'
[20:02:59][C][uptime.sensor:031]:   State Class: 'total_increasing'
[20:02:59][C][uptime.sensor:031]:   Unit of Measurement: 's'
[20:02:59][C][template.sensor:022]: Template Sensor 'Esp32-cam Uptime'
[20:02:59][C][template.sensor:022]:   Device Class: 'timestamp'
[20:02:59][C][restart.button:017]: Restart Button 'Esp32-cam Restart'
[20:02:59][C][esp32_camera:048]: ESP32 Camera:
[20:02:59][C][esp32_camera:049]:   Name: Esp32-cam
[20:02:59][C][esp32_camera:050]:   Internal: NO
[20:02:59][C][esp32_camera:052]:   Data Pins: D0:5 D1:18 D2:19 D3:21 D4:36 D5:39 D6:34 D7:35
[20:02:59][C][esp32_camera:053]:   VSYNC Pin: 25
[20:02:59][C][esp32_camera:054]:   HREF Pin: 23
[20:02:59][C][esp32_camera:055]:   Pixel Clock Pin: 22
[20:02:59][E][esp32_camera:123]:   Setup Failed: ESP_ERR_NOT_FOUND
[20:02:59][C][psram:020]: PSRAM:
[20:02:59][C][psram:021]:   Available: YES
[20:02:59][C][psram:024]:   Size: 4095 KB
[20:02:59][C][homeassistant.time:010]: Home Assistant Time:
[20:03:00][C][homeassistant.time:011]:   Timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
[20:03:00][C][captive_portal:088]: Captive Portal:
[20:03:00][C][web_server:161]: Web Server:
[20:03:00][C][web_server:162]:   Address: 192.168.0.141:80
[20:03:00][C][mdns:112]: mDNS:
[20:03:00][C][mdns:113]:   Hostname: esp32-camera
[20:03:00][C][ota:093]: Over-The-Air Updates:
[20:03:00][C][ota:094]:   Address: 192.168.0.141:3232
[20:03:00][C][api:138]: API Server:
[20:03:00][C][api:139]:   Address: 192.168.0.141:6053
[20:03:00][C][api:141]:   Using noise encryption: YES
[20:03:00][C][wifi_signal.sensor:009]: WiFi Signal 'Esp32-cam Signal'
[20:03:00][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[20:03:00][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[20:03:00][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[20:03:00][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0

Well you could google that error, but one thing we have found is that these devices are very sensitive to connection errors, so make sure

  1. that the little flat joiner cable between the camera and the board is clean; and

  2. That it is properly seated.

Try taking it out, cleaning it, and putting it back together, making sure it is right in the “hole” before locking it into place.

I had the same issue on one device of a two pack. Turned out that the flexfoil that connects the camera to the esp32 module was torn on the back side.

Ok will see what it brings. I already took it out and reconnected it. But might need some cleaning or any other treatment. I do not understand why they do not make this part a bit more robust.