Hi all,
I want to display time and pool temperature on an oled display via an ESP32.
Here is what I have:
substitutions:
name: esphome-web-8d6f74
friendly_name: temperaturdisplay_pool
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
on_boot:
priority: 800
then:
- script.execute: show_pages
esp32:
board: esp32dev
framework:
type: arduino
script:
- id: show_pages
mode: single
then:
- while:
condition:
- script.is_running: show_pages
then:
- display.page.show: page1
- component.update: my_display
- delay: 1s
- display.page.show: page2
- component.update: my_display
- delay: 1s
- display.page.show: page3
- component.update: my_display
- delay: 1s
- display.page.show: page4
- component.update: my_display
- delay: 1s
# Enable logging
logger:
logs:
component: ERROR
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
# Set up a wifi access point
ap: {}
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
# Various ways to configure fonts
font:
# gfonts://family[@weight]
- file: "gfonts://Roboto"
id: roboto_20
size: 20
- file: "gfonts://Roboto"
id: roboto_24
size: 34
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# To have a "next url" for improv serial
web_server:
# Example configuration entry
i2c:
sda: GPIO016
scl: GPIO017
display:
- platform: ssd1306_i2c
model: "SH1107 128x128"
id: my_display
pages:
- id: page1
lambda: |-
it.strftime(20, 0, id(roboto_24),"%H:%M", id(esptime).now());
it.line(0,40,128,40);
it.printf(10, 50, id(roboto_20), "Temperatur");
it.printf(10, 75, id(roboto_24), "%.1f °C", id(temp).state);
- id: page2
lambda: |-
it.strftime(25, 0, id(roboto_24),"%H:%M", id(esptime).now());
it.line(2,40,128,40);
it.printf(15, 50, id(roboto_20), "Temperatur");
it.printf(15, 75, id(roboto_24), "%.1f °C", id(temp).state);
- id: page3
lambda: |-
it.strftime(25, 5, id(roboto_24),"%H:%M", id(esptime).now());
it.line(2,45,128,45);
it.printf(15, 55, id(roboto_20), "Temperatur");
it.printf(15, 80, id(roboto_24), "%.1f °C", id(temp).state);
- id: page4
lambda: |-
it.strftime(20, 5, id(roboto_24),"%H:%M", id(esptime).now());
it.line(0,42,128,42);
it.printf(10, 55, id(roboto_20), "Temperatur");
it.printf(10, 80, id(roboto_24), "%.1f °C", id(temp).state);
- id: page5
lambda: |-
it.printf(0, 0, id(roboto_24), "");
# Example configuration entry
sensor:
- platform: homeassistant
name: "Temperatur_Pool"
id: temp
entity_id: sensor.shellyplus1pm_e465b893306c_temperature
time:
- platform: homeassistant
id: esptime
timezone: Europe/Amsterdam
binary_sensor:
- platform: gpio
pin:
number: GPIO018
name: "Bewegungssensor Pool"
id: "my_sensor"
device_class: motion
#on_state:
#then:
#- if:
#condition:
#binary_sensor.is_on: "my_sensor"
#then:
#script.execute: show_pages
#else:
#display.page.show: page5
The text moves a little bit (script with pages1-4). So far everything works fine.
Now I want a Motion sensor (HC-SR501) to start the script. If there is no motion, the display should rest black (therefore page5 with no text). The last part with the sensor doesn´t work…I tried with if condition (line 167 ff.) but this doesn´t work either. Could anybody help me?
By the way: I use these
In the specs I find a voltage of 5DC, in the web I read 3.3DC (obviously the same module…). What´s right?
Thanks a lot
Markus