Mercurial > code > home > repos > micro
annotate air-quality/tr-air-quality.yaml @ 20:ec7e7d2c763f
aq sync and refactors; start hw.md
author | drewp@bigasterisk.com |
---|---|
date | Tue, 13 Aug 2024 22:38:39 -0700 |
parents | tr-air-quality.yaml@dcd981e1386b |
children |
rev | line source |
---|---|
20 | 1 substitutions: |
2 location: tr | |
3 location_caps: TR | |
4 | |
5 esphome: | |
6 name: "${location}-air-quality" | |
10 | 7 platform: ESP32 |
8 board: featheresp32 | |
20 | 9 on_boot: |
10 priority: 590 | |
11 then: | |
12 - script.execute: on_wifi_disconnect | |
10 | 13 |
14 logger: | |
15 level: DEBUG | |
16 logs: | |
17 sensor: INFO | |
18 pmsx003: INFO | |
19 | |
20 wifi: | |
21 networks: | |
22 - ssid: !secret wifi_ssid | |
20 | 23 password: !secret wifi_password |
10 | 24 on_connect: |
25 then: | |
20 | 26 - script.execute: on_wifi_connect |
10 | 27 on_disconnect: |
28 then: | |
20 | 29 - script.execute: on_wifi_disconnect |
10 | 30 |
31 ota: | |
32 platform: esphome | |
33 password: !secret ota_password_1 | |
34 | |
35 mqtt: | |
36 id: mqtt_client | |
20 | 37 broker: "mqtt2.bigasterisk.com" |
10 | 38 |
39 uart: | |
40 rx_pin: 13 | |
41 baud_rate: 9600 | |
42 | |
43 sensor: | |
44 - platform: pmsx003 | |
45 type: PMS5003T | |
46 pm_1_0: | |
47 name: "Particulate Matter <1.0µm Concentration" | |
48 pm_2_5: | |
49 name: "Particulate Matter <2.5µm Concentration" | |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
50 id: pm_2_5 |
10 | 51 pm_10_0: |
52 name: "Particulate Matter <10.0µm Concentration" | |
53 temperature: | |
54 name: "air temperature C" | |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
55 id: air_temp_c |
10 | 56 |
20 | 57 - platform: wifi_signal |
58 id: my_wifi_signal | |
59 name: wifi_signal | |
60 update_interval: 4s | |
61 internal: true # no mqtt | |
62 | |
10 | 63 spi: |
64 clk_pin: GPIO18 | |
65 mosi_pin: GPIO19 | |
66 | |
67 font: | |
20 | 68 - file: "../fonts/PassionOne-Regular.ttf" |
10 | 69 id: font_14 |
20 | 70 size: 34 |
71 glyphs: "%-.°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " | |
72 | |
10 | 73 color: |
20 | 74 - { id: color_title, hex: 88888a } |
75 - { id: color_wifi_h, hex: 5998de } | |
76 - { id: color_wifi_b, hex: aec9e2 } | |
77 - { id: color_pm_h, hex: 5998de } | |
78 - { id: color_pm_b, hex: aec9e2 } | |
79 - { id: color_temp_h, hex: 5998de } | |
80 - { id: color_temp_b, hex: aec9e2 } | |
10 | 81 |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
82 output: |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
83 - platform: ledc |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
84 pin: GPIO04 |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
85 id: gpio_04_backlight_pwm |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
86 |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
87 light: |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
88 - platform: monochromatic |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
89 output: gpio_04_backlight_pwm |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
90 name: "Display Backlight" |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
91 id: back_light |
10 | 92 restore_mode: ALWAYS_ON |
93 | |
20 | 94 - platform: fastled_clockless |
95 chipset: WS2812 | |
96 pin: GPIO27 | |
97 num_leds: 8 | |
98 rgb_order: GRB | |
99 name: "strip1" | |
100 id: strip1 | |
101 effects: | |
102 - pulse: | |
103 name: "wifi_connecting_effect" | |
104 transition_length: 0.5s | |
105 update_interval: 0.5s | |
106 min_brightness: 0% | |
107 max_brightness: 40% | |
108 | |
109 - addressable_lambda: | |
110 name: "lighthouse" | |
111 update_interval: 30ms | |
112 lambda: |- | |
113 static const Color lamp(255, 200, 160); | |
114 | |
115 static const int32_t wid = 32; | |
116 static const int32_t mul = 256 / wid; | |
117 | |
118 static const int32_t ctr[] = {65, 90, 110, 120}; | |
119 static const int32_t ctr_mirror[] = { | |
120 ctr[0], ctr[1], ctr[2], ctr[3], | |
121 255 - ctr[3], 255 - ctr[2], 255 - ctr[1], 255 - ctr[0] | |
122 }; | |
123 | |
124 const uint32_t now = millis(); | |
125 | |
126 int16_t phase256 = ((int32_t)now / 10) % 256; | |
127 | |
128 for (int i = 0; i < 8; i++) { | |
129 int16_t dist256 = abs(phase256 - ctr_mirror[i]); | |
130 if (dist256 < wid) { | |
131 it[i] = lamp * (mul * (wid - dist256)); | |
132 } else { | |
133 it[i] = Color::BLACK; | |
134 } | |
135 } | |
136 | |
137 script: | |
138 - id: on_wifi_disconnect | |
139 then: | |
140 - light.turn_on: | |
141 id: strip1 | |
142 effect: "wifi_connecting_effect" | |
143 color_brightness: 100% | |
144 red: 100% | |
145 green: 0% | |
146 blue: 0% | |
147 - id: on_wifi_connect | |
148 then: | |
149 - light.turn_off: | |
150 id: strip1 | |
151 # # debugging | |
152 # - light.turn_on: | |
153 # id: strip1 | |
154 # effect: "lighthouse" | |
155 | |
10 | 156 display: |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
157 # see note at https://esphome.io/components/display/ili9xxx#:~:text=For-,Lilygo%20TTGO%20Boards,-if%20you%20move |
20 | 158 - platform: ili9xxx |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
159 model: st7789v |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
160 dimensions: |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
161 height: 240 |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
162 width: 135 |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
163 offset_height: 40 |
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
164 offset_width: 52 |
20 | 165 rotation: 0° |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
166 invert_colors: true |
10 | 167 cs_pin: GPIO5 |
168 dc_pin: GPIO16 | |
169 reset_pin: GPIO23 | |
20 | 170 update_interval: 2s |
14
dcd981e1386b
br-air-quality has new screen layout; wifi connection blinks; etc
drewp@bigasterisk.com
parents:
10
diff
changeset
|
171 pixel_mode: 16bit |
10 | 172 lambda: |- |
20 | 173 unsigned int row = 0; |
174 unsigned int rh = 32; | |
175 unsigned int x0 = 0; | |
176 unsigned int x1 = 15; | |
177 | |
178 it.print(135 / 2, (row++)*rh, id(font_14), id(color_title), TextAlign::TOP_CENTER, "${location_caps}"); | |
179 it.line(0, rh, 135, rh, id(color_title)); | |
10 | 180 |
20 | 181 it.print(x0, (row++)*rh, id(font_14), id(color_wifi_h), "WIFI"); |
182 if (std::isnan(id(my_wifi_signal).state)) { | |
183 it.print(x1, (row++)*rh, id(font_14), id(color_wifi_b), "..."); | |
184 } else { | |
185 it.printf(x1, (row++)*rh, id(font_14), id(color_wifi_b), "%.0f%%", min(max(2 * (id(my_wifi_signal).state + 100.0), 0.0), 100.0)); | |
186 } | |
187 it.print(x0, (row++)*rh, id(font_14), id(color_pm_h), "PM2.5"); | |
188 it.printf(x1, (row++)*rh, id(font_14), id(color_pm_b), "%.1f", id(pm_2_5).state); | |
189 it.print(x0, (row++)*rh, id(font_14), id(color_temp_h), "TEMP °F"); | |
190 it.printf(x1, (row++)*rh, id(font_14), id(color_temp_b), "%.1f", 32 + (id(air_temp_c).state * 9 / 5)); |