I have successfully connected SH1106 OLED with esp32.
Now I have two issues,
-
use material designs icons for displaying different icons. e.g using these icons Material Symbols and Icons - Google Fonts
Material Symbols and Icons - Google Fonts
f076
e.g like this
DIY ESP32 E-Ink Thermometer Project with a DS18B20 Sensor and the Arduino IDE - Low Power - YouTube -
Display uptime in multiple rows because it overflows off the display.
Used the following code
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
address: 0x3C
id: oled_display
pages:
- id: page1
lambda: |-
// Print WiFi Signal
it.printf(0, 26, id(arial_14), "Wi-Fi: %.1f", id(wifi_sgnl).state);
// Print time in HH:MM format
it.strftime(0, 0, id(roboto), TextAlign::TOP_LEFT, "%H:%M", id(esptime).now());
// Print Room humidity"(from xiaomi sensor)
if (id(room_humidity).has_state()) {
it.printf(127,62, id(roboto), TextAlign::BOTTOM_RIGHT, "%.1f%%", id(room_humidity).state);
}
// Print Room temperature(from xiaomi sensor)
if (id(room_temperature).has_state()) {
it.printf(127, 0, id(Carrois_Gothic), TextAlign::TOP_RIGHT, "%.1f°C", id(room_temperature).state);
}
// Print 29Gal temperature(from dallas sensor)
if (id(dallas_temp).has_state()) {
it.printf(0, 62, id(Carrois_Gothic), TextAlign::BOTTOM_LEFT, "%.1f°C", id(dallas_temp).state);
}
- id: page2
lambda: |-
// Print 29Gal temperature(from dallas sensor)
if (id(dallas_temp).has_state()) {
it.printf(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%.1f°C", id(dallas_temp).state);
}
- id: page3
lambda: |-
// Print time in HH:MM format
it.strftime(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%H:%M", id(esptime).now());
- id: page4
lambda: |-
// Print time from Human Readable uptime
it.printf(60, 10, id(Merriweather), TextAlign::CENTER_HORIZONTAL, "%s", id(uptime_human).state.c_str());
# For example cycle through pages on a timer
interval:
- interval: 3s
then:
- display.page.show_next: oled_display
- component.update: oled_display
For uptime sensor used the following code
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
address: 0x3C
id: oled_display
pages:
- id: page1
lambda: |-
// Print WiFi Signal
it.printf(0, 26, id(arial_14), "Wi-Fi: %.1f", id(wifi_sgnl).state);
// Print time in HH:MM format
it.strftime(0, 0, id(roboto), TextAlign::TOP_LEFT, "%H:%M", id(esptime).now());
// Print Room humidity"(from xiaomi sensor)
if (id(room_humidity).has_state()) {
it.printf(127,62, id(roboto), TextAlign::BOTTOM_RIGHT, "%.1f%%", id(room_humidity).state);
}
// Print Room temperature(from xiaomi sensor)
if (id(room_temperature).has_state()) {
it.printf(127, 0, id(Carrois_Gothic), TextAlign::TOP_RIGHT, "%.1f°C", id(room_temperature).state);
}
// Print 29Gal temperature(from dallas sensor)
if (id(dallas_temp).has_state()) {
it.printf(0, 62, id(Carrois_Gothic), TextAlign::BOTTOM_LEFT, "%.1f°C", id(dallas_temp).state);
}
- id: page2
lambda: |-
// Print 29Gal temperature(from dallas sensor)
if (id(dallas_temp).has_state()) {
it.printf(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%.1f°C", id(dallas_temp).state);
}
- id: page3
lambda: |-
// Print time in HH:MM format
it.strftime(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%H:%M", id(esptime).now());
- id: page4
lambda: |-
// Print time from Human Readable uptime
it.printf(60, 10, id(Merriweather), TextAlign::CENTER_HORIZONTAL, "%s", id(uptime_human).state.c_str());
# For example cycle through pages on a timer
interval:
- interval: 3s
then:
- display.page.show_next: oled_display
- component.update: oled_display
to make Human readable
- platform: uptime
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();