ESPhome PM Air Quality Sensor Code
CategoriesIoT / Smart Home
After some requests for the code which I have used, here is my working code with an active BME280 temp & humidity sensor. I have #’ed the DHT22 code but left it in here if you want to make use of it. Here is the link to the Printables page where you can download and 3D print your enclosure for this project as well which I have designed: https://www.printables.com/model/527836-pms5003-dht22-or-bme280-esp32s-air-quality-sensor
esphome: name: pm-air friendly_name: pm-air esp32: board: esp32dev framework: type: arduino # Enable logging logger: # Enable Home Assistant API api: encryption: key: "Your_Encryption_Key" ota: platform: esphome password: "Your_Password" wifi: ssid: !secret wifi_ssid password: !secret wifi_password manual_ip: static_ip: 10.0.0.197 gateway: 10.0.0.254 subnet: 255.255.255.0 dns1: 10.0.0.253 dns2: 10.0.0.254 # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Pm-Air Fallback Hotspot" password: "Your_Password" captive_portal: web_server: port: 80 uart: tx_pin: 13 rx_pin: 14 baud_rate: 9600 i2c: #id: bus_a sda: 21 scl: 22 scan: True sensor: - platform: pmsx003 type: PMSX003 pm_1_0: name: "Particulate Matter <1.0µm Concentration" filters: - sliding_window_moving_average: window_size: 30 send_every: 15 pm_2_5: name: "Particulate Matter <2.5µm Concentration" filters: - sliding_window_moving_average: window_size: 30 send_every: 15 pm_10_0: name: "Particulate Matter <10.0µm Concentration" filters: - sliding_window_moving_average: window_size: 25 send_every: 15 - platform: bme280_i2c temperature: name: "Air quality meter Temperature" pressure: name: "Air quality meter Pressure" accuracy_decimals: 1 filters: - lambda: |- const float altitude = 1564.0; // Replace with your altitude in meters const float pressure = x / pow(1.0 - (altitude / 44330.0), 5.255); return pressure; humidity: name: "Air quality meter Humidity" update_interval: 20s address: 0x76 # - platform: dht # model: DHT22 # pin: 32 # temperature: # name: "Air quality meter Temperature" # humidity: # name: "Air quality meter Humidity" # update_interval: 20s switch: - platform: restart name: "Restart PM Air ESP32"
Leave a Reply