Skip to content

Commit 693085f

Browse files
Add files via upload
1 parent 6b43e2e commit 693085f

6 files changed

+458
-0
lines changed

esphome_configs/esp32-cams.yaml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
esphome:
2+
name: "home-esp32-cam-room"
3+
friendly_name: Home ESP32 Cam – Room
4+
5+
esp32:
6+
board: esp32dev # Generic ESP32 Dev Board
7+
framework:
8+
type: arduino
9+
10+
# Enable logging
11+
logger:
12+
level: VERBOSE
13+
tx_buffer_size: 256
14+
15+
# Enable Home Assistant API + custom service for tuning camera settings on the fly
16+
api:
17+
services:
18+
- service: camera_set_param
19+
variables:
20+
name: string
21+
value: int
22+
then:
23+
- lambda: |-
24+
bool state_return = false;
25+
if (("contrast" == name) && (value >= -2) && (value <= 2)) { id(espcam).set_contrast(value); state_return = true; }
26+
if (("brightness" == name) && (value >= -2) && (value <= 2)) { id(espcam).set_brightness(value); state_return = true; }
27+
if (("saturation" == name) && (value >= -2) && (value <= 2)) { id(espcam).set_saturation(value); state_return = true; }
28+
if (("special_effect" == name) && (value >= 0U) && (value <= 6U)) { id(espcam).set_special_effect((esphome::esp32_camera::ESP32SpecialEffect)value); state_return = true; }
29+
if (("aec_mode" == name) && (value >= 0U) && (value <= 1U)) { id(espcam).set_aec_mode((esphome::esp32_camera::ESP32GainControlMode)value); state_return = true; }
30+
if (("aec2" == name) && (value >= 0U) && (value <= 1U)) { id(espcam).set_aec2(value); state_return = true; }
31+
if (("ae_level" == name) && (value >= -2) && (value <= 2)) { id(espcam).set_ae_level(value); state_return = true; }
32+
if (("aec_value" == name) && (value >= 0U) && (value <= 1200U)) { id(espcam).set_aec_value(value); state_return = true; }
33+
if (("agc_mode" == name) && (value >= 0U) && (value <= 1U)) { id(espcam).set_agc_mode((esphome::esp32_camera::ESP32GainControlMode)value); state_return = true; }
34+
if (("agc_value" == name) && (value >= 0U) && (value <= 30U)) { id(espcam).set_agc_value(value); state_return = true; }
35+
if (("agc_gain_ceiling" == name) && (value >= 0U) && (value <= 6U)) { id(espcam).set_agc_gain_ceiling((esphome::esp32_camera::ESP32AgcGainCeiling)value); state_return = true; }
36+
if (("wb_mode" == name) && (value >= 0U) && (value <= 4U)) { id(espcam).set_wb_mode((esphome::esp32_camera::ESP32WhiteBalanceMode)value); state_return = true; }
37+
if (("test_pattern" == name) && (value >= 0U) && (value <= 1U)) { id(espcam).set_test_pattern(value); state_return = true; }
38+
39+
if (true == state_return) {
40+
id(espcam).update_camera_parameters();
41+
} else {
42+
ESP_LOGW("esp32_camera_set_param", "Error in name or data range");
43+
}
44+
45+
# OTA updates
46+
ota:
47+
- platform: esphome
48+
password: "REPLACE_WITH_PASSWORD"
49+
50+
# Network settings (static IP recommended for stability)
51+
wifi:
52+
ssid: !secret wifi_ssid
53+
password: !secret wifi_password
54+
power_save_mode: none
55+
domain: .your-domain.local
56+
manual_ip:
57+
static_ip: 192.168.1.212
58+
gateway: 192.168.1.1
59+
subnet: 255.255.255.0
60+
dns1: 192.168.1.1
61+
dns2: 8.8.8.8
62+
ap:
63+
ssid: "ESP32-CAM-Fallback"
64+
password: "StrongFallbackPass"
65+
66+
# Camera module configuration
67+
esp32_camera:
68+
id: espcam
69+
name: "Room Camera"
70+
external_clock:
71+
pin: GPIO0
72+
frequency: 8MHz
73+
i2c_pins:
74+
sda: GPIO26
75+
scl: GPIO27
76+
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
77+
vsync_pin: GPIO25
78+
href_pin: GPIO23
79+
pixel_clock_pin: GPIO22
80+
power_down_pin: GPIO32
81+
resolution: 1024x768 # SVGA
82+
jpeg_quality: 30 # 10–63 (lower is better quality)
83+
max_framerate: 25.0fps
84+
idle_framerate: 0.1fps
85+
frame_buffer_count: 2
86+
vertical_flip: false
87+
horizontal_mirror: false
88+
brightness: 2
89+
contrast: 1
90+
special_effect: none
91+
aec_mode: auto
92+
aec2: false
93+
ae_level: 0
94+
aec_value: 300
95+
agc_mode: auto
96+
agc_gain_ceiling: 4x
97+
agc_value: 0
98+
wb_mode: auto
99+
100+
# Lights (onboard white LED & red indicator)
101+
output:
102+
- platform: ledc
103+
channel: 2
104+
pin: GPIO4
105+
id: espCamLED
106+
- platform: gpio
107+
pin:
108+
number: GPIO33
109+
inverted: True
110+
id: gpio_33
111+
112+
light:
113+
- platform: monochromatic
114+
output: espCamLED
115+
name: Room Cam Spotlight
116+
- platform: binary
117+
output: gpio_33
118+
name: Room Cam Status LED
119+
120+
# Restart switch + availability sensor
121+
switch:
122+
- platform: restart
123+
name: Room Cam Restart
124+
125+
binary_sensor:
126+
- platform: status
127+
name: Room Cam Online
128+
129+
# Optional fallback access point
130+
captive_portal:
131+
132+
# Built-in Web Server (stream & snapshot)
133+
esp32_camera_web_server:
134+
- port: 8080
135+
mode: stream
136+
- port: 8081
137+
mode: snapshot
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
esphome:
2+
name: iot-esp32-room-co2th
3+
friendly_name: Home CO2/T/H Sensor – Room
4+
name_add_mac_suffix: false
5+
6+
esp32:
7+
board: esp32-s3-devkitc-1
8+
framework:
9+
type: arduino # Arduino framework for broad compatibility
10+
11+
# Enable logging for debugging (via serial)
12+
logger:
13+
14+
# Home Assistant API for native integration
15+
api:
16+
encryption:
17+
key: "REPLACE_WITH_API_ENCRYPTION_KEY"
18+
19+
# Enable OTA firmware updates
20+
ota:
21+
- platform: esphome
22+
password: "REPLACE_WITH_OTA_PASSWORD"
23+
24+
# Static IP configuration for reliability
25+
wifi:
26+
ssid: !secret wifi_ssid
27+
password: !secret wifi_password
28+
power_save_mode: none
29+
domain: .your-domain.local
30+
manual_ip:
31+
static_ip: 192.168.1.176
32+
gateway: 192.168.1.1
33+
subnet: 255.255.255.0
34+
dns1: 192.168.1.1
35+
dns2: 8.8.8.8
36+
37+
# I²C communication bus for SCD41 sensor
38+
i2c:
39+
sda: GPIO8
40+
scl: GPIO9
41+
scan: true
42+
id: bus_a
43+
44+
# SCD41 sensor – measures CO2, temperature, humidity
45+
sensor:
46+
- platform: scd4x
47+
id: scd41
48+
co2:
49+
name: "CO2 Room"
50+
accuracy_decimals: 0
51+
unit_of_measurement: "ppm"
52+
id: scd41co2
53+
temperature:
54+
name: "Room Temperature"
55+
accuracy_decimals: 1
56+
unit_of_measurement: "°C"
57+
id: scd41_temperature
58+
humidity:
59+
name: "Room Humidity"
60+
accuracy_decimals: 0
61+
unit_of_measurement: "%"
62+
update_interval: 15s
63+
# Add non-linear calibration platform
64+
- platform: template
65+
name: "Room Temperature Calibrated"
66+
unit_of_measurement: "°C"
67+
accuracy_decimals: 1
68+
lambda: |- # Replace values according to measurements table
69+
float slope = -0.31;
70+
float reference_temp = 24.0;
71+
float base_error = 2.3;
72+
return id(scd41_temperature).state + (slope * (id(scd41_temperature).state - reference_temp)) - base_error;
73+
update_interval: 15s
74+
75+
# Manually set a reference CO2 value for calibration
76+
number:
77+
- platform: template
78+
name: "CO2 Calibration Reference"
79+
id: co2_calibration_value
80+
optimistic: true
81+
min_value: 400
82+
max_value: 2000
83+
step: 1
84+
initial_value: 400
85+
unit_of_measurement: "ppm"
86+
icon: "mdi:molecule-co2"
87+
88+
# Buttons to trigger forced calibration or factory reset
89+
button:
90+
- platform: template
91+
name: "Calibrate CO2 Sensor"
92+
icon: "mdi:calibration"
93+
on_press:
94+
then:
95+
- lambda: |-
96+
id(scd41).perform_forced_calibration(id(co2_calibration_value).state);
97+
- logger.log:
98+
format: "Forced calibration with reference %d ppm"
99+
args: ["int(id(co2_calibration_value).state)"]
100+
101+
- platform: template
102+
name: "CO2 Sensor Factory Reset"
103+
icon: "mdi:restore"
104+
id: factory_reset_button
105+
on_press:
106+
then:
107+
- scd4x.factory_reset: scd41
108+
- logger.log: "SCD41 sensor factory reset initiated"
109+
110+
# Optional: Switch for enabling/disabling auto calibration
111+
switch:
112+
- platform: template
113+
name: "CO2 Auto Calibration"
114+
id: co2_auto_calibration
115+
optimistic: true
116+
restore_mode: RESTORE_DEFAULT_ON
117+
icon: "mdi:calibration"
118+
on_turn_on:
119+
- lambda: 'id(scd41).set_automatic_self_calibration(true);'
120+
- logger.log: "Enabled automatic self-calibration"
121+
on_turn_off:
122+
- lambda: 'id(scd41).set_automatic_self_calibration(false);'
123+
- logger.log: "Disabled automatic self-calibration"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
esphome:
2+
name: esp32-temphumid-sensor-room
3+
friendly_name: Home Temp & Humidity Sensor – Room
4+
5+
esp32:
6+
board: esp32-s3-devkitc-1
7+
framework:
8+
type: arduino # Using Arduino framework for stability and compatibility
9+
10+
# Enable verbose logging via UART
11+
logger:
12+
level: DEBUG
13+
baud_rate: 115200 # Default UART speed for serial logging
14+
15+
# Enable API for Home Assistant integration
16+
api:
17+
encryption:
18+
key: "REPLACE_WITH_YOUR_API_ENCRYPTION_KEY"
19+
reboot_timeout: 1min # Reboot if no API connection for 1 minute
20+
port: 6053 # Optional, default ESPHome port
21+
22+
# Enable OTA (Over-the-Air) firmware updates
23+
ota:
24+
- platform: esphome
25+
password: "REPLACE_WITH_YOUR_OTA_PASSWORD"
26+
27+
# Wi-Fi Configuration
28+
wifi:
29+
ssid: !secret wifi_ssid # Use secrets.yaml to protect credentials
30+
password: !secret wifi_password
31+
power_save_mode: none # Better responsiveness
32+
fast_connect: true # Skip scanning other networks
33+
domain: .your-domain.local # Optional: DNS domain for discovery
34+
manual_ip: # Static IP setup for reliability
35+
static_ip: 192.168.1.175 # Replace with IP of your choice
36+
gateway: 192.168.1.1
37+
subnet: 255.255.255.0
38+
dns1: 192.168.1.1
39+
dns2: 8.8.8.8
40+
41+
# Temperature and Humidity Sensor – AM2302 (a DHT22 variant)
42+
sensor:
43+
- platform: dht
44+
pin: GPIO4
45+
model: AM2302
46+
temperature:
47+
name: "Room Temperature"
48+
unit_of_measurement: "°C"
49+
accuracy_decimals: 1
50+
humidity:
51+
name: "Room Humidity"
52+
unit_of_measurement: "%"
53+
accuracy_decimals: 1
54+
update_interval: 10s # Refresh every 10 seconds
55+
56+
# Built-in or external RGB LED for status/feedback
57+
light:
58+
- platform: neopixelbus
59+
pin: GPIO48
60+
variant: WS2812 # Popular individually addressable RGB LED
61+
num_leds: 1 # Single LED
62+
type: GRB # Color ordering format
63+
name: "Sensor RGB LED"
64+
id: esp32_led
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# A stack-in-card used to group multiple graph cards with custom background and styling
2+
3+
type: custom:stack-in-card
4+
card_mod:
5+
style: |
6+
ha-card {
7+
background-image: url('/api/image/serve/REDACTED_IMAGE_ID/512x512'); # Set custom background image
8+
background-size: cover;
9+
background-blend-mode: overlay;
10+
background-color: rgba(0, 0, 0, 0.6); # Semi-transparent overlay for readability
11+
border: 3px solid;
12+
border-radius: 5px;
13+
--ha-card-header-color: orange;
14+
--ha-card-header-font-size: 30px;
15+
min-height: 350px;
16+
display: flex;
17+
flex-direction: column;
18+
justify-content: space-between;
19+
}
20+
mode: vertical # Arrange child cards vertically
21+
cards:
22+
- type: heading
23+
icon: mdi:home-thermometer
24+
heading: Room Sensor
25+
heading_style: title
26+
badges:
27+
- type: entity
28+
entity: sensor.iot_esp32_room_co2th_temperature_calibrated
29+
show_state: true
30+
show_icon: true
31+
state_content: last_changed
32+
card_mod:
33+
style: |
34+
ha-card { align-items: center; }
35+
.title > p { color: orange; font-size: 18px; }
36+
.title ha-icon {
37+
--icon-primary-color: orange;
38+
animation: rotating 2s linear infinite; # Animated icon to suggest live reading
39+
}
40+
41+
- type: sensor
42+
graph: line
43+
entity: sensor.iot_esp32_room_co2th_temperature_calibrated
44+
name: Temperature
45+
hours_to_show: 3
46+
detail: 2 # Detail level for the graph resolution
47+
48+
- type: sensor
49+
graph: line
50+
entity: sensor.iot_esp32_room_co2th_humidity
51+
name: Humidity
52+
hours_to_show: 3
53+
detail: 2
54+
55+
- type: sensor
56+
graph: line
57+
entity: sensor.iot_esp32_room_co2th_co2
58+
name: CO2
59+
hours_to_show: 3
60+
detail: 2
61+
62+
view_layout:
63+
grid-area: d1 # Used if you're placing this card in a grid layout

0 commit comments

Comments
 (0)