Add d1-mini-scd40-27afc1
This commit is contained in:
parent
334169533e
commit
979f9c0ae1
5
nodes/d1-mini-scd40-27afc1/.gitignore
vendored
Normal file
5
nodes/d1-mini-scd40-27afc1/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Gitignore settings for ESPHome
|
||||
# This is an example and may include too much for your use-case.
|
||||
# You can modify this file to suit your needs.
|
||||
/.esphome/
|
||||
/secrets.yaml
|
247
nodes/d1-mini-scd40-27afc1/firmware.yaml
Normal file
247
nodes/d1-mini-scd40-27afc1/firmware.yaml
Normal file
@ -0,0 +1,247 @@
|
||||
---
|
||||
|
||||
substitutions:
|
||||
macsuffix: "27afc1"
|
||||
|
||||
wifi:
|
||||
power_save_mode: LIGHT
|
||||
|
||||
improv_serial:
|
||||
|
||||
globals:
|
||||
# Configure CO2 indicator thresholds
|
||||
- id: threshold1
|
||||
type: float
|
||||
initial_value: '750'
|
||||
- id: threshold2
|
||||
type: float
|
||||
initial_value: '1200'
|
||||
- id: threshold3
|
||||
type: float
|
||||
initial_value: '1500'
|
||||
- id: threshold4
|
||||
type: float
|
||||
initial_value: '1750'
|
||||
- id: threshold5
|
||||
type: float
|
||||
initial_value: '2000'
|
||||
|
||||
# Configure the brightness values for the LED indicator
|
||||
- id: dim
|
||||
type: float
|
||||
initial_value: '0.5'
|
||||
- id: bright
|
||||
type: float
|
||||
initial_value: '1.0'
|
||||
|
||||
esphome:
|
||||
name: "d1-mini-scd40-${macsuffix}"
|
||||
project:
|
||||
name: "cccda.d1-mini-scd40"
|
||||
version: "2023052001"
|
||||
comment: "https://git.darmstadt.ccc.de/cda/co2-sensor-workshop/"
|
||||
on_boot:
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: indicator
|
||||
red: 0
|
||||
green: 0.2
|
||||
blue: 1.0
|
||||
effect: "None"
|
||||
brightness: 30%
|
||||
|
||||
esp8266:
|
||||
board: d1_mini
|
||||
|
||||
captive_portal:
|
||||
|
||||
logger:
|
||||
level: DEBUG
|
||||
logs:
|
||||
light: INFO
|
||||
sensor: INFO
|
||||
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
api:
|
||||
reboot_timeout: 0s
|
||||
|
||||
# Enable either SNTP or Home Assistant as a time source
|
||||
time:
|
||||
# https://esphome.io/components/time/sntp.html
|
||||
- platform: sntp
|
||||
id: time_source
|
||||
timezone: "Europe/Berlin"
|
||||
# Disable LED indicator during nighttime
|
||||
# https://esphome.io/components/time/index.html#on-time-trigger
|
||||
on_time:
|
||||
- hours: 8
|
||||
minutes: 0
|
||||
seconds: 0
|
||||
then:
|
||||
- light.turn_on:
|
||||
# cold white
|
||||
id: indicator
|
||||
red: 0.9
|
||||
green: 0.9
|
||||
blue: 0.9
|
||||
effect: "None"
|
||||
brightness: !lambda |-
|
||||
return id(dim);
|
||||
- logger.log: "Leaving night mode via on_time, enabling LED indicator."
|
||||
- hours: 22
|
||||
minutes: 0
|
||||
seconds: 0
|
||||
then:
|
||||
- light.turn_off: indicator
|
||||
- logger.log: "Entering night mode via on_time, disabling LED indicator."
|
||||
on_time_sync:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |
|
||||
return
|
||||
(id(time_source).now().hour < 8 ||
|
||||
id(time_source).now().hour >= 22);
|
||||
then:
|
||||
- light.turn_off: indicator
|
||||
- logger.log: "Entering night mode via on_time_sync, disabling LED indicator."
|
||||
|
||||
i2c:
|
||||
scl: GPIO5
|
||||
sda: GPIO4
|
||||
scan: false
|
||||
|
||||
sensor:
|
||||
- platform: scd4x
|
||||
id: scd40
|
||||
# low power mode
|
||||
measurement_mode: low_power_periodic
|
||||
update_interval: 30s
|
||||
# Apply a temperature correction offset, that gets substracted
|
||||
# from the measured temperature, defaults to 4.0
|
||||
#temperature_offset: 1.5
|
||||
co2:
|
||||
name: "${macsuffix} CO2"
|
||||
on_value:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- lambda: return (x < id(threshold1));
|
||||
- light.is_on: indicator
|
||||
then:
|
||||
- light.turn_on:
|
||||
# cold white
|
||||
id: indicator
|
||||
red: 0.9
|
||||
green: 0.9
|
||||
blue: 0.9
|
||||
effect: "None"
|
||||
brightness: !lambda |-
|
||||
return id(dim);
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- lambda: return (x > id(threshold1) and x < id(threshold2));
|
||||
- light.is_on: indicator
|
||||
then:
|
||||
- light.turn_on:
|
||||
# neutral white
|
||||
id: indicator
|
||||
red: 1.0
|
||||
green: 0.84
|
||||
blue: 0.54
|
||||
effect: "None"
|
||||
brightness: !lambda |-
|
||||
return id(bright);
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- lambda: return (x > id(threshold2) and x < id(threshold3));
|
||||
- light.is_on: indicator
|
||||
then:
|
||||
- light.turn_on:
|
||||
# warmwhite
|
||||
id: indicator
|
||||
red: 1.0
|
||||
green: 0.75
|
||||
blue: 0.0
|
||||
effect: "None"
|
||||
brightness: !lambda |-
|
||||
return id(bright);
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- lambda: return (x > id(threshold3) and x < id(threshold4));
|
||||
- light.is_on: indicator
|
||||
then:
|
||||
- light.turn_on:
|
||||
# orange
|
||||
id: indicator
|
||||
red: 1.0
|
||||
green: 0.5
|
||||
blue: 0.0
|
||||
effect: "None"
|
||||
brightness: !lambda |-
|
||||
return id(bright);
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- lambda: return (x > id(threshold4) and x < id(threshold5));
|
||||
- light.is_on: indicator
|
||||
then:
|
||||
- light.turn_on:
|
||||
# red
|
||||
id: indicator
|
||||
red: 1.0
|
||||
green: 0.0
|
||||
blue: 0.0
|
||||
effect: "None"
|
||||
brightness: !lambda |-
|
||||
return id(bright);
|
||||
- if:
|
||||
condition:
|
||||
- lambda: return (x > id(threshold5));
|
||||
- light.is_on: indicator
|
||||
then:
|
||||
- light.turn_on:
|
||||
# red pulse
|
||||
id: indicator
|
||||
red: 1.0
|
||||
green: 0.0
|
||||
blue: 0.0
|
||||
effect: "Fast Pulse"
|
||||
brightness: !lambda |-
|
||||
return id(bright);
|
||||
humidity:
|
||||
name: "${macsuffix} Humidity"
|
||||
temperature:
|
||||
name: "${macsuffix} Temperature"
|
||||
|
||||
button:
|
||||
- platform: template
|
||||
name: "${macsuffix} Force CO2 Sensor Calibration"
|
||||
icon: "mdi:restart"
|
||||
on_press:
|
||||
then:
|
||||
- scd4x.perform_forced_calibration:
|
||||
# Average outdoor value for March 2023
|
||||
# https://www.co2.earth/daily-co2
|
||||
value: 421
|
||||
id: scd40
|
||||
|
||||
light:
|
||||
- platform: neopixelbus
|
||||
id: indicator
|
||||
name: "${macsuffix} CO2 Level Indicator"
|
||||
type: GRB
|
||||
variant: WS2812
|
||||
pin: GPIO0
|
||||
num_leds: 3
|
||||
effects:
|
||||
- pulse:
|
||||
name: "Fast Pulse"
|
||||
transition_length: 0.5s
|
||||
update_interval: 0.5s
|
Loading…
Reference in New Issue
Block a user