-
Notifications
You must be signed in to change notification settings - Fork 0
/
heltec32-01.yml
151 lines (136 loc) · 3.4 KB
/
heltec32-01.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# heltec docs
# https://resource.heltec.cn/download/WiFi_Kit_32/WiFi%20Kit32.pdf
# heltec source code
# https://github.com/HelTecAutomation/Heltec_ESP32
substitutions:
node_name: heltec32-01
device_verbose_name: "Heltec w/display"
ip_suffix: "119"
ap_password: "y0ltlm7Rryim"
board_type: heltec_wifi_kit_32
packages:
wifi: !include common/wifi.yml
device_base: !include common/device_base.yml
gradient_data: !include common/effect_data.yml
# https://esphome.io/index.html#
esphome:
includes:
- custom/glow
- esp32-custom/src/display
# unique to this device
api:
password: "19995aac489e7eab0577feae9a5f4a8d"
# https://esphome.io/components/light/index.html
light:
- platform: fastled_clockless
name: "LED Strip 01"
id: strip1
chipset: WS2811
rgb_order: BRG
num_leds: 20
pin: GPIO12
effects: !include custom/strip_effects.yml
on_turn_on:
then:
- lambda: |-
id(strip_on) = true;
on_turn_off:
then:
- lambda: |-
id(strip_on) = false;
# https://esphome.io/components/i2c.html
i2c:
# Built-in display
- id: bus_a
sda: 4
scl: 15
scan: false
# https://esphome.io/components/switch/index.html
switch:
- platform: template
id: led_switch
name: "LED ON/OFF Switch"
optimistic: true
on_turn_on:
then:
- light.turn_on: strip1
on_turn_off:
then:
- light.turn_off: strip1
# https://esphome.io/components/binary_sensor/index.html
binary_sensor:
- platform: gpio
name: "LED ON/OFF"
pin:
number: GPIO26
mode:
input: true
on_press:
then:
- switch.toggle: led_switch
# https://esphome.io/guides/automations.html?highlight=template#global-variables
globals:
- id: strip_on
type: bool
restore_value: yes
initial_value: 'false'
# https://esphome.io/components/display/index.html?highlight=font#fonts
font:
# gfonts://family[@weight]
- file: "gfonts://Lato"
id: lato
size: 14
# https://esphome.io/components/display/index.html
display:
- platform: ssd1306_i2c
i2c_id: bus_a
model: "SSD1306 128x64"
id: blue_display
reset_pin: 16
address: 0x3C
lambda: |-
const char* on_off = (id(strip_on)) ? "ON" : "OFF";
it.printf(0, 0, id(lato), "WIFI signal: %.2f", id(wifi_signal_1).state);
it.printf(0, 16, id(lato), "%s", on_off);
it.printf(0, 32, id(lato), "Brightness: %.2f", id(rotary1).state);
# https://esphome.io/components/sensor/index.html
sensor:
- platform: rotary_encoder
name: "LED Brightness"
id: 'rotary1'
pin_a:
number: GPIO14
inverted: true
mode:
input: true
pin_b:
number: GPIO27
inverted: true
mode:
input: true
pullup: true
min_value: 0
max_value: 100
unit_of_measurement: "%"
publish_initial_value: true
on_value:
then:
- light.turn_on:
id: strip1
brightness: !lambda |-
// output value must be in range 0 - 1.0
return id(rotary1).state / 100.0;
- platform: wifi_signal
id: wifi_signal_1
name: "WiFi Signal"
update_interval: 60s
# https://esphome.io/components/sensor/ultrasonic.html?highlight=hc+sr04
- platform: ultrasonic
trigger_pin: GPIO18
echo_pin: GPIO23
id: ultra_1
name: "Ultrasonic Sensor"
# defaults
update_interval: 60s
timeout: 2m
pulse_time: 10us