Last active 1719118046

using ESPHome

Revision 295e1386aa6f0dd9fa208f2e7c2ea1ae6593d84c

esp32-clock.yaml Raw
1esp32:
2 board: esp32-c3-devkitm-1
3 variant: ESP32C3
4
5i2c:
6 sda: GPIO6
7 scl: GPIO7
8 frequency: 800kHz
9
10binary_sensor:
11 - platform: gpio
12 pin: GPIO9
13 id: boot
14 filters:
15 - delayed_on: 10ms
16 on_release:
17 then:
18 - switch.toggle: clock_active
19 internal: True
20
21time:
22 - platform: sntp
23 id: sntp_time
24 on_time:
25 - cron: '/2 * * * * *'
26 then:
27 - if:
28 condition:
29 - switch.is_on: clock_active
30 then:
31 - delay: 500ms
32 - switch.turn_on: relay
33
34switch:
35 - platform: template
36 id: clock_active
37 name: "Clock active"
38 optimistic: True
39 restore_mode: ALWAYS_OFF
40
41 - platform: gpio
42 name: "Relay"
43 id: relay
44 pin: GPIO0
45 inverted: True
46 on_turn_on:
47 - delay: 1s
48 - switch.turn_off: relay
49
50font:
51 - file: "gfonts://Roboto"
52 id: roboto25
53 size: 25
54 - file: "gfonts://Roboto"
55 id: roboto14
56 size: 14
57
58display:
59 - platform: ssd1306_i2c
60 model: "SSD1306 128x32"
61 flip_y: False
62 flip_x: False
63 lambda: |-
64 it.strftime(0, -5, id(roboto25), "%H:%M", id(sntp_time).now());
65 it.strftime(64, -2, id(roboto14), "%S", id(sntp_time).now());
66 it.strftime(it.get_width(), -2, id(roboto14), TextAlign::TOP_RIGHT, "%a", id(sntp_time).now());
67 it.strftime(it.get_width(), 15, id(roboto14), TextAlign::TOP_RIGHT, "%b %d", id(sntp_time).now());
68 it.draw_pixel_at(id(sntp_time).now().second+1, 30, COLOR_ON);
69 it.line(0,27,61,27);
70 it.draw_pixel_at(0,28,COLOR_ON);
71 it.draw_pixel_at(61,28,COLOR_ON);
72# it.printf(it.get_width(), 0, id(roboto14), TextAlign::TOP_RIGHT, "%.2f°C", id(temp).state);
73# it.printf(0, 0, id(roboto14), "%.5f", id(temp).state);
74