Skip to content

Instantly share code, notes, and snippets.

@epsimatic
Last active April 4, 2019 08:04
Show Gist options
  • Save epsimatic/4ba8019124a2dcd1771473ca9bad8d28 to your computer and use it in GitHub Desktop.
Save epsimatic/4ba8019124a2dcd1771473ca9bad8d28 to your computer and use it in GitHub Desktop.
CO₂ autonomous meter with esphome
esphome:
name: co2_meter
platform: ESP8266
board: d1_mini
i2c:
sda: D1
scl: D2
scan: true
sensor:
- platform: mhz19
co2:
name: "Уровень CO₂"
id: co2_level
on_value_range:
- above: 1000
then:
- light.turn_on:
id: led
effect: strobe
- light.turn_on:
id: buzzer
brightness: 25%
# flash_length: 0.1s
- delay: 3s
- light.turn_off: buzzer
- below: 1000
then:
- light.turn_off: led
- light.turn_off: buzzer
temperature:
name: "Температура Wemos"
update_interval: 60s
# For MH-Z19
uart:
tx_pin: D6
rx_pin: D7
baud_rate: 9600
display:
- platform: ssd1306_i2c
model: "SSD1306 64x48"
id: mini_display
address: 0x3C
lambda: |-
if (!id(co2_level).has_state()) {
it.print(it.get_width()/2, it.get_height()/2, id(noto_sb_big), TextAlign::CENTER, "Wait");
} else if (id(co2_level).state > 1000) {
it.fill(COLOR_ON);
it.print(it.get_width()/2, -1, id(noto_sb_small), COLOR_OFF, TextAlign::TOP_CENTER, "CO2 Bad");
it.printf(it.get_width()/2, it.get_height()-4, id(noto_sb_big), COLOR_OFF, TextAlign::BASELINE_CENTER, "%.0f", id(co2_level).state);
} else {
it.print(it.get_width()/2, -1, id(noto_sb_small), TextAlign::TOP_CENTER, "CO2 Level");
it.printf(it.get_width()/2, it.get_height()-4, id(noto_sb_big), TextAlign::BASELINE_CENTER, "%.0f", id(co2_level).state);
}
output:
- id: buzzer_pin
platform: esp8266_pwm
frequency: 1157 Hz
max_power: 0.5
pin: D5
- id: led_pin
platform: esp8266_pwm
pin:
number: D4
inverted: True
light:
- id: led
platform: monochromatic
output: led_pin
default_transition_length: 0.1s
effects:
- strobe:
- flicker:
- id: buzzer
platform: monochromatic
output: buzzer_pin
# name: Buzzer
effects:
- strobe:
font:
- id: noto_sb_small
file: "fonts/NotoSansSymbols-SemiBold.ttf"
size: 10
- id: noto_sb_big
file: "fonts/NotoSansSymbols-SemiBold.ttf"
size: 26
logger:
wifi:
ssid: !secret wifi_name
password: !secret wifi_password
api:
password: !secret esphome_password
ota:
password: !secret esphome_password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment