From 906c3caf2cdc2586ccbfadfb947de337eb3a4c40 Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Mon, 28 Jul 2025 11:27:12 +0200 Subject: [PATCH] control box --- filter_v2_fan.yaml | 150 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 132 insertions(+), 18 deletions(-) diff --git a/filter_v2_fan.yaml b/filter_v2_fan.yaml index 4f392cc..dd0e58d 100644 --- a/filter_v2_fan.yaml +++ b/filter_v2_fan.yaml @@ -1,17 +1,16 @@ esphome: - name: esp-filter2 - friendly_name: ESP-FILTER2 + name: esp-control + friendly_name: ESP-CONTROL esp32: board: esp32-s3-devkitc-1 framework: - type: arduino + type: esp-idf + version: latest -# Enable logging logger: level: verbose -# Enable Home Assistant API api: encryption: key: !secret api_key @@ -21,16 +20,16 @@ ota: password: !secret ota_password wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - manual_ip: - static_ip: 192.168.1.60 - gateway: 192.168.1.254 - subnet: 255.255.255.0 - dns1: 9.9.9.9 - dns2: 149.112.112.112 + networks: + - ssid: !secret wifi_ssid + password: !secret wifi_password + manual_ip: + static_ip: 192.168.1.60 + gateway: 192.168.1.254 + subnet: 255.255.255.0 + dns1: 9.9.9.9 + dns2: 149.112.112.112 - # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Esp32S3N16R8 Fallback Hotspot" password: "v41VUZA7A1VA" @@ -40,19 +39,134 @@ mqtt: port: 18832 username: fire password: !secret mqtt_password - topic_prefix: "esp_filter_blower_fan" + topic_prefix: "esp_control" output: - platform: ledc pin: GPIO5 - id: fan_pwm_output + id: fan_pwm_output1 + frequency: 25000Hz + - platform: ledc + pin: GPIO6 + id: fan_pwm_output2 + frequency: 25000Hz + - platform: ledc + pin: GPIO7 + id: fan_pwm_output3 frequency: 25000Hz fan: - platform: speed - output: fan_pwm_output - name: "12V Blower Fan" + output: fan_pwm_output1 + name: "12V fan 1" + - platform: speed + output: fan_pwm_output2 + name: "12V fan 2" + - platform: speed + output: fan_pwm_output3 + name: "12V fan 3" + +# ===== PMS5003 PM2.5 Sensor ===== +uart: + id: uart_pms + rx_pin: 47 + tx_pin: 48 + baud_rate: 9600 + +i2c: + - id: bus_i2c + scl: 20 + sda: 21 + scan: true + +sensor: +# ===== SGP40 Indoor Air Quality (VOC) ===== + - platform: sgp4x + voc: + name: "VOC Index" + i2c_id: bus_i2c + address: 0x59 + update_interval: 30s + compensation: + temperature_source: aht10_temperature + humidity_source: aht10_humidity +# ===== PMS5003 PM2.5 Sensor ===== + - platform: pmsx003 + type: PMSX003 + pm_1_0: + name: "PM <1.0µm Concentration" + pm_2_5: + name: "PM <2.5µm Concentration" + pm_10_0: + name: "PM <10.0µm Concentration" + uart_id: uart_pms + update_interval: 30s +# ===== AHT10 Temperature & Humidity ===== + - platform: aht10 + temperature: + name: "AHT10 Temperature" + id: aht10_temperature + humidity: + name: "AHT10 Humidity" + id: aht10_humidity + address: 0x38 + i2c_id: bus_i2c + update_interval: 30s +# ===== BME680 Indoor Air Quality ===== + - platform: bme680 + temperature: + name: "BME680 Temperature" + oversampling: 16x + pressure: + name: "BME680 Pressure" + humidity: + id: "humidity" + name: "BME680 Humidity" + gas_resistance: + id: "gas_resistance" + name: "BME680 Gas Resistance" + address: 0x77 + i2c_id: bus_i2c + update_interval: 60s + - platform: template + name: "BME680 Indoor Air Quality" + id: iaq + icon: "mdi:gauge" + # calculation: comp_gas = log(R_gas[ohm]) + 0.04 log(Ohm)/%rh * hum[%rh] + lambda: |- + return log(id(gas_resistance).state) + 0.04 * id(humidity).state; + state_class: "measurement" + +text_sensor: + - platform: template + name: "BME680 IAQ Classification" + icon: "mdi:checkbox-marked-circle-outline" + lambda: |- + if (int(id(iaq).state) <= 50) { + return {"Excellent"}; + } + else if (int(id(iaq).state) <= 100) { + return {"Good"}; + } + else if (int(id(iaq).state) <= 150) { + return {"Lightly polluted"}; + } + else if (int(id(iaq).state) <= 200) { + return {"Moderately polluted"}; + } + else if (int(id(iaq).state) <= 250) { + return {"Heavily polluted"}; + } + else if (int(id(iaq).state) <= 350) { + return {"Severely polluted"}; + } + else if (int(id(iaq).state) <= 500) { + return {"Extremely polluted"}; + } + else { + return {"unknown"}; + }