赞
踩
主控:ESP12-F
屏幕:0.96寸OLED,I2C接口
ESPHOME版本:v2023.6.4
font: - file: # 创建一个字库 type: gfonts family: Roboto weight: 900 id: my_gfont size: 16 i2c: # 配置I2C接口信息 sda: GPIO2 scl: GPIO14 frequency: 400k display: # 配置屏幕 - platform: ssd1306_i2c model: "SSD1306 128x64" address: 0x3C lambda: |- it.print(0, 0, id(font), "Hello World!");
为了加快显示更新过程,可以选择更高的I²C频率。
时间组件相关说明请参考ESPHOME Time组件
time:
- platform: sntp
id: sntp_time
timezone: Asia/Shanghai
on_time:
- seconds: "*"
then:
lambda: |-
auto time = id(sntp_time).now();
ESP_LOGW("time", "%d-%d-%d %d:%d:%d", time.year, time.month, time.day_of_month, time.hour, time.minute, time.second);
esphome: name: olcd-demo friendly_name: OLCD_demo esp8266: board: esp12e # Enable logging logger: # Enable Home Assistant API api: encryption: key: "********************************" ota: password: "*****************************" wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Olcd-Demo Fallback Hotspot" password: "**********************" captive_portal: font: - file: type: gfonts family: Roboto weight: 900 id: my_gfont size: 16 i2c: # 配置I2C接口信息 sda: GPIO2 scl: GPIO14 frequency: 400k display: - platform: ssd1306_i2c id: my_oled model: "SSD1306 128x64" address: 0x3C lambda: |- if (id(sntp_time).now().is_valid()) { auto time = id(sntp_time).now(); it.printf(0, 16, id(my_gfont), "%04d:%02d:%02d", time.year, time.month, time.day_of_month); it.printf(0, 32, id(my_gfont), "%02d:%02d:%02d", time.hour, time.minute, time.second); } else { it.print(0, 0, id(my_gfont), "NTP..."); } time: - platform: sntp id: sntp_time timezone: Asia/Shanghai on_time: - seconds: "*" then: lambda: |- auto time = id(sntp_time).now(); ESP_LOGW("time", "%d-%d-%d %d:%d:%d", time.year, time.month, time.day_of_month, time.hour, time.minute, time.second);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。