How to get temp and hum on an oled Home Assistant?

Hey. I got this display: Grove - OLED Display 0.96 inch | Seeed Studio Wiki

And I got it working on arduino, but i want it to work on home assistant,

This is the code in arduino:

// Initialize OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F(“SSD1306 allocation failed”));
for (;:wink:

  // Printing the results on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("    Humidity = ");
  Serial.print(h);
  Serial.println(" % ");

  // Display temperature and humidity on OLED
  display.clearDisplay();
  display.setTextSize(2); // Increase text size to 2
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.print("Temp:");
  display.println(t);
  display.print("Humidity: ");
  display.println(h);
  display.display();

// Initialize OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F(“SSD1306 allocation failed”));
for (;:wink:

`Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
WebServer server(80);
DHT dht(DHTPIN, DHTTYPE);
`

ESPHome might support it via

If you’re not aware / talking about esphome, then clarify what you’re asking for

1 Like

only get errors, also mine oled is: The OLED128*64 uses all the pins of SSD1308 chip,…
Failed config

display.ssd1306_i2c: [source /config/esphome/hemmis.yaml:48]
platform: ssd1306_i2c
model: SSD1306_128X64
address: 0x3C

What errors?
What is your esphome yaml?

Please have a little empathy for the people trying to help you :wink:

1 Like

the error is the one i posted: # Example configuration entry
i2c:
sda: D1
scl: D2

display:

  • platform: ssd1306_i2c
    model: “SSD1306 128x64”
    reset_pin: D0
    address: 0x3C
    lambda: |-
    it.print(0, 0, id(font), “Hello World!”);

I have at the end of the yaml

Please format your code. Indentation is important in YAML

Code_format

You don’t show the actual error

1 Like
Failed config

display.ssd1306_i2c: [source /config/esphome/hemmis.yaml:48]
  platform: ssd1306_i2c
  model: SSD1306 128x64
  
  This variable only supports pin numbers, not full pin schemas (with inverted and mode).
  reset_pin: 
  address: 60
  lambda: it.print(0, 0, id(font), "Hello World!");

my yaml: `esphome:
name: hemmis
friendly_name: hemmis

esp32:
board: esp32-c3-devkitm-1
variant: esp32c3
framework:
type: esp-idf

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: “6Q6KlUXNo/sFmWFl95FQ9w+xrD0wGvPkI9nhIRYOKbo=”

ota:
password: “3e0cf106f66397e5c25b617030953960”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Hemmis Fallback Hotspot”
password: “BDjQBIjT7kdG”

captive_portal:
web_server:
sensor:

  • platform: dht
    model: AUTO_DETECT
    pin: 2
    temperature:
    name: “Temperature”
    humidity:
    name: “Humidity”
    update_interval: 15s

    Example configuration entry

i2c:
sda: GPIO6
scl: GPIO7

display:

  • platform: ssd1306_i2c
    model: “SSD1306 128x64”
    reset_pin:
    address: 0x3C
    lambda: |-
    it.print(0, 0, id(font), “Hello World!”);`

Format the YAML, please.
The error message typically hints of an indentation issue.

You actually need to specify a pin, here

I Diddn’t have any reset pin when it worked on arduino, what is the reset pin? I Have an Xiao esp32c3

Read the doc

Optional means you don’t have to indicate one, but if you don’t, omit the key altogether, not put the key without a value.

so what should i have there?

Remove reset_pin: altogether

Now i got: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pioenvs/hemmis/src/main.o: in function esphome::api::APIServer* esphome::Application::register_componentesphome::api::APIServer(esphome::api::APIServer*)‘:
/data/build/hemmis/src/esphome/core/application.h:149: undefined reference to vtable for esphome::i2c::IDFI2CBus' /data/cache/platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /data/build/hemmis/src/esphome/core/application.h:149: undefined reference to vtable for esphome::i2c::IDFI2CBus’
/data/cache/platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/…/…/…/…/riscv32-esp-elf/bin/ld: .pioenvs/hemmis/src/main.o: in function setup()': /data/build/hemmis/src/main.cpp:146: undefined reference to vtable for esphome::i2c::IDFI2CBus’
/data/cache/platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/…/…/…/…/riscv32-esp-elf/bin/ld: /data/build/hemmis/src/main.cpp:146: undefined reference to vtable for esphome::i2c::IDFI2CBus' /data/cache/platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /data/build/hemmis/src/main.cpp:253: undefined reference to vtable for esphome::ssd1306_i2c::I2CSSD1306’
/data/cache/platformio/packages/toolchain-riscv32-esp/bin/…/lib/gcc/riscv32-esp-elf/8.4.0/…/…/…/…/riscv32-esp-elf/bin/ld: /data/build/hemmis/src/main.cpp:253: undefined reference to vtable for esphome::ssd1306_i2c::I2CSSD1306' collect2: error: ld returned 1 exit status *** [.pioenvs/hemmis/firmware.elf] Error 1 ========================= [FAILED] Took 403.85 seconds =========================

tried to format the yaml but couldnt…

Try to do a clean build

it-s something with the version, wich i can understand since i have a ssd1308 instead of 1306…
ssd1306_i2c::I2CSSD1306’ error

You’re just compiling, here. ESPhome still hasn’t a clue about the actual hardware, so, no.

so strange it so easy on arduino, but on home assistant it wont work …

now i get `display.ssd1306_i2c: [source /config/esphome/hemmis.yaml:48]
platform: ssd1306_i2c
model: SH1106_128X64
address: 0x3C

Couldn’t find ID ‘font’. Please check you have defined an ID with that name in your configuration.
lambda: !lambda |-
it.print(0, 0, id(font), “Hello World!”);
auto_clear_enabled: True
brightness: 1.0
contrast: 1.0
flip_x: True
flip_y: True
offset_x: 0
offset_y: 0
invert: False
update_interval: 1s`