ESPCam Not connecting to network when camera is plugged in

Hi,

I have a ESP32 WROVER Dev board with an attached cam (see pic). When I connect the camera it does not allow the ESP to connect to the network (cannot ping, acces from ESPHome etc etc), however when I look at the local USB serial logs they indicate that it is connected to Wifi, an IP has been allocated etc etc. See logs below

When I dissconnect the camera the ESP connects to the network and I can acces it as you would expect from ESPHome for example I can upload firmware, goto the portal, check logs etc etc

Has anyone seen this problem before or could help with a diagnosing the issue that I am having?

Device picture, device yaml and logs below

Thx

Device Config

substitutions:
  name: esphome-web-523ba4
  friendly_name: ESPHome Web 523ba4

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32cam
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  # Set up a wifi access point
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap: {}


# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
  authorizer: none

# To have a "next url" for improv serial
web_server:

esp32_camera:
  external_clock:
    pin: GPIO21
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO4, GPIO5, GPIO18, GPIO19, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22

  # Image settings
  name: Wrover Camera    
  max_framerate: 10 fps
  idle_framerate: 1.0 fps
  resolution: VGA
  horizontal_mirror: false
  vertical_flip: false
  brightness: 2
  contrast: 2

Serial Logs

16:04:14.207 -> rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
16:04:14.207 -> configsip: 0, SPIWP:0xee
16:04:14.207 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
16:04:14.317 -> mode:DIO, clock div:2
16:04:14.317 -> load:0x3fff0030,len:1184
16:04:14.317 -> load:0x40078000,len:13132
16:04:14.317 -> load:0x40080400,len:3036
16:04:14.317 -> entry 0x400805e4
16:04:15.335 -> e[0;32m[I][logger:158]: Log initializede[0m
16:04:15.335 -> e[0;35m[C][ota:483]: There have been 1 suspected unsuccessful boot attempts.e[0m
16:04:15.418 -> e[0;36m[D][esp32.preferences:114]: Saving 1 preferences to flash...e[0m
16:04:15.418 -> e[0;36m[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failede[0m
16:04:15.418 -> e[0;32m[I][app:029]: Running through setup()...e[0m
16:04:15.601 -> e[0;35m[C][esp32_ble:027]: Setting up BLE...e[0m
16:04:15.601 -> e[0;35m[C][wifi:038]: Setting up WiFi...e[0m
16:04:15.601 -> e[0;35m[C][wifi:051]: Starting WiFi...e[0m
16:04:15.601 -> e[0;35m[C][wifi:052]:   Local MAC: 30:AE:A4:52:3B:A4e[0m
16:04:15.715 -> e[0;36m[D][wifi:462]: Starting scan...e[0m
16:04:15.715 -> e[0;33m[W][wifi:152]: Warning set: unspecifiede[0m
16:04:15.715 -> e[0;36m[D][esp32_ble:270]: Enabling BLE...e[0m
16:04:16.333 -> e[0;36m[D][esp32_camera:196]: Got Image: len=13413e[0m
16:04:16.333 -> e[0;36m[D][esp32_ble_server:077]: BLE server setup successfullye[0m
16:04:16.333 -> e[0;36m[D][esp32_improv.component:077]: Creating Improv servicee[0m
16:04:17.326 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12872e[0m
16:04:18.319 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12488e[0m
16:04:18.816 -> e[0;36m[D][wifi:477]: Found networks:e[0m
16:04:18.816 -> e[0;32m[I][wifi:521]: - 'XXXX' e[5m(CC:32:xx:xx:xx:xx) e[6me[0;32m▂▄▆█e[0me[0m
16:04:18.816 -> e[0;36m[D][wifi:522]:     Channel: 11e[0m
16:04:18.816 -> e[0;36m[D][wifi:523]:     RSSI: -47 dBe[0m

16:04:18.907 -> e[0;32m[I][wifi:303]: WiFi Connecting to 'XXXX'...e[0m
16:04:19.314 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12401e[0m
16:04:19.480 -> e[0;33m[W][wifi_esp32:482]: Event: Disconnected ssid='XXXX' bssid=e[5mCC:32:xx:xx:xx:xxe[6m reason='Authentication Failed'e[0m
16:04:19.537 -> e[0;33m[W][wifi:651]: WiFi Unknown connection status 0e[0m
16:04:19.537 -> e[0;32m[I][wifi:303]: WiFi Connecting to 'XXX'...e[0m
16:04:19.537 -> e[0;33m[W][wifi_esp32:482]: Event: Disconnected ssid='XXXX' bssid=e[5mCC:32:xx:xx:xx:xxe[6m reason='Authentication Failed'e[0m
16:04:20.309 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11633e[0m
16:04:20.609 -> e[0;33m[W][wifi_esp32:482]: Event: Disconnected ssid='XXXX' bssid=e[5mCC:32:xx:xx:xx:xxe[6m reason='Auth Expired'e[0m
16:04:21.309 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11813e[0m
16:04:22.337 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11822e[0m
16:04:23.331 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11812e[0m
16:04:24.324 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11842e[0m
16:04:24.523 -> e[0;36m[D][wifi:462]: Starting scan...e[0m
16:04:25.319 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11845e[0m
16:04:26.312 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11902e[0m
16:04:27.340 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11864e[0m
16:04:27.904 -> e[0;36m[D][wifi:477]: Found networks:e[0m
16:04:27.904 -> e[0;32m[I][wifi:521]: - 'XXXX' e[5m(CC:32:xx:xx:xx:xx) e[6me[0;32m▂▄▆█e[0me[0m
16:04:27.904 -> e[0;36m[D][wifi:522]:     Channel: 11e[0m
16:04:27.904 -> e[0;36m[D][wifi:523]:     RSSI: -50 dBe[0m
16:04:27.904 -> e[0;36m[D][wifi:526]: - e[5m'XXXXK'e[6m e[5m(D6:32:xx:xx:xx:xx) e[6me[0;32m▂▄▆█e[0me[0m
16:04:27.959 -> e[0;36m[D][wifi:526]: - e[5m'XXXXEXT'e[6m e[5m(D2:32:xx:xx:xx:xx) e[6me[0;32m▂▄▆█e[0me[0m
16:04:27.959 -> e[0;32m[I][wifi:303]: WiFi Connecting to 'XXXX'...e[0m
16:04:27.959 -> e[0;33m[W][wifi:630]: Error while connecting to network.e[0m
16:04:27.959 -> e[0;36m[D][wifi:673]: Retrying with hidden networks...e[0m
16:04:27.959 -> e[0;32m[I][wifi:303]: WiFi Connecting to 'XXXX'...e[0m
16:04:27.959 -> e[0;33m[W][wifi_esp32:482]: Event: Disconnected ssid='XXXX' bssid=e[5mCC:32:xx:xx:xx:xxe[6m reason='Authentication Failed'e[0m
16:04:28.338 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11847e[0m
16:04:29.331 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11832e[0m
16:04:30.328 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11805e[0m
16:04:31.321 -> e[0;36m[D][esp32_camera:196]: Got Image: len=11830e[0m
16:04:32.348 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12231e[0m
16:04:32.978 -> e[0;32m[I][wifi:303]: WiFi Connecting to 'XXXX'...e[0m
16:04:32.978 -> e[0;33m[W][wifi_esp32:482]: Event: Disconnected ssid='XXXX' bssid=e[5mCC:32:xx:xx:xx:xxe[6m reason='Association Leave'e[0m
16:04:32.978 -> e[0;33m[W][wifi:651]: WiFi Unknown connection status 0e[0m
16:04:32.978 -> e[0;36m[D][wifi:673]: Retrying with hidden networks...e[0m
16:04:32.978 -> e[0;32m[I][wifi:303]: WiFi Connecting to 'XXXX'...e[0m
16:04:33.344 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12209e[0m
16:04:33.709 -> e[0;32m[I][wifi:594]: WiFi Connected!e[0m
16:04:33.709 -> e[0;35m[C][wifi:408]:   Local MAC: 30:AE:A4:52:3B:A4e[0m
16:04:33.709 -> e[0;35m[C][wifi:413]:   SSID: e[5m'XXXX'e[6me[0m
16:04:33.709 -> e[0;35m[C][wifi:416]:   IP Address: 192.168.xxx.xxxe[0m
16:04:33.709 -> e[0;35m[C][wifi:420]:   BSSID: e[5mCC:32:xx:xx:xx:xxe[6me[0m
16:04:33.709 -> e[0;35m[C][wifi:421]:   Hostname: 'esphome-web-523ba4'e[0m
16:04:33.709 -> e[0;35m[C][wifi:423]:   Signal strength: -50 dB e[0;32m▂▄▆█e[0me[0m
16:04:33.778 -> e[0;35m[C][wifi:427]:   Channel: 11e[0m
16:04:33.778 -> e[0;35m[C][wifi:428]:   Subnet: 255.255.255.0e[0m
16:04:33.778 -> e[0;35m[C][wifi:429]:   Gateway: 192.168.xxx.xxxe[0m
16:04:33.778 -> e[0;35m[C][wifi:430]:   DNS1: 192.168.xxx.xxxe[0m
16:04:33.778 -> e[0;35m[C][wifi:431]:   DNS2: 192.168.xxx.xxxe[0m
16:04:33.778 -> e[0;35m[C][web_server:124]: Setting up web server...e[0m
16:04:33.778 -> e[0;35m[C][ota:096]: Over-The-Air Updates:e[0m
16:04:33.778 -> e[0;35m[C][ota:097]:   Address: esphome-web-523ba4.local:3232e[0m
16:04:33.778 -> e[0;35m[C][ota:103]:   OTA version: 2.e[0m
16:04:33.778 -> e[0;35m[C][api:025]: Setting up Home Assistant API server...e[0m
16:04:33.909 -> e[0;32m[I][app:062]: setup() finished successfully!e[0m
16:04:33.909 -> e[0;33m[W][wifi:165]: Warning clearede[0m
16:04:33.909 -> e[0;33m[W][api:152]: Warning set: unspecifiede[0m
16:04:33.909 -> e[0;32m[I][app:102]: ESPHome version 2024.3.2 compiled on Apr 10 2024, 15:59:53e[0m
16:04:33.909 -> e[0;32m[I][app:104]: Project esphome.web version 1.0e[0m
16:04:33.909 -> e[0;35m[C][wifi:580]: WiFi:e[0m
16:04:33.909 -> e[0;35m[C][wifi:408]:   Local MAC: 30:AE:A4:52:3B:A4e[0m
16:04:33.909 -> e[0;35m[C][wifi:413]:   SSID: e[5m'XXXX'e[6me[0m
16:04:33.909 -> e[0;35m[C][wifi:416]:   IP Address: 192.168.xxx.xxxe[0m
16:04:33.909 -> e[0;35m[C][wifi:420]:   BSSID: e[5mCC:32:xx:xx:xx:xxe[6me[0m
16:04:33.909 -> e[0;35m[C][wifi:421]:   Hostname: 'esphome-web-523ba4'e[0m
16:04:33.909 -> e[0;35m[C][wifi:423]:   Signal strength: -49 dB e[0;32m▂▄▆█e[0me[0m
16:04:33.909 -> e[0;35m[C][wifi:427]:   Channel: 11e[0m
16:04:33.909 -> e[0;35m[C][wifi:428]:   Subnet: 255.255.255.0e[0m
16:04:33.909 -> e[0;35m[C][wifi:429]:   Gateway: 192.168.xxx.xxxe[0m
16:04:33.909 -> e[0;35m[C][wifi:430]:   DNS1: 192.168.xxx.xxxe[0m
16:04:33.909 -> e[0;35m[C][wifi:431]:   DNS2: 192.168.xxx.xxxe[0m
16:04:33.909 -> e[0;35m[C][logger:166]: Logger:e[0m
16:04:33.909 -> e[0;35m[C][logger:167]:   Level: DEBUGe[0m
16:04:33.909 -> e[0;35m[C][logger:169]:   Log Baud Rate: 115200e[0m
16:04:34.060 -> e[0;35m[C][logger:170]:   Hardware UART: UART0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:048]: ESP32 Camera:e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:049]:   Name: Wrover Camerae[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:050]:   Internal: NOe[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:052]:   Data Pins: D0:4 D1:5 D2:18 D3:19 D4:36 D5:39 D6:34 D7:35e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:053]:   VSYNC Pin: 25e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:054]:   HREF Pin: 23e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:055]:   Pixel Clock Pin: 22e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:056]:   External Clock: Pin:21 Frequency:20000000e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:060]:   I2C Pins: SDA:26 SCL:27e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:062]:   Reset Pin: -1e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:080]:   Resolution: 640x480 (VGA)e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:129]:   JPEG Quality: 10e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:131]:   Contrast: 2e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:132]:   Brightness: 2e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:133]:   Saturation: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:134]:   Vertical Flip: OFFe[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:135]:   Horizontal Mirror: OFFe[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:136]:   Special Effect: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:137]:   White Balance Mode: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:140]:   Auto Exposure Control: 1e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:141]:   Auto Exposure Control 2: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:142]:   Auto Exposure Level: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:143]:   Auto Exposure Value: 300e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:144]:   AGC: 1e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:145]:   AGC Gain: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:146]:   Gain Ceiling: 0e[0m
16:04:34.181 -> e[0;35m[C][esp32_camera:152]:   Test Pattern: NOe[0m
16:04:34.329 -> e[0;35m[C][psram:020]: PSRAM:e[0m
16:04:34.329 -> e[0;35m[C][psram:021]:   Available: YESe[0m
16:04:34.329 -> e[0;35m[C][psram:024]:   Size: 4095 KBe[0m
16:04:34.329 -> e[0;35m[C][esp32_ble:374]: ESP32 BLE:e[0m
16:04:34.329 -> e[0;35m[C][esp32_ble:376]:   MAC address: 30:AE:A4:52:3B:A6e[0m
16:04:34.329 -> e[0;35m[C][esp32_ble:377]:   IO Capability: nonee[0m
16:04:34.329 -> e[0;35m[C][esp32_ble_server:200]: ESP32 BLE Server:e[0m
16:04:34.329 -> e[0;35m[C][esp32_improv.component:261]: ESP32 Improv:e[0m
16:04:34.329 -> e[0;35m[C][captive_portal:088]: Captive Portal:e[0m
16:04:34.329 -> e[0;35m[C][web_server:169]: Web Server:e[0m
16:04:34.329 -> e[0;35m[C][web_server:170]:   Address: esphome-web-523ba4.local:80e[0m
16:04:34.461 -> e[0;35m[C][mdns:115]: mDNS:e[0m
16:04:34.461 -> e[0;35m[C][mdns:116]:   Hostname: esphome-web-523ba4e[0m
16:04:34.461 -> e[0;35m[C][ota:096]: Over-The-Air Updates:e[0m
16:04:34.461 -> e[0;35m[C][ota:097]:   Address: esphome-web-523ba4.local:3232e[0m
16:04:34.461 -> e[0;35m[C][ota:103]:   OTA version: 2.e[0m
16:04:34.461 -> e[0;35m[C][api:139]: API Server:e[0m
16:04:34.461 -> e[0;35m[C][api:140]:   Address: esphome-web-523ba4.local:6053e[0m
16:04:34.461 -> e[0;35m[C][api:144]:   Using noise encryption: NOe[0m
16:04:34.461 -> e[0;35m[C][improv_serial:032]: Improv Serial:e[0m
16:04:34.461 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12340e[0m
16:04:35.345 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12327e[0m
16:04:36.371 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12310e[0m
16:04:37.364 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12305e[0m
16:04:38.392 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12319e[0m
16:04:39.386 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12293e[0m
16:04:40.381 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12294e[0m
16:04:41.409 -> e[0;36m[D][esp32_camera:196]: Got Image: len=12336e[0m

Perhaps remove the web server component. It is very resource intensive.

Hi nickrout

I tried the removing the WEBSERVER component and it did not make much difference. I then went further and removed the AP and CAPTIVE PORTAL - when i removed all three of these it started to work in a fashion.

Now im getting strange behaviour where the network is up for a while (20-30 seconds) and then goes down for a few minutes ?!?!

I have started to suspect a PSU problem so I have plugged into a 2A 5V supply - still goes up and down on the network?!?!?

I am really scratching my head with this

What do you mean by “connect the camera”? Are you physically disconnecting it?

yes phsically disconnecting it - its the only way i can get control back over the board.

I have been playing a little more and removing more of the config -

  • esp32_improv:
  • dashboard_import:
  • improv_serial:
  • project:

I now get a video stream in HA although the network connection is still intermittent.

Wondering of there is a psu problem or even a config problem that is tying up resources?

Since my last update I have had the camera running for the last 3 hours without any problems.

I am convinced that there are problems somewhere in the default config HASS applies when you adopt the device - I dont know enough about each config item and what it does to narrow it down but I suspect that it will have something to do with one of the last 4 items I disabled.

When I get a little more time I will try reenabling each one individaully to see what happens.

My resultant WORKING config is as follows

substitutions:
  name: esphome-web-523ba4
  friendly_name: ESPHome Web 523ba4

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false

esp32:
  board: esp32cam
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:

wifi:
  # Set up a wifi access point
  ssid: !secret wifi_ssid
  password: !secret wifi_password

esp32_camera:
  external_clock:
    pin: GPIO21
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO4, GPIO5, GPIO18, GPIO19, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22

  # Image settings
  name: Wrover Camera    
  max_framerate: 14 fps
  idle_framerate: 1.0 fps
  resolution: VGA
  horizontal_mirror: false
  vertical_flip: false
  brightness: 0
  contrast: 0