esp/esp32-c3-oled/i2ctest.yaml

173 lines
3.4 KiB
YAML
Raw Normal View History

2025-10-24 17:46:40 +02:00
esphome:
name: oled-test
friendly_name: oled test
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "rNfuxXEaIvVuOHvYVdb4QpW8fezbbkKn3wvjkHdHGkY="
ota:
- platform: esphome
password: "5aa6ac416280761455b83922c266822b"
wifi:
ssid: "Lothlorien"
password: "LitwoOjczyznoMojaTysJestJakZdrowie"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-C3-Oled-Test"
password: "Zto2fEEcWgnS"
captive_portal:
web_server:
output:
- platform: ledc
pin: GPIO4
id: led_pwm
frequency: 20000 Hz # 20 kHz bez pisku i bez migotania w kamerze
light:
- platform: monochromatic
name: "LED PWM"
output: led_pwm
gamma_correct: 1.0
button:
- platform: restart
name: "Restart Device"
- platform: safe_mode
name: "Restart in Safe Mode"
i2c:
id: bus_oled
sda: GPIO5
scl: GPIO6
frequency: 100kHz
scan: true
# --- Czcionki do wyświetlacza (wygodne, ale możesz zmienić na swoje) ---
font:
- file: "fonts/Roboto-Regular.ttf"
id: f12
size: 8
- file: "fonts/Roboto-Bold.ttf"
id: f20
size: 11
# --- Przydatne sensory do pokazania na ekranie ---
sensor:
- platform: wifi_signal
name: "WiFi RSSI"
id: wifi_rssi
update_interval: 30s
- platform: uptime
name: "Uptime (s)"
id: uptime_s
update_interval: 60s
- platform: hm3301
2025-10-27 21:40:42 +01:00
i2c_id: bus_oled
update_interval: 30s
2025-10-24 17:46:40 +02:00
pm_1_0:
name: "PM1.0"
2025-10-27 21:40:42 +01:00
id: pm_1_0
2025-10-24 17:46:40 +02:00
pm_2_5:
name: "PM2.5"
2025-10-27 21:40:42 +01:00
id: pm_2_5
2025-10-24 17:46:40 +02:00
pm_10_0:
2025-10-27 21:40:42 +01:00
name: "PM10"
id: pm_10_0
- platform: dht
pin: GPIO10
model: DHT11
temperature:
name: "Temperatura"
humidity:
name: "Wilgotność"
update_interval: 30s
- platform: bmp3xx_i2c
i2c_id: bus_oled
address: 0x77 # jeśli skan pokaże 0x76, zmień tutaj
temperature:
name: "Temperatura BMP388"
oversampling: 16x
pressure:
name: "Ciśnienie BMP388"
oversampling: 16x
update_interval: 30s
2025-10-24 17:46:40 +02:00
text_sensor:
- platform: wifi_info
ip_address:
name: "IP"
id: ip_addr
ssid:
name: "SSID"
id: wifi_ssid
# --- Przycisk BOOT (ten „użytkowy”; RESET/EN nie da się odczytać) ---
binary_sensor:
- platform: gpio
pin:
number: GPIO9 # BOOT na większości C3
mode: INPUT_PULLUP
inverted: true
name: "BOOT Button"
id: btn_boot
- platform: gpio
pin:
number: GPIO7
mode:
input: true
pullup: false
pulldown: true
name: "Czujnik ruchu SR505"
device_class: motion
filters:
- delayed_off: 2s
- platform: gpio
pin:
number: GPIO3
mode:
input: true
pullup: false
pulldown: false
name: "Czujnik ruchu HW-416A"
device_class: motion
filters:
- delayed_off: 2s
# --- Wyświetlacz OLED ---
display:
- platform: ssd1306_i2c
model: "SSD1306 72x40"
address: 0x3C
rotation: 0
i2c_id: bus_oled # <- to jest kluczowe
lambda: |-
{
if (id(ip_addr).has_state()) {
it.printf(0, 0, id(f12), "ip:%s", id(ip_addr).state.c_str());
} else {
it.printf(0, 0, id(f12), "ip: (brak)");
}
2025-10-27 21:40:42 +01:00
it.printf(0, 10, id(f12), "PM1: %.0f", id(pm_1_0).state);
it.printf(0, 20, id(f12), "PM2.5:%.0f", id(pm_2_5).state);
it.printf(0, 30, id(f12), "PM10: %.0f", id(pm_10_0).state);
2025-10-24 17:46:40 +02:00
}