Couldn't find ID 'font' error when using SSD1306 OLED Display

Hi, Can anyone spot what could be wrong here? I keep getting errors like this…

Failed config

display.ssd1306_i2c:
  platform: ssd1306_i2c
  model: SSD1306_128X64
  address: 0x3C

  Couldn't find ID 'font'. Please check you have defined an ID with that name in your configuration. These IDs look similar: "my_font".
  lambda: !lambda |-
    it.print(0, 0, id(font), "Hello World!");
  brightness: 1.0
  update_interval: 1s

Here’s my code so far…

esphome:
  name: esp_poe
  platform: ESP32
  board: esp32-poe-iso
  
ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
  power_pin: GPIO12
  manual_ip:
    static_ip: 10.0.0.246
    gateway: 10.0.0.139
    subnet: 255.0.0.0

i2c:
  sda: 13
  scl: 16
  scan: True
  id: bus_a
  
font:
  - file: "Comic Sans MS.ttf"
    id: my_font
    size: 20

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    #reset_pin: D0
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(font), "Hello World!"); 
  
sensor:
  - platform: bme280
    temperature:
      name: "BME280 Temperature"
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x76
    update_interval: 10s  
    
web_server:
  port: 80
   
  
logger:
  level: VERBOSE 
  #baud_rate: 19200

It’s doing my head in :slight_smile:

1 Like

I found the problem!

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    #reset_pin: D0
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(my_font), "Hello World!"); 

Just need the “my_” added in front of font (see the bottom line).

hey … can you explain from where you are getting the font pls?

G’day mouthpiece. I can’t remember exactly where i got it from as it’s been awhile and I have trouble remembering what I did yesterday, but I would’ve downloaded it off the internet somewhere. This site possibly could’ve been it https://www.wfonts.com/font/comic-sans-ms You can always change it to something else too.

2 Likes

thanks for getting back to me :slight_smile: I managed, just downloaded the fonts after a random google search and all worked fine.

1 Like

Having the same issue. I downloaded the font (on my laptop), but how do I get it into HA / ESPHome?

You move the font to your esphome config folder. It should say where your file should be, if you hover over the error in yaml.