Created
July 27, 2024 14:51
-
-
Save vinibaggio/a75aa617c1927a28e6f2a13641452b92 to your computer and use it in GitHub Desktop.
ESPHome + BME680 + PMSx003 AQM
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
esphome: | |
name: YOURAQM | |
esp8266: | |
board: d1_mini | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
ota: | |
password: "" | |
wifi: | |
ssid: "Your Wifi" | |
password: "Your Password" | |
fast_connect: true | |
# I had issues with DHCP so I configured a static IP. | |
manual_ip: | |
static_ip: 192.168.x.x | |
gateway: 192.168.x.x | |
subnet: 255.255.x.x | |
i2c: | |
scan: true | |
sda: 4 # default pins | |
scl: 5 | |
frequency: 100000 | |
switch: | |
- platform: gpio | |
pin: | |
number: 0 | |
id: pms_set | |
name: "Start measuring" | |
uart: | |
baud_rate: 9600 # Required by PMS5003 | |
tx_pin: 14 | |
rx_pin: 12 | |
interval: | |
- interval: 300s | |
then: | |
- switch.turn_on: pms_set | |
- delay: 20s | |
- switch.turn_off: pms_set | |
bme680_bsec: | |
# id | |
# ----------- | |
# Identifier for this component, useful when working with multiple devices. | |
# Must be unique, and can be used in the sensor sections to refer to the correct device. | |
# Default: auto-computed | |
id: i2cbus_bme | |
# i2c address | |
# ----------- | |
# Common values are: | |
# - 0x76 | |
# - 0x77 | |
# Default: 0x76 | |
address: 0x77 | |
# Temperature offset | |
# ------------------ | |
# Useful if device is in enclosure and reads too high | |
# For example, if it reads 5C too high, set this to 5 | |
# This also corrects the relative humidity readings | |
# Default: 0 | |
temperature_offset: 2 | |
# IAQ calculation mode | |
# -------------------- | |
# Available options: | |
# - static (for fixed position devices) | |
# - mobile (for on a person or other moveable devices) | |
# Default: static | |
iaq_mode: static | |
# Sample rate | |
# ----------- | |
# Available options: | |
# - lp (low power - samples every 3 seconds) | |
# - ulp (ultra-low power - samples every 5 minutes) | |
# Default: lp | |
sample_rate: lp | |
# Interval at which to save BSEC state | |
# ------------------------------------ | |
# Default: 6h | |
state_save_interval: 6h | |
sensor: | |
- platform: bme680_bsec | |
# ID of the bme680_bsec component to use for the next sensors. | |
# Useful when working with multiple devices | |
bme680_bsec_id: i2cbus_bme | |
temperature: | |
# Temperature in °C | |
name: "Temperature" | |
sample_rate: lp | |
filters: | |
- median | |
pressure: | |
# Pressure in hPa | |
name: "Pressure" | |
sample_rate: lp | |
filters: | |
- median | |
humidity: | |
# Relative humidity % | |
name: "Humidity" | |
sample_rate: lp | |
filters: | |
- median | |
gas_resistance: | |
# Gas resistance in Ω | |
name: "Gas Resistance" | |
filters: | |
- median | |
iaq: | |
# Indoor air quality value | |
name: "IAQ" | |
id: iaq | |
filters: | |
- median | |
iaq_accuracy: | |
# IAQ accuracy as a numeric value of 0, 1, 2, 3 | |
name: "Numeric IAQ Accuracy" | |
co2_equivalent: | |
# CO2 equivalent estimate in ppm | |
name: "CO2 Equivalent" | |
filters: | |
- median | |
breath_voc_equivalent: | |
# Volatile organic compounds equivalent estimate in ppm | |
name: "Breath VOC Equivalent" | |
filters: | |
- median | |
- platform: pmsx003 | |
type: PMSX003 | |
pm_1_0: | |
name: "Particulate Matter <1.0µm Concentration" | |
pm_2_5: | |
name: "Particulate Matter <2.5µm Concentration" | |
pm_10_0: | |
name: "Particulate Matter <10.0µm Concentration" | |
text_sensor: | |
- platform: bme680_bsec | |
iaq_accuracy: | |
# IAQ accuracy as a text value of Stabilizing, Uncertain, Calibrating, Calibrated | |
name: "IAQ Accuracy" | |
- platform: template | |
name: "IAQ Classification" | |
icon: "mdi:checkbox-marked-circle-outline" | |
lambda: |- | |
if ( int(id(iaq).state) <= 50) { | |
return {"Excellent"}; | |
} | |
else if (int(id(iaq).state) >= 51 && int(id(iaq).state) <= 100) { | |
return {"Good"}; | |
} | |
else if (int(id(iaq).state) >= 101 && int(id(iaq).state) <= 150) { | |
return {"Lightly polluted"}; | |
} | |
else if (int(id(iaq).state) >= 151 && int(id(iaq).state) <= 200) { | |
return {"Moderately polluted"}; | |
} | |
else if (int(id(iaq).state) >= 201 && int(id(iaq).state) <= 250) { | |
return {"Heavily polluted"}; | |
} | |
else if (int(id(iaq).state) >= 251 && int(id(iaq).state) <= 350) { | |
return {"Severely polluted"}; | |
} | |
else if (int(id(iaq).state) >= 351) { | |
return {"Extremely polluted"}; | |
} | |
else { | |
return {"error"}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment