ESP32 Camera Buffer Space / API disconnects

Having an issue with an ESP32 Camera board. It’s a Freenove WROVER kit board and I’m using standard config.

From reading others’ success with this board with default settings (VGA / jpeq quality 10), I would’ve expected the default settings to work just fine.

And yet for default setting I’m getting a ‘Cannot send message because of TCP buffer space’ message, at which point the ESP32 disconnects from Home Assistant. (I had to turn on Verbose logging to understand what was occuring, and it came up with this)

[10:18:53][D][esp32_camera:172]: Got Image: len=13738
[10:19:03][D][esp32_camera:172]: Got Image: len=13968
[10:19:13][V][api.connection:993]: Cannot send message because of TCP buffer space
[10:19:13][V][api:114]: Removing connection to Home Assistant 2023.1.7 (::FFFF:192.168.1.201)
[10:19:13][D][esp32_camera:172]: Got Image: len=13817
[10:19:20][D][api:102]: Accepted ::FFFF:192.168.1.201
[10:19:20][V][api.connection:900]: Hello from client: ‘Home Assistant 2023.1.7 (::FFFF:192.168.1.201)’ | API Version 1.7
[10:19:23][D][esp32_camera:172]: Got Image: len=13865
[10:19:30][W][api.connection:083]: Home Assistant 2023.1.7 (::FFFF:192.168.1.201): Connection closed

So I tried lowering to 320x240 and jpeg quality 20 to not stress buffer, but even with that I get api disconnect/reconnects but no ‘Cannot send message because of TCP buffer space’ message (I had to turn on Very Verbose logging to get this detail). The API connection just flaps; disconnects then immediately reconnects.

[10:35:48][VV][api.service:470]: on_ping_request: PingRequest {}
[10:35:48][VV][api.service:043]: send_ping_response: PingResponse {}
[10:35:55][D][esp32_camera:172]: Got Image: len=3290
[10:35:58][VV][api.socket:813]: Home Assistant 2023.1.7 (::FFFF:192.168.1.201): Connection closed
[10:35:58][W][api.connection:083]: Home Assistant 2023.1.7 (::FFFF:192.168.1.201): Connection closed
[10:35:58][V][api:114]: Removing connection to Home Assistant 2023.1.7 (::FFFF:192.168.1.201)
[10:35:59][D][api:102]: Accepted ::FFFF:192.168.1.201
[10:35:59][VV][api.service:434]: on_hello_request: HelloRequest {
[10:35:59] client_info: ‘Home Assistant 2023.1.7’
[10:35:59] api_version_major: 1
[10:35:59] api_version_minor: 7
[10:35:59]}
[10:35:59][V][api.connection:900]: Hello from client: ‘Home Assistant 2023.1.7 (::FFFF:192.168.11.201)’ | API Version 1.7

I’m running HA 2023.1.7 (latest) and ESPHome 2023.2.0-dev. I had been running ESPHome 2022.12.8 (with same issues), but based on another thread with a guy having problems with an ESP32 camera on ESPHome 2022.12.x, I updated to dev to see if 2022.12 was just buggy. No luck.

Config:

esphome:
  name: esp32camera

esp32:
  board: esp-wrover-kit

wifi:
  networks:
  - ssid: "redacted"
    password: "redacted"
  power_save_mode: none
  manual_ip:
    static_ip: 192.168.1.85
    gateway: 192.168.1.1
    subnet: 255.255.255.0

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
  name: ESP32 Camera
  resolution: 320x240
  jpeg_quality: 20

switch:
  platform: restart
  name: "ESP32 Restart"

logger:
  level: very_verbose

api:

ota:

Downgraded to ESPHome 2022.11.5 to see if pre-2022.12.x would help, and I’m still getting a ‘Cannot send message because of TCP buffer space’ error.

Also tried esp32 camera web server and it usually goes belly up after 5 frames.

Could the board be at issue?

Launched this f@cking thing into the sun

Hi ! I have the same problem, have you find a solution ? For me, after flashing ESP32 it’s ok for few minutes and the problem returns :frowning:

actually there is a solution described here:

in a nutshell: clock frequencies above 8 MHz create interferences that lead to a range of problems. setting it to 8 MHz solved all my connectivity problems i had with my esp32 cams.
there needed to be some esphome code changes to be made (already merged), since only clock speeds between 10 and 20 were allowed. i don’t know if the patch is included in the latest esphome release, i patched it manually, and like i said, my esp32 cams work quite reliably now with a camera clock speed of 8 MHz.

2 Likes

This ist it!!!
Thank you so much.

frequency: 8MHz
1 Like