2020-09-15 12:54:25 +02:00
|
|
|
substitutions:
|
|
|
|
node_name: !env_var co2ampel
|
2020-11-10 16:00:35 +01:00
|
|
|
|
2020-09-02 13:07:18 +02:00
|
|
|
esphome:
|
2020-09-15 12:54:25 +02:00
|
|
|
name: co2ampel_${node_name}
|
2020-09-02 13:07:18 +02:00
|
|
|
platform: ESP32
|
|
|
|
board: esp32doit-devkit-v1
|
|
|
|
on_boot:
|
2020-09-15 12:54:25 +02:00
|
|
|
- display.page.show: boot
|
2020-11-10 16:00:35 +01:00
|
|
|
# manually define needed libs to avoid broken NeoPixelBus-esphome@2.5.7 (we use the upstream version 2.6.0 instead)
|
|
|
|
platformio_options:
|
|
|
|
lib_deps: NeoPixelBus@2.6.0, AsyncTCP-esphome, ESPAsyncTCP-esphome, AsyncTCP-esphome, AsyncMqttClient-esphome, ESPAsyncTCP-esphome, AsyncTCP-esphome, ArduinoJson-esphomelib@5.13.3, ESPAsyncWebServer-esphome
|
|
|
|
|
|
|
|
|
2020-09-15 12:54:25 +02:00
|
|
|
ota:
|
|
|
|
safe_mode: True
|
|
|
|
password: !secret ota_passwd
|
|
|
|
|
2020-09-02 13:07:18 +02:00
|
|
|
|
|
|
|
logger:
|
|
|
|
level: DEBUG
|
|
|
|
wifi:
|
|
|
|
ssid: !secret wifi_ssid
|
|
|
|
password: !secret wifi_passwd
|
2020-09-15 12:54:25 +02:00
|
|
|
ap:
|
|
|
|
ssid: "co2ampel"
|
|
|
|
password: ""
|
|
|
|
captive_portal:
|
2020-09-02 13:07:18 +02:00
|
|
|
mqtt:
|
2020-09-15 12:54:25 +02:00
|
|
|
broker: co2.cyber23.de
|
|
|
|
topic_prefix: co2ampel/${node_name}
|
2020-09-02 13:07:18 +02:00
|
|
|
birth_message:
|
2020-09-15 12:54:25 +02:00
|
|
|
topic: co2ampel/${node_name}/status
|
2020-09-02 13:07:18 +02:00
|
|
|
payload: online
|
|
|
|
will_message:
|
2020-09-15 12:54:25 +02:00
|
|
|
topic: co2ampel/${node_name}/status
|
2020-09-02 13:07:18 +02:00
|
|
|
payload: offline
|
|
|
|
|
|
|
|
uart:
|
2020-09-07 16:26:06 +02:00
|
|
|
rx_pin: GPIO16
|
|
|
|
tx_pin: GPIO17
|
2020-09-02 13:07:18 +02:00
|
|
|
baud_rate: 9600
|
|
|
|
id: uart_mhz19
|
|
|
|
|
|
|
|
light:
|
|
|
|
- platform: neopixelbus
|
|
|
|
pin: GPIO4
|
|
|
|
num_leds: 12
|
|
|
|
name: "ws2812 ring"
|
|
|
|
id: "ws2812"
|
|
|
|
restore_mode: ALWAYS_OFF
|
|
|
|
|
|
|
|
output:
|
|
|
|
- platform: ledc
|
|
|
|
pin: GPIO12
|
|
|
|
id: buzzer
|
|
|
|
|
|
|
|
sensor:
|
|
|
|
- platform: mhz19
|
2020-09-07 16:26:06 +02:00
|
|
|
update_interval: 10s
|
|
|
|
automatic_baseline_calibration: true
|
2020-09-02 15:40:29 +02:00
|
|
|
uart_id: uart_mhz19
|
|
|
|
temperature:
|
2020-09-15 12:54:25 +02:00
|
|
|
name: ${node_name} Temperature
|
2020-09-02 15:40:29 +02:00
|
|
|
id: mhz19_temp
|
2020-09-02 13:07:18 +02:00
|
|
|
co2:
|
2020-09-15 12:54:25 +02:00
|
|
|
name: ${node_name} PPM
|
2020-09-02 13:07:18 +02:00
|
|
|
id: mhz19_co2
|
|
|
|
on_value:
|
|
|
|
then:
|
|
|
|
if:
|
|
|
|
condition:
|
|
|
|
sensor.in_range:
|
|
|
|
id: mhz19_co2
|
|
|
|
above: 0
|
|
|
|
below: 800
|
|
|
|
then:
|
|
|
|
- light.turn_off:
|
|
|
|
id: ws2812
|
|
|
|
- display.page.show: co2
|
|
|
|
else:
|
|
|
|
if:
|
|
|
|
condition:
|
|
|
|
sensor.in_range:
|
|
|
|
id: mhz19_co2
|
|
|
|
above: 800
|
2020-11-01 14:09:22 +01:00
|
|
|
below: 1000
|
2020-09-02 13:07:18 +02:00
|
|
|
then:
|
|
|
|
- light.turn_on:
|
|
|
|
id: ws2812
|
|
|
|
brightness: 80%
|
|
|
|
red: 50%
|
|
|
|
green: 50%
|
|
|
|
blue: 0%
|
2020-09-15 12:54:25 +02:00
|
|
|
- display.page.show: co2
|
2020-09-02 13:07:18 +02:00
|
|
|
else:
|
|
|
|
if:
|
|
|
|
condition:
|
|
|
|
sensor.in_range:
|
|
|
|
id: mhz19_co2
|
2020-11-01 14:09:22 +01:00
|
|
|
above: 1000
|
2020-09-02 13:07:18 +02:00
|
|
|
then:
|
|
|
|
- light.turn_on:
|
|
|
|
id: ws2812
|
|
|
|
brightness: 100%
|
|
|
|
red: 100%
|
|
|
|
green: 0%
|
|
|
|
blue: 0%
|
2020-09-15 12:54:25 +02:00
|
|
|
# - output.turn_on: buzzer
|
|
|
|
# - output.ledc.set_frequency:
|
|
|
|
# id: buzzer
|
|
|
|
# frequency: "5000Hz"
|
|
|
|
# - output.set_level:
|
|
|
|
# id: buzzer
|
|
|
|
# level: "20%"
|
|
|
|
# - delay: 10ms
|
|
|
|
# - output.turn_off: buzzer
|
2020-11-01 14:09:22 +01:00
|
|
|
- delay: 500ms
|
|
|
|
- light.toggle: ws2812
|
|
|
|
- delay: 500ms
|
|
|
|
- light.toggle: ws2812
|
2020-09-15 12:54:25 +02:00
|
|
|
- delay: 500ms
|
|
|
|
- light.toggle: ws2812
|
2020-09-02 13:07:18 +02:00
|
|
|
- delay: 500ms
|
2020-09-15 12:54:25 +02:00
|
|
|
- light.toggle: ws2812
|
2020-09-02 13:07:18 +02:00
|
|
|
- lambda: |-
|
|
|
|
static int num_executions = 0;
|
|
|
|
ESP_LOGD("main", "I am at execution number %d", num_executions);
|
|
|
|
num_executions += 1;
|
2020-09-15 12:54:25 +02:00
|
|
|
- display.page.show: co2
|
2020-09-02 13:07:18 +02:00
|
|
|
i2c:
|
|
|
|
sda: GPIO21
|
|
|
|
scl: GPIO22
|
|
|
|
|
|
|
|
font:
|
|
|
|
- file: "font.ttf"
|
|
|
|
id: cust_font
|
2020-11-01 14:09:22 +01:00
|
|
|
size: 70
|
2020-09-02 13:07:18 +02:00
|
|
|
|
|
|
|
display:
|
|
|
|
- platform: ssd1306_i2c
|
|
|
|
model: "SSD1306 128x64"
|
|
|
|
address: 0x3C
|
|
|
|
brightness: 100%
|
2020-09-07 16:26:06 +02:00
|
|
|
update_interval: 10s
|
2020-09-02 13:07:18 +02:00
|
|
|
pages:
|
|
|
|
- id: boot
|
|
|
|
lambda: |-
|
2020-11-01 14:09:22 +01:00
|
|
|
it.printf(64, 0, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, ":-)");
|
2020-09-02 13:07:18 +02:00
|
|
|
- id: co2
|
|
|
|
lambda: |-
|
2020-11-01 14:09:22 +01:00
|
|
|
int ergb;
|
|
|
|
ergb = id(mhz19_co2).state/100;
|
|
|
|
it.printf(64, 0, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, "%.0i", ergb);
|
|
|
|
# it.printf(64, 16, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, "%.0fPPM", id(mhz19_co2).state);
|
2020-09-02 13:07:18 +02:00
|
|
|
# it.printf(64, 40, id(cust_font),TextAlign::TOP_CENTER, "%.0f°C", id(mhz19_temp).state);
|