Skip to content

Instantly share code, notes, and snippets.

@M3t0r
Created September 26, 2023 15:50
Show Gist options
  • Select an option

  • Save M3t0r/b81ce82796a2ec30f5470f1345f9ca97 to your computer and use it in GitHub Desktop.

Select an option

Save M3t0r/b81ce82796a2ec30f5470f1345f9ca97 to your computer and use it in GitHub Desktop.
esphome:
name: airgradient
name_add_mac_suffix: true
platform: ESP8266
board: d1_mini
# Enable logging
logger:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
encryption:
key: !secret hass_encryption_key
mqtt:
broker: !secret mqtt_broker
port: !secret mqtt_port
username: !secret mqtt_username
password: !secret mqtt_password
i2c:
sda: D2
scl: D1
uart:
- rx_pin: D5
tx_pin: D6
baud_rate: 9600
id: uart_1
- rx_pin: D4
tx_pin: D3
baud_rate: 9600
id: uart_2
sensor:
- platform: sht3xd
temperature:
id: temp
name: "Temperature"
humidity:
id: humidity
name: "Humidity"
address: 0x44
update_interval: 5s
- platform: pmsx003
type: PMSX003
uart_id: uart_1
pm_2_5:
id: pm25
name: "Particulate Matter <2.5µm Concentration"
- platform: senseair
uart_id: uart_2
co2:
id: co2
name: "SenseAir CO2 Value"
update_interval: 60s
font:
- file: "B612-Regular.ttf"
id: ttf_big
size: 14
glyphs: |
!%.-°0123456789/
- file: "B612-Regular.ttf"
id: ttf_small
size: 10
glyphs: |
!%()<+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzµ³²/
display:
- platform: ssd1306_i2c
id: oled_display
model: "SSD1306 64x48"
rotation: '90°'
address: 0x3C
update_interval: 6s
pages:
- id: air
lambda: |-
it.printf(0, 0, id(ttf_big), "%.1f°", id(temp).state);
it.printf(0, 38, id(ttf_big), "%.1f%%", id(humidity).state);
- id: co2_display
lambda: |-
it.printf(0, 0, id(ttf_small), "CO²");
it.printf(0, 17, id(ttf_big), "%.0f", id(co2).state);
it.printf(0, 38, id(ttf_small), "ppm", id(co2).state);
- id: air2
lambda: |-
it.printf(0, 0, id(ttf_big), "%.1f°", id(temp).state);
it.printf(0, 38, id(ttf_big), "%.1f%%", id(humidity).state);
- id: particulate
lambda: |-
it.printf(0, 0, id(ttf_small), "pm<2.5µm", id(temp).state);
it.printf(0, 17, id(ttf_big), "%.0f", id(pm25).state);
it.printf(0, 38, id(ttf_small), "µg/m³", id(pm25).state);
interval:
- interval: 5s
then:
- display.page.show_next: oled_display
- component.update: oled_display
@M3t0r
Copy link
Author

M3t0r commented Sep 26, 2023

Flash on connected AirGradient:

podman run --rm --privileged --device=/dev/ttyUSB0 -v "${PWD}":/config -it ghcr.io/esphome/esphome run esphome.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment