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

id’s were misplaced

esphome:
  name: hemmis
  friendly_name: hemmis

esp32:
  board: seeed_xiao_esp32c3
  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"

sensor:
  - platform: dht
    model: AUTO_DETECT
    pin: 2
    temperature:
      name: "Temperature"
      id: dht_temp
    humidity:
      name: "Humidity"
      id: dht_humidity
    update_interval: 15s
i2c:
  sda: GPIO6
  scl: GPIO7
  scan: False

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, "%.1f°", id(dht_temp).state);
      
font:
  - file: 'Roboto-Regular.ttf'
    id: font1
    size: 12

Firmware:

https://nextcloud.semperpax.be/s/dZ2Fx2FHF6ifTai/download/hemmis-factory.bin

it\s compiling… what is that firmware file?

It’s the result of the compilation.
You can flash it directly to the ESP with https://web.esphome.io/ in chrome/edge

we are close :smiley:
Now i get only one the display: 23.9’
nothing more… Would like to also show humidity… and like this: temp: “value”
hum: “Value”

Pal, if you cannot proceed from here, it’s pretty much desperate :wink:

1 Like

when using the firmware file it wont work, and connect to wifi…
I’m doing a clean build like you thought me now… ill post back…
also i added this: it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, "Temperature: %.1f°C", id(dht_temp).state); it.printf(0, 16, id(font1), TextAlign::TOP_LEFT, "Humidity: %.1f%%", id(dht_hum).state);

It’s compiling now, ill be back

now i have some other error, cant connect it to wifi… ill check something out

INFO Resolving IP address of hemmis.local
ERROR Error resolving IP address of hemmis.local. Is it connected to WiFi?

now nothing works… cant connect to wifi?

im trying to delete the whole damn thing and try from start

Well, maybe you forgot that esphome is very well documented and even features a getting started guide?

Please don’t forget to read the docs!

Also how to ask a good question is something you probably also completely forgot (to read)

Just give it all a try! Often you are quicker in resolving your errors then posting in 5 forums and getting 20 opinions on your code!

Hello :slight_smile: i had an exam the last 4 days, sry… i will try to flash this code now:

it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, "Temperature: %.1f°C", id(dht_temp).state);
it.printf(0, 16, id(font1), TextAlign::TOP_LEFT, "Humidity: %.1f%%", id(dht_hum).state);


esphome:
  name: hemmis
  friendly_name: hemmis

esp32:
  board: seeed_xiao_esp32c3
  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"
web_server:
captive_portal:
sensor:
  - platform: dht
    model: AUTO_DETECT
    pin: 2
    temperature:
      name: "Temperature"
      id: dht_temp
    humidity:
      name: "Humidity"
      id: dht_hum
    update_interval: 15s
i2c:
  sda: GPIO6
  scl: GPIO7
  scan: False

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, "Temperature: %.1f°C", id(dht_temp).state);
      it.printf(0, 16, id(font1), TextAlign::TOP_LEFT, "Humidity: %.1f%%", id(dht_hum).state);
      
font:
  - file: 'Roboto-Regular.ttf'
    id: font1
    size: 12

Now i got it to succed compiling, but i get nothing on the screen!

here is my log:

Archiving .pioenvs/hemmis/libe15/libnoise-c.a
Linking .pioenvs/hemmis/firmware.elf
RAM: [= ] 8.1% (used 26388 bytes from 327680 bytes)
Flash: [===== ] 46.8% (used 858236 bytes from 1835008 bytes)
Building .pioenvs/hemmis/firmware.bin
Creating esp32c3 image…
Successfully created esp32c3 image.
esp32_create_combined_bin([“.pioenvs/hemmis/firmware.bin”], [“.pioenvs/hemmis/firmware.elf”])
Wrote 0xe2c20 bytes to file /data/build/hemmis/.pioenvs/hemmis/firmware-factory.bin, ready to flash to offset 0x0
======================== [SUCCESS] Took 3834.70 seconds ========================

is that really your yaml? or a wrong copy-and-paste? what are those first two lines for?

Please try formating your logs/yaml correctly - you succeeded already in the past!

You can read about it here: How to help us help you - or How to ask a good question

forget the 2 lines, it was a post mistake

Im trying another (same model) esp32c3 xiao, i think the other one might be broken… ill post when i have compiled it…

Please try to format your code correctly like requested already multiple times from more then one user!

it takes my like i said over 1 hour to compile, so if i want to change only one letter i have to wait an hour to se if it works, also often get terminated ram problem… so i have installed haos on a powerfull pc and is setting it up now and will come back to you…

I installed haos on an pc with 16gb ram (8x moore than pi) and it went from 4300 seconds compiling to 53secondsxD and also now it works :smiley: Thank you guys so much for the help, now i’m going to set up hacs, and ewelink so i can use an automatic switch :slight_smile: also at one point my esp32 was connecting and disconnecting, and i thought it was burned up, but it’s just because it got some corupt drivers onboard, so if you press and hold down the en button on it while connecting you fix that :slight_smile:

Here is the final code: `esphome:
name: hemmis
friendly_name: hemmis

esp32:
board: seeed_xiao_esp32c3
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”
web_server:
captive_portal:
sensor:

  • platform: dht
    model: AUTO_DETECT
    pin: 2
    temperature:
    name: “Temperature”
    id: dht_temp
    humidity:
    name: “Humidity”
    id: dht_hum
    update_interval: 15s
    i2c:
    sda: GPIO6
    scl: GPIO7
    scan: False

display:

  • platform: ssd1306_i2c
    model: “SSD1306 128x64”
    address: 0x3C
    lambda: |-
    it.printf(0, 0, id(font1), TextAlign::TOP_LEFT, “Temperature: %.1f°C”, id(dht_temp).state);
    it.printf(0, 16, id(font1), TextAlign::TOP_LEFT, “Humidity: %.1f%%”, id(dht_hum).state);

font:

  • file: ‘Roboto-Regular.ttf’
    id: font1
    size: 12`