Hello
has anybody made this screen work using ESPHOME code?
can you please share your code? I’ve been trying for hours and coundt find the way to do it, I get always 100% lit scren
thanks!
Hello
has anybody made this screen work using ESPHOME code?
can you please share your code? I’ve been trying for hours and coundt find the way to do it, I get always 100% lit scren
thanks!
At least post what you have done on yaml.
Does your I2C find the display address?
Sorry, you are completly right
My current code work, but just by trial and error about the offsets, rotation and possition:
# LCD bus I2C
i2c:
sda: GPIO5
scl: GPIO6
scan: true
id: bus_a
display:
- platform: ssd1306_i2c
model: "SH1107 128x128"
rotation: 180
update_interval: 60s
offset_y: 0
offset_x: 0
address: 0x3C
lambda: |-
it.print(25, 11, id(my_font), "ESP32-C3 OLED");
font:
- file: "fonts/roboto.ttf"
id: my_font
size: 12
that code works, shows and I can update the info in screen but if I use the more correct (according to the screen resolution) code:
display:
- platform: ssd1306_i2c
model: "SSD1306 72x40"
rotation: 0
update_interval: 1s # Se refresca cada 60 segundos (toma aprox. 1s)
offset_y: 0
offset_x: 0
address: 0x3C
lambda: |-
// Imprime "Hello World" en la posición (0,0)
it.print(0, 0, id(my_font), "ESP32_72x40");
no matter what I write on the message, the screen shows the info I uploaded with the previous code (keeps showing ESP32-C3 OLED)
Then your upload didn’t complete.
You probably got some errors when complied?
What about:
# Imprime "Hello World" en la posición (0,0)
Finally I found a solution that works for me,
in case it helps someone else:
# LCD bus I2C
i2c:
sda: GPIO5
scl: GPIO6
scan: true
id: bus_a
frequency: 800kHz
display:
- platform: ssd1306_i2c
model: "sh1106 128x64"
rotation: 0
update_interval: 60s
offset_y: 0
offset_x: 0
invert: True # Optional
address: 0x3C
lambda: |-
it.print(27, 9, id(my_font), "27x9");
font:
- file: "fonts/roboto.ttf" ## Choose your font from the esphome fonts folder
id: my_font
size: 12
Thanks a lot @poseido. I finally got mine working, after finding your post.
# LCD bus I2C
i2c:
sda: GPIO5
scl: GPIO6
scan: true
id: bus_a
frequency: 800kHz
# Display settings
display:
- platform: ssd1306_i2c
model: "sh1106 128x64"
id: my_display
rotation: 0
update_interval: 60s
offset_y: 0
offset_x: 0
invert: false
address: 0x3C
lambda: |-
it.printf(30, 18, id(my_font), "%s", id(oledtext).state.c_str());
# Font
font:
- file: "gfonts://Roboto"
id: my_font
size: 16
text_sensor:
- platform: homeassistant
name: "oledtext"
entity_id: input_text.oled_display
id: oledtext
on_value:
then:
- component.update: my_display
Actually, the proper config should be like below. Just posting it in a case that someone else like me would stumble upon this post.
Don’t forget to set up your font.
# I2C minimum settings
i2c:
sda: GPIO5
scl: GPIO6
scan: true
id: bus_i2c
# OLED SSD1306 72x40 Display settings
display:
- platform: ssd1306_i2c
model: "SSD1306 72x40"
id: my_display
rotation: 0
update_interval: 1s
offset_y: 0
offset_x: 0
invert: true
address: 0x3C
lambda: |-
it.printf(0, 0, id(my_font_12), "TEXT", id(uptime_human).state.c_str());
This way you have no issues with offsets or x/y starting points.