ESP32 camera becomes unresponsive, but its sibling is stable

I’m exeriencing a very strange issue with ESPHome-powered ESP32-cam modules.

I bought two unbranded modules which look like the AiThinker modules. I’ve got both running properly with Home Assistant, configuration is good, everything appears to work. Can view the camera stream and control the on-board LED from Lovelace.

However, after a few minutes of operation, one of the two modules stops providing images from the camera. The logs don’t say anything is wrong, and the light to control the on-board white LED still responds. Everything appears to be working, but I don’t see any logs about getting an image the way it does when it first starts up.

But here’s where it gets weird: this only happens on one of the two boards. I’m using the exact same config on each, one named cam_1 while the other is named cam_2. I’ve swapped power supplies and power cables, but for some reason, cam_1 is unstable while cam_2 works fine. I even tried putting a heatsink on the ESP32 for cam_1, but that made no difference, and even without one, the module doesn’t get beyond warm even when streaming video.

Here’s my config

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

wifi:
  ssid: "[redacted]"
  password: "[redacted]"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

esp32_camera:
  name: Camera 1
  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
  
output:
  - platform: gpio
    pin: 4
    id: gpio_4
    
light:
  - platform: binary
    name: "Cam 1"
    output: gpio_4
    
status_led:
    pin:
      number: 33
      inverted: true

switch:
  - platform: restart
    name: Cam 1 restart

sensor:
  - platform: wifi_signal
    name: "Cam 1 dB"
    update_interval: 300s
  - platform: uptime
    name: Cam 1 Uptime

I wouldn’t trust the sourcing, could be a clone of a clone, faulty or cheap parts, etc. I have mine programmed tor reboot once an hour to keep them up.

What he said ^, but also these are quite sensitive to wifi connectivity.

What is your RSSI like?

Are you using an external antenna?

me too: had the same also on good quality boards.
If you do not reboot (i do every 30mins) they become unresponsive

The RSSI appears okay (-79 dB). Can anyone share their lambda or config that will reboot the device regularly?

I’ve also seen some strange issues on reboot of the problematic device warning that setup failed. Looks like in intermittent fault with the camera module itself, which is kind of annoying. I’m wondering if that might be the culprit.

Here is my hourly reboot:

time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
      - cron: '00 00 * * * *'
        then:
          - switch.toggle: restart_device
switch:
  - platform: restart
    id: restart_device
    name: "${friendly_name} Restart"

Thanks @aneisch

If I reboot the device within the first minute or two of operation, it reboots fine. However, if the camera feed has been interrupted, it won’t complete the reboot.

Here are the logs:

[14:39:19][I][app:133]: Rebooting safely…
[14:39:19]ets Jun 8 2016 00:22:57
[14:39:19]
[14:39:19]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[14:39:19]configsip: 0, SPIWP:0xee
[14:39:19]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[14:39:19]mode:DIO, clock div:2
[14:39:19]load:0x3fff0018,len:4
[14:39:19]load:0x3fff001c,len:952
[14:39:19]load:0x40078000,len:6084
[14:39:19]load:0x40080000,len:7944
[14:39:19]entry 0x40080310
[14:39:21][I][logger:116]: Log initialized
[14:39:21][C][status_led:014]: Setting up Status LED…
[14:39:21][C][ota:364]: There have been 0 suspected unsuccessful boot attempts.
[14:39:21][I][app:028]: Running through setup()…
[14:39:21][C][light:094]: Setting up light ‘Cam 1’…
[14:39:21][D][light:261]: ‘Cam 1’ Setting:

And that’s as far as it gets. A successful reboot shows the same message, but continues on…

[14:41:41][I][restart:015]: Restarting device…
[14:41:41][I][app:133]: Rebooting safely…
[14:41:41]ets Jun 8 2016 00:22:57
[14:41:41]
[14:41:41]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[14:41:41]configsip: 0, SPIWP:0xee
[14:41:41]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[14:41:41]mode:DIO, clock div:2
[14:41:41]load:0x3fff0018,len:4
[14:41:41]load:0x3fff001c,len:952
[14:41:41]load:0x40078000,len:6084
[14:41:41]load:0x40080000,len:7944
[14:41:41]entry 0x40080310
[14:41:43][I][logger:116]: Log initialized
[14:41:43][C][status_led:014]: Setting up Status LED…
[14:41:43][C][ota:364]: There have been 0 suspected unsuccessful boot attempts.
[14:41:43][I][app:028]: Running through setup()…
[14:41:43][C][light:094]: Setting up light ‘Cam 1’…
[14:41:43][D][light:261]: ‘Cam 1’ Setting:
[14:41:43][C][wifi:029]: Setting up WiFi…
[14:41:43][D][wifi:272]: Starting scan…
[14:41:43][D][sensor:092]: ‘Cam 1 Uptime’: Sending state 1.86500 s with 0 decimals of accuracy
[14:41:46][D][wifi:287]: Found networks:

and so on…

I have a similar module. If I power it from a USB port it fails after a while but if I power from the same USB cable and plug it in to a wall socket it appears more reliable.
I have also noticed that the chip gets quite warm so I’m going to add a heatsink on it once they arrive.

Matt

I’ve tried different power supplies, including ones that work with my second module. I’m doing most of my testing on a power bank that delivers up to 2 amps, so I don’t think it’s due to brownouts, as I’m also not seeing anything like that in the logs (viewed over USB, not OTA).

Maybe faulty module? Can you swap camera between modules?

Where do you put this reboot code?

In the yaml file.

You mean the configuration.yaml?

No sorry the esphome yaml file.

1 Like

Could you please post your entire yaml file here, just so I can verify I get it right.?