From b1fa10e78ef7e1bcf7d2e5fe9e9c1d2f8da6a0ac Mon Sep 17 00:00:00 2001 From: Joshua King Date: Tue, 8 Sep 2026 14:48:07 -0400 Subject: [PATCH] Enhance camera image tuning and add gain ceiling selection for improved chamber monitoring --- esphome/esp32-h2c-camera.yaml | 50 ++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/esphome/esp32-h2c-camera.yaml b/esphome/esp32-h2c-camera.yaml index 8b7a896..e73cb7d 100644 --- a/esphome/esp32-h2c-camera.yaml +++ b/esphome/esp32-h2c-camera.yaml @@ -80,17 +80,21 @@ esp32_camera: vertical_flip: true horizontal_mirror: false - # Image tuning for chamber monitoring through tinted door - brightness: 1 - contrast: -1 + # Image tuning for chamber monitoring through tinted door. + # Low contrast + high brightness lifts the shadows; the LED strips are + # allowed to blow out since the chamber is what matters. + brightness: 2 + contrast: -2 saturation: 0 - # Auto-Exposure & Gain tuning (AEC2 + AE Level lift shadows away from bright LEDs) + # Auto-Exposure & Gain tuning (AEC2 + AE Level lift shadows away from bright LEDs). + # The gain ceiling is the main lever for the tinted door: 8X was capping how + # far AGC could amplify, leaving everything outside the LED strips black. aec_mode: auto aec2: true - ae_level: 1 + ae_level: 2 agc_mode: auto - agc_gain_ceiling: 8X + agc_gain_ceiling: 128X wb_mode: auto # Camera endpoints: @@ -160,7 +164,7 @@ number: min_value: -2 max_value: 2 step: 1 - initial_value: 1 + initial_value: 2 optimistic: true set_action: - lambda: |- @@ -172,7 +176,7 @@ number: min_value: -2 max_value: 2 step: 1 - initial_value: -1 + initial_value: -2 optimistic: true set_action: - lambda: |- @@ -184,10 +188,38 @@ number: min_value: -2 max_value: 2 step: 1 - initial_value: 1 + initial_value: 2 optimistic: true set_action: - lambda: |- sensor_t *s = esp_camera_sensor_get(); if (s) s->set_ae_level(s, (int)x); +select: + # Caps how far AGC may amplify. Higher = brighter but noisier; back this off + # if the chamber image gets too grainy at 128X. + - platform: template + name: "${friendly_name} Gain Ceiling" + optimistic: true + initial_option: "128X" + options: + - "2X" + - "4X" + - "8X" + - "16X" + - "32X" + - "64X" + - "128X" + set_action: + - lambda: |- + sensor_t *s = esp_camera_sensor_get(); + if (!s) return; + int idx = 6; + if (x == "2X") idx = 0; + else if (x == "4X") idx = 1; + else if (x == "8X") idx = 2; + else if (x == "16X") idx = 3; + else if (x == "32X") idx = 4; + else if (x == "64X") idx = 5; + s->set_gainceiling(s, (gainceiling_t)idx); +