Refactor ESP32 camera configuration and add dynamic controls for brightness, contrast, and AE level tuning
This commit is contained in:
@@ -56,34 +56,42 @@ mdns:
|
|||||||
web_server:
|
web_server:
|
||||||
port: 80
|
port: 80
|
||||||
|
|
||||||
i2c:
|
|
||||||
- id: camera_i2c
|
|
||||||
sda: GPIO8
|
|
||||||
scl: GPIO9
|
|
||||||
scan: false
|
|
||||||
|
|
||||||
esp32_camera:
|
esp32_camera:
|
||||||
name: "${friendly_name}"
|
name: "${friendly_name}"
|
||||||
external_clock:
|
external_clock:
|
||||||
pin: GPIO5
|
pin: GPIO5
|
||||||
frequency: 20MHz
|
frequency: 20MHz
|
||||||
i2c_id: camera_i2c
|
i2c_pins:
|
||||||
|
sda: GPIO8
|
||||||
|
scl: GPIO9
|
||||||
data_pins: [GPIO16, GPIO18, GPIO21, GPIO17, GPIO14, GPIO7, GPIO6, GPIO4]
|
data_pins: [GPIO16, GPIO18, GPIO21, GPIO17, GPIO14, GPIO7, GPIO6, GPIO4]
|
||||||
vsync_pin: GPIO1
|
vsync_pin: GPIO1
|
||||||
href_pin: GPIO2
|
href_pin: GPIO2
|
||||||
pixel_clock_pin: GPIO15
|
pixel_clock_pin: GPIO15
|
||||||
|
|
||||||
# Start conservative for reliability; increase later if stable.
|
# Resolution & quality (ESP32-S3 with Octal PSRAM handles XGA easily)
|
||||||
resolution: 800X600
|
resolution: 1024X768
|
||||||
jpeg_quality: 15
|
jpeg_quality: 10
|
||||||
max_framerate: 20 fps
|
max_framerate: 20 fps
|
||||||
idle_framerate: 0.2 fps
|
idle_framerate: 0.2 fps
|
||||||
frame_buffer_count: 1
|
frame_buffer_count: 2
|
||||||
|
|
||||||
# Common orientation defaults for this module.
|
# Orientation
|
||||||
vertical_flip: true
|
vertical_flip: true
|
||||||
horizontal_mirror: false
|
horizontal_mirror: false
|
||||||
|
|
||||||
|
# Image tuning for chamber monitoring through tinted door
|
||||||
brightness: 1
|
brightness: 1
|
||||||
|
contrast: -1
|
||||||
|
saturation: 0
|
||||||
|
|
||||||
|
# Auto-Exposure & Gain tuning (AEC2 + AE Level lift shadows away from bright LEDs)
|
||||||
|
aec_mode: auto
|
||||||
|
aec2: true
|
||||||
|
ae_level: 1
|
||||||
|
agc_mode: auto
|
||||||
|
agc_gain_ceiling: 8X
|
||||||
|
wb_mode: auto
|
||||||
|
|
||||||
# Camera endpoints:
|
# Camera endpoints:
|
||||||
# Stream: http://<ip>:8080
|
# Stream: http://<ip>:8080
|
||||||
@@ -144,3 +152,42 @@ interval:
|
|||||||
- logger.log: "Wi-Fi not connected for 5 min, rebooting..."
|
- logger.log: "Wi-Fi not connected for 5 min, rebooting..."
|
||||||
- delay: 10s
|
- delay: 10s
|
||||||
- lambda: 'App.safe_reboot();'
|
- lambda: 'App.safe_reboot();'
|
||||||
|
|
||||||
|
# Dynamic controls exposed to Home Assistant for real-time camera tuning
|
||||||
|
number:
|
||||||
|
- platform: template
|
||||||
|
name: "${friendly_name} Brightness"
|
||||||
|
min_value: -2
|
||||||
|
max_value: 2
|
||||||
|
step: 1
|
||||||
|
initial_value: 1
|
||||||
|
optimistic: true
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
|
if (s) s->set_brightness(s, (int)x);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "${friendly_name} Contrast"
|
||||||
|
min_value: -2
|
||||||
|
max_value: 2
|
||||||
|
step: 1
|
||||||
|
initial_value: -1
|
||||||
|
optimistic: true
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
|
if (s) s->set_contrast(s, (int)x);
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "${friendly_name} AE Level"
|
||||||
|
min_value: -2
|
||||||
|
max_value: 2
|
||||||
|
step: 1
|
||||||
|
initial_value: 1
|
||||||
|
optimistic: true
|
||||||
|
set_action:
|
||||||
|
- lambda: |-
|
||||||
|
sensor_t *s = esp_camera_sensor_get();
|
||||||
|
if (s) s->set_ae_level(s, (int)x);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user