Created
September 28, 2024 23:14
-
-
Save reconbot/79c2542a609e3b817294c52d47840990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
name: esphome-web-sensors | |
friendly_name: Sensorbox | |
esphome: | |
name: ${name} | |
friendly_name: ${friendly_name} | |
min_version: 2024.6.0 | |
name_add_mac_suffix: false | |
project: | |
name: esphome.web | |
version: '1.0' | |
esp32: | |
board: upesy_wrover | |
framework: | |
type: arduino | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
# Allow Over-The-Air updates | |
ota: | |
- platform: esphome | |
# Allow provisioning Wi-Fi via serial | |
improv_serial: | |
# In combination with the `ap` this allows the user | |
# to provision wifi credentials to the device via WiFi AP. | |
captive_portal: | |
dashboard_import: | |
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main | |
import_full_config: true | |
# To have a "next url" for improv serial | |
web_server: | |
debug: | |
update_interval: 5s | |
wifi: | |
ap: {} | |
# Display dimming | |
globals: | |
- id: dbright | |
type: int | |
restore_value: no | |
initial_value: '0' | |
output: | |
- platform: ledc | |
pin: GPIO32 | |
id: backlight_pwm | |
light: | |
- platform: monochromatic | |
output: backlight_pwm | |
name: "Display Backlight" | |
id: back_light | |
restore_mode: ALWAYS_ON | |
binary_sensor: | |
- platform: gpio | |
pin: | |
number: GPIO04 | |
mode: | |
input: true | |
pullup: true | |
inverted: true | |
id: top_btn | |
filters: | |
- delayed_on: 10ms | |
- delayed_off: 500ms | |
on_press: | |
then: | |
- lambda: |- | |
if (id(dbright) == 0) { id(dbright) = 3; id(back_light).turn_on().set_brightness(1.00).perform();return;} | |
if (id(dbright) == 1) { id(dbright) = 0; id(back_light).turn_off().perform();return;} | |
if (id(dbright) == 2) { id(dbright) = 1; id(back_light).turn_on().set_brightness(0.03).perform();return;} | |
if (id(dbright) == 3) { id(dbright) = 2; id(back_light).turn_on().set_brightness(0.33).perform();return;} | |
# /Display dimming | |
font: | |
- file: "gfonts://Rubik@300" | |
id: font20_l | |
size: 20 | |
bpp: 4 | |
- file: "gfonts://Rubik@400" | |
id: font20 | |
size: 20 | |
bpp: 4 | |
glyphs: [ | |
0,1,2,3,4,5,6,7,8,9, µ, g, p, m, ³, b, /, n, a, C, °, "%", ",", "." | |
] | |
- file: "gfonts://Rubik@400" | |
id: font14 | |
size: 14 | |
bpp: 4 | |
glyphs: [ | |
0,1,2,3,4,5,6,7,8,9, µ, g, p, m, ³, b, /, n, a, C, °, "%", ",", "." | |
] | |
color: | |
- id: white | |
hex: FFFFFF | |
- id: grey | |
hex: AAAAAA | |
- id: yellow | |
hex: FFFA72 | |
- id: orange | |
hex: FF9C32 | |
- id: red | |
hex: FF1616 | |
- id: purple | |
hex: FF16e0 | |
display: | |
- platform: ili9xxx | |
model: ILI9341 | |
cs_pin: GPIO14 | |
dc_pin: GPIO27 | |
reset_pin: GPIO33 | |
#data_rate: 10MHz | |
transform: | |
#mirror_x: true | |
mirror_y: true | |
#show_test_card: true | |
color_order: bgr | |
#Hardcoded limits for value colors, placeholders for the various MQ sensors. If you want the MQ-7 in the same box (not recommended), combine the config from the standalone MQ-7 setup. | |
lambda: |- | |
it.fill(Color::BLACK); | |
auto ub = 200; | |
auto lh = 22; | |
auto cl = 0; | |
auto fon = id(font20); | |
auto fonl = id(font20_l); | |
auto fons = id(font14); | |
auto col = id(white); | |
; | |
auto temp = id(temp_sht40).state; | |
auto hum = id(hum_sht40).state; | |
auto co = float(0); | |
auto co2 = id(co2_scd40).state; | |
auto ch2o = id(ch2o_pms).state; | |
auto bvoce = id(bvoce_bme680).state; | |
auto tvoc = id(tvoc_ens160).state; | |
auto pm1 = id(pm1_pms).state; | |
auto pm25 = id(pm25_pms).state; | |
auto pm10 = id(pm10_pms).state; | |
auto bme_iaq = id(iaq_bme680).state; | |
; | |
cl += lh; | |
; | |
col = id(white); | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "Temp"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.1f", temp); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "°C"); | |
cl += lh; | |
; | |
col = id(white); | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "Hum"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.1f", hum); | |
it.print(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "\%"); | |
cl += lh; | |
; | |
col = id(white); | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "CO"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "n/a"); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "ppm"); | |
cl += lh; | |
; | |
col = id(white); | |
if (co2 > 800){col = id(yellow);} | |
if (co2 > 1200){col = id(orange);} | |
if (co2 > 1500){col = id(red);} | |
if (co2 > 1800){col = id(purple);} | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "CO2"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.0f", co2); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "ppm"); | |
cl += lh; | |
; | |
col = id(white); | |
if (ch2o > 60){col = id(yellow);} | |
if (ch2o > 100){col = id(orange);} | |
if (ch2o > 150){col = id(red);} | |
if (ch2o > 200){col = id(purple);} | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "CH2O"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.1f", ch2o); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "µg/m³"); | |
cl += lh; | |
; | |
col = id(white); | |
if (bme_iaq > 100){col = id(yellow);} | |
if (bme_iaq > 150){col = id(orange);} | |
if (bme_iaq > 200){col = id(red);} | |
if (bme_iaq > 250){col = id(purple);} | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "BVOC BME680"); | |
it.printf(ub, cl, fon, id(white), display::TextAlign::BOTTOM_RIGHT, "%.1f", bvoce); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "ppm"); | |
cl += lh; | |
; | |
col = id(white); | |
if (tvoc > 5){col = id(yellow);} | |
if (tvoc > 10){col = id(orange);} | |
if (tvoc > 15){col = id(red);} | |
if (tvoc > 25){col = id(purple);} | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "TVOC ENS160"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.1f", tvoc); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "ppb"); | |
cl += lh; | |
; | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "PM1"); | |
it.printf(ub, cl, fon, id(white), display::TextAlign::BOTTOM_RIGHT, "%.0f", pm1); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "µg/m³"); | |
cl += lh; | |
; | |
col = id(white); | |
if (pm25 > 5){col = id(yellow);} | |
if (pm25 > 10){col = id(orange);} | |
if (pm25 > 15){col = id(red);} | |
if (pm25 > 25){col = id(purple);} | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "PM2.5"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.0f", pm25); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "µg/m³"); | |
cl += lh; | |
; | |
col = id(white); | |
if (pm10 > 15){col = id(yellow);} | |
if (pm10 > 45){col = id(orange);} | |
if (pm10 > 60){col = id(red);} | |
if (pm10 > 80){col = id(purple);} | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "PM10"); | |
it.printf(ub, cl, fon, col, display::TextAlign::BOTTOM_RIGHT, "%.0f", pm10); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "µg/m³"); | |
cl += lh; | |
; | |
col = id(white); | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "MQ-2"); | |
it.printf(ub, cl, fon, id(white), display::TextAlign::BOTTOM_RIGHT, "n/a"); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "n"); | |
cl += lh; | |
; | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "MQ-7"); | |
it.printf(ub, cl, fon, id(white), display::TextAlign::BOTTOM_RIGHT, "n/a"); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "n"); | |
cl += lh; | |
; | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "MQ-9"); | |
it.printf(ub, cl, fon, id(white), display::TextAlign::BOTTOM_RIGHT, "n/a"); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "n"); | |
cl += lh; | |
; | |
it.print(0, cl, fonl, id(grey), TextAlign::BOTTOM_LEFT, "MQ-135"); | |
it.printf(ub, cl, fon, id(white), display::TextAlign::BOTTOM_RIGHT, "n/a"); | |
it.printf(ub, cl, fons, id(grey), display::TextAlign::BOTTOM_LEFT, "n"); | |
cl += lh; | |
; | |
dimensions: | |
height: 320 | |
width: 240 | |
uart: | |
tx_pin: GPIO19 | |
rx_pin: GPIO25 | |
baud_rate: 9600 | |
id: uart_pms | |
spi: | |
clk_pin: GPIO18 | |
mosi_pin: GPIO23 | |
miso_pin: GPIO12 | |
i2c: | |
sda: GPIO21 | |
scl: GPIO22 | |
scan: true | |
bme680_bsec: | |
address: 0x77 | |
sample_rate: ulp | |
sensor: | |
- platform: homeassistant | |
id: co_mq7 | |
entity_id: sensor.esphome_web_886f9a_mq7_carbon_monoxide | |
- platform: template | |
id: co2p | |
name: "Placeholder CO2" | |
device_class: carbon_dioxide | |
state_class: measurement | |
unit_of_measurement: ppm | |
accuracy_decimals: 0 | |
lambda: |- | |
return 1234; | |
update_interval: 60s | |
- platform: uptime | |
name: "Uptime" | |
id: uptime_sensor | |
update_interval: 5s | |
#internal: true | |
- platform: debug | |
free: | |
name: "Heap Free" | |
id: heap_free | |
#internal: true | |
loop_time: | |
name: "Loop Time" | |
id: loop_time | |
#internal: true | |
- platform: sht4x | |
#addr 0x44 | |
temperature: | |
name: "SHT40 Temperature" | |
id: temp_sht40 | |
humidity: | |
name: "SHT40 Relative Humidity" | |
id: hum_sht40 | |
update_interval: 60s | |
- platform: scd4x | |
#address: 0x62 | |
co2: | |
name: "SCD40 CO2" | |
id: co2_scd40 | |
temperature: | |
name: "SCD40 Temperature" | |
id: temp_scd40 | |
humidity: | |
name: "SCD40 Humidity" | |
id: hum_scd40 | |
update_interval: 300s | |
- platform: ens160_i2c | |
address: 0x53 | |
eco2: | |
name: "ENS160 eCO2" | |
id: eco2_ens160 | |
tvoc: | |
name: "ENS160 Total Volatile Organic Compounds" | |
id: tvoc_ens160 | |
aqi: | |
id: aqi_ens160 | |
name: "ENS160 Air Quality Index" | |
update_interval: 120s | |
compensation: | |
temperature: temp_sht40 | |
humidity: hum_sht40 | |
- platform: aht10 | |
#address: 0x38 | |
variant: AHT20 | |
temperature: | |
name: "AHT20 Temperature" | |
id: temp_aht20 | |
humidity: | |
name: "AHT20 Humidity" | |
id: hum_aht20 | |
update_interval: 60s | |
- platform: bme680_bsec | |
temperature: | |
name: "BME680 Temperature" | |
id: temp_bme680 | |
pressure: | |
name: "BME680 Pressure" | |
id: pres_bme680 | |
humidity: | |
name: "BME680 Humidity" | |
id: hum_bme680 | |
iaq: | |
name: "BME680 IAQ" | |
id: iaq_bme680 | |
co2_equivalent: | |
name: "BME680 CO2 Equivalent" | |
id: co2e_bme680 | |
breath_voc_equivalent: | |
name: "BME680 Breath VOC Equivalent" | |
id: bvoce_bme680 | |
gas_resistance: | |
# Gas resistance in Ω | |
name: "BME680 Gas Resistance" | |
filters: | |
- median | |
iaq_accuracy: | |
# IAQ accuracy as a numeric value of 0, 1, 2, 3 | |
name: "BME680 Numeric IAQ Accuracy" | |
- platform: pmsx003 | |
type: PMS5003S | |
update_interval: 300s | |
uart_id: uart_pms | |
pm_1_0: | |
name: "PMS Particulate Matter <1.0µm Concentration" | |
id: pm1_pms | |
pm_2_5: | |
name: "PMS Particulate Matter <2.5µm Concentration" | |
id: pm25_pms | |
pm_10_0: | |
name: "PMS Particulate Matter <10.0µm Concentration" | |
id: pm10_pms | |
formaldehyde: | |
name: "PMS Formaldehyde" | |
id: ch2o_pms | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment