esphome: name: a16v3-ds3231-oled min_version: 2026.11.0 on_boot: priority: -100 then: - ds3231.read_time: id: rtc_time esp32: board: esp32-s3-devkitc-1 framework: type: esp-idf logger: i2c: sda: GPIO9 scl: GPIO10 frequency: 100kHz # Connect Ethernet to sync the clock via SNTP. ethernet: type: W5500 clk_pin: GPIO42 mosi_pin: GPIO43 miso_pin: GPIO44 cs_pin: GPIO15 interrupt_pin: GPIO2 reset_pin: GPIO1 ds3231: address: 0x68 time: - platform: ds3231 id: rtc_time timezone: Asia/Shanghai - platform: sntp timezone: Asia/Shanghai servers: - ntp.aliyun.com - pool.ntp.org on_time_sync: then: - ds3231.write_time: id: rtc_time pcf8574: - id: outputs_1_8 address: 0x24 switch: - platform: gpio id: out1 internal: true restore_mode: ALWAYS_OFF pin: pcf8574: outputs_1_8 number: 0 mode: OUTPUT inverted: true font: - file: "gfonts://Roboto Mono" id: oled_font size: 16 display: - platform: ssd1306_i2c model: "SSD1306 128x64" address: 0x3C update_interval: 1s lambda: |- // Use the same timestamp for OUT1 and the display. const auto now = id(rtc_time).now(); const bool active = now.is_valid() && (now.second % 10 < 5); if (id(out1).state != active) { if (active) id(out1).turn_on(); else id(out1).turn_off(); } if (now.is_valid()) { it.strftime(0, 0, id(oled_font), "%Y-%m-%d", now); it.strftime(0, 21, id(oled_font), "%H:%M:%S", now); } else { it.print(0, 0, id(oled_font), "Waiting for"); it.print(0, 21, id(oled_font), "network time"); } it.printf(0, 42, id(oled_font), "OUT1: %s", active ? "ON" : "OFF");