Metainformationen zur Seite
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
digitales:hardware:displays:esp32_ttgo_t-display [24.04.2025] – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | digitales:hardware:displays:esp32_ttgo_t-display [25.05.2025] (aktuell) – [Spezifikation] cs | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | {{tag> | ||
+ | |||
+ | ====== ESP32 TTGO T-Display ====== | ||
+ | |||
+ | ===== Spezifikation ===== | ||
+ | |||
+ | {{..: | ||
+ | |||
+ | Material: PCB Größe: Ca.51,52 x 25,04 x 8,54 mm/2,03 x 0,99 x 0,34 Zoll Gewicht: Ca.7,81 g\\ Hardware-Spezifikationen: | ||
+ | |||
+ | {{..: | ||
+ | |||
+ | |||
+ | ===== Nützliche Links ===== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | {{youtube> | ||
+ | |||
+ | |||
+ | ===== Code ===== | ||
+ | |||
+ | <file yaml ttgo-display.yaml> | ||
+ | # ESPHome code for the LilyGO TTGO Display | ||
+ | # Copyright 2023 by Smart Home Junkie | ||
+ | # | ||
+ | # Visit my website at https:// | ||
+ | # Watch the tutorial for this display and code at https:// | ||
+ | substitutions: | ||
+ | devicename: ttgo-display | ||
+ | upper_devicename: | ||
+ | |||
+ | esphome: | ||
+ | name: $devicename | ||
+ | friendly_name: | ||
+ | |||
+ | esp32: | ||
+ | board: esp32dev | ||
+ | framework: | ||
+ | type: arduino | ||
+ | |||
+ | # Enable logging | ||
+ | logger: | ||
+ | level: DEBUG | ||
+ | |||
+ | packages: | ||
+ | wifi: !include packages/ | ||
+ | mqtt: !include packages/ | ||
+ | ota: !include packages/ | ||
+ | time: !include packages/ | ||
+ | font: !include packages/ | ||
+ | |||
+ | # Enable Home Assistant API | ||
+ | api: | ||
+ | |||
+ | captive_portal: | ||
+ | |||
+ | spi: | ||
+ | clk_pin: GPIO18 | ||
+ | mosi_pin: GPIO19 | ||
+ | |||
+ | # Define the cycle variable. This indicates if the pages should be cycled or not | ||
+ | globals: | ||
+ | - id: cycle | ||
+ | type: boolean | ||
+ | initial_value: | ||
+ | |||
+ | # Define binary sensors | ||
+ | binary_sensor: | ||
+ | - platform: gpio # Short Press button 0 | ||
+ | pin: | ||
+ | number: GPIO0 | ||
+ | inverted: true | ||
+ | mode: | ||
+ | input: true | ||
+ | pullup: true | ||
+ | name: "Short Press Button 0" | ||
+ | id: short_press_button_0 | ||
+ | on_click: | ||
+ | min_length: 1ms | ||
+ | max_length: 1000ms | ||
+ | then: | ||
+ | - display.page.show_previous: | ||
+ | - component.update: | ||
+ | |||
+ | - platform: gpio # Long Press button 0 | ||
+ | pin: | ||
+ | number: GPIO0 | ||
+ | inverted: true | ||
+ | name: "Long Press Button 0" | ||
+ | id: long_press_button_0 | ||
+ | on_click: | ||
+ | min_length: 1001ms | ||
+ | max_length: 5000ms | ||
+ | then: | ||
+ | - switch.toggle: | ||
+ | |||
+ | - platform: gpio # Short Press button 1 | ||
+ | pin: | ||
+ | number: GPIO35 | ||
+ | inverted: true | ||
+ | name: "Short Press Button 1" | ||
+ | id: short_press_button_1 | ||
+ | on_click: | ||
+ | min_length: 1ms | ||
+ | max_length: 1000ms | ||
+ | then: | ||
+ | - display.page.show_next: | ||
+ | - component.update: | ||
+ | |||
+ | - platform: gpio # Long Press button 1 | ||
+ | pin: | ||
+ | number: GPIO35 | ||
+ | inverted: true | ||
+ | name: "Long Press Button 1" | ||
+ | id: long_press_button_1 | ||
+ | on_click: | ||
+ | min_length: 1001ms | ||
+ | max_length: 5000ms | ||
+ | then: | ||
+ | - if: | ||
+ | condition: | ||
+ | lambda: |- | ||
+ | return id(cycle); | ||
+ | then: | ||
+ | globals.set: | ||
+ | id: cycle | ||
+ | value: " | ||
+ | else: | ||
+ | globals.set: | ||
+ | id: cycle | ||
+ | value: " | ||
+ | |||
+ | # Allow dimmable control of the backlight (pin GPIO4) - Currently not working | ||
+ | output: | ||
+ | - platform: ledc | ||
+ | pin: GPIO4 | ||
+ | id: gpio4 | ||
+ | |||
+ | light: | ||
+ | - platform: monochromatic | ||
+ | output: gpio4 | ||
+ | name: " | ||
+ | |||
+ | switch: | ||
+ | - platform: gpio | ||
+ | pin: GPIO4 | ||
+ | id: backlight | ||
+ | internal: true | ||
+ | |||
+ | # Define all the numeric sensors used | ||
+ | sensor: | ||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.youtube_subscriber | ||
+ | id: subscriptions | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.youtube_views | ||
+ | id: views | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.plug_02_power | ||
+ | id: homelab | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.wohnklima_temperature_2 | ||
+ | id: wohnklima_temperature | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.wohnklima_humidity_2 | ||
+ | id: wohnklima_humidity | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.wohnklima_equivalent_sea_level_pressure_2 | ||
+ | id: wohnklima_pressure | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.dw2_02_luminosity | ||
+ | id: wohnklima_light_sensor | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.openweathermap_temperature | ||
+ | id: outside_temperature | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.openweathermap_wind_speed | ||
+ | id: wind_speed | ||
+ | |||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.xbt_eur_bid | ||
+ | id: bitcoin | ||
+ | |||
+ | # Define all the string sensors used | ||
+ | text_sensor: | ||
+ | - platform: homeassistant | ||
+ | entity_id: sensor.openweathermap_condition | ||
+ | id: weather_condition | ||
+ | filters: | ||
+ | - to_upper: | ||
+ | |||
+ | # Define colors | ||
+ | color: | ||
+ | - id: RED | ||
+ | red: 100% | ||
+ | green: 0% | ||
+ | blue: 0% | ||
+ | - id: GREEN | ||
+ | red: 0% | ||
+ | green: 100% | ||
+ | blue: 0% | ||
+ | - id: BLUE | ||
+ | red: 0% | ||
+ | green: 0% | ||
+ | blue: 100% | ||
+ | - id: YELLOW | ||
+ | red: 100% | ||
+ | green: 100% | ||
+ | blue: 0% | ||
+ | - id: WHITE | ||
+ | red: 100% | ||
+ | green: 100% | ||
+ | blue: 100% | ||
+ | - id: ORANGE | ||
+ | red: 100% | ||
+ | green: 67% | ||
+ | blue: 20% | ||
+ | |||
+ | # Define all the images used. Store the images in the images folder within the esphome folder (esphome/ | ||
+ | image: | ||
+ | - file: " | ||
+ | id: youtube_image | ||
+ | resize: 80x80 | ||
+ | type: RGB24 | ||
+ | - file: " | ||
+ | id: logo | ||
+ | resize: 120x120 | ||
+ | type: RGB24 | ||
+ | - file: " | ||
+ | id: electricity_image | ||
+ | resize: 80x80 | ||
+ | type: RGB24 | ||
+ | - file: " | ||
+ | id: bitcoin_logo | ||
+ | resize: 80x80 | ||
+ | type: RGB24 | ||
+ | - file: " | ||
+ | id: wind_icon | ||
+ | resize: 30x30 | ||
+ | type: RGB24 | ||
+ | - file: " | ||
+ | id: thermometer_icon | ||
+ | resize: 30x30 | ||
+ | type: RGB24 | ||
+ | |||
+ | # Define animations | ||
+ | animation: | ||
+ | - file: " | ||
+ | id: weather_animation | ||
+ | resize: 80x80 | ||
+ | type: RGB24 | ||
+ | |||
+ | # Define the graphs for sensors that you want to show on the display | ||
+ | graph: | ||
+ | - id: wohnklima_temperature_graph | ||
+ | sensor: wohnklima_temperature | ||
+ | duration: 4h | ||
+ | width: 220 | ||
+ | height: 90 | ||
+ | x_grid: 1h | ||
+ | y_grid: 5 | ||
+ | min_range: 5 | ||
+ | max_range: 35 | ||
+ | min_value: 5 | ||
+ | max_value: 35 | ||
+ | color: GREEN | ||
+ | - id: wohnklima_humidity_graph | ||
+ | sensor: wohnklima_humidity | ||
+ | duration: 4h | ||
+ | width: 220 | ||
+ | height: 90 | ||
+ | x_grid: 1h | ||
+ | y_grid: 25 | ||
+ | min_range: 1 | ||
+ | max_range: 100 | ||
+ | min_value: 1 | ||
+ | max_value: 100 | ||
+ | color: BLUE | ||
+ | - id: wohnklima_pressure_graph | ||
+ | sensor: wohnklima_pressure | ||
+ | duration: 4h | ||
+ | width: 220 | ||
+ | height: 90 | ||
+ | x_grid: 1h | ||
+ | y_grid: 100.0 | ||
+ | color: YELLOW | ||
+ | - id: wohnklima_light_sensor_graph | ||
+ | duration: 4h | ||
+ | width: 220 | ||
+ | height: 90 | ||
+ | x_grid: 1h | ||
+ | traces: | ||
+ | - sensor: wohnklima_light_sensor | ||
+ | color: ORANGE | ||
+ | line_type: SOLID | ||
+ | line_thickness: | ||
+ | |||
+ | # Define qr code locations | ||
+ | qr_code: | ||
+ | - id: qrcode_wiki | ||
+ | value: https:// | ||
+ | |||
+ | - id: qrcode_wlan | ||
+ | value: WIFI: | ||
+ | |||
+ | # Set up the display. This is the main part of the code | ||
+ | display: | ||
+ | - platform: st7789v | ||
+ | model: TTGO_TDISPLAY_135x240 | ||
+ | backlight_pin: | ||
+ | cs_pin: GPIO5 | ||
+ | dc_pin: GPIO16 | ||
+ | reset_pin: GPIO23 | ||
+ | rotation: 270° | ||
+ | update_interval: | ||
+ | id: my_display | ||
+ | pages: | ||
+ | - id: showintro | ||
+ | lambda: |- | ||
+ | it.image(0, 10, id(logo)); | ||
+ | it.printf(120, | ||
+ | it.printf(145, | ||
+ | it.printf(125, | ||
+ | |||
+ | - id: showtime | ||
+ | lambda: |- | ||
+ | it.strftime(45, | ||
+ | it.strftime(25, | ||
+ | |||
+ | - id: showsubscribers | ||
+ | lambda: |- | ||
+ | it.printf(0, | ||
+ | it.image(0, 40, id(youtube_image)); | ||
+ | if (id(subscriptions).has_state()) { | ||
+ | it.printf(95, | ||
+ | } else { | ||
+ | it.printf(95, | ||
+ | } | ||
+ | |||
+ | - id: showviews | ||
+ | lambda: |- | ||
+ | it.printf(0, | ||
+ | it.image(0, 40, id(youtube_image)); | ||
+ | if (id(views).has_state()) { | ||
+ | it.printf(95, | ||
+ | } else { | ||
+ | it.printf(95, | ||
+ | } | ||
+ | |||
+ | - id: showhomelab | ||
+ | lambda: |- | ||
+ | it.printf(0, | ||
+ | it.image(0, 40, id(electricity_image)); | ||
+ | if (id(homelab).has_state()) { | ||
+ | if (id(homelab).state> | ||
+ | it.printf(95, | ||
+ | } else { | ||
+ | it.printf(95, | ||
+ | } | ||
+ | } else { | ||
+ | it.printf(95, | ||
+ | } | ||
+ | |||
+ | - id: showbitcoin | ||
+ | lambda: |- | ||
+ | it.printf(0, | ||
+ | it.image(0, 40, id(bitcoin_logo)); | ||
+ | if (id(bitcoin).has_state()) { | ||
+ | it.printf(95, | ||
+ | } else { | ||
+ | it.printf(95, | ||
+ | } | ||
+ | |||
+ | - id: show_wohnklima_temperature_graph | ||
+ | lambda: |- | ||
+ | if (id(wohnklima_temperature).has_state()) { | ||
+ | it.printf(0, | ||
+ | it.graph(10, | ||
+ | } else { | ||
+ | it.printf(0, | ||
+ | it.printf(80, | ||
+ | } | ||
+ | |||
+ | - id: show_wohnklima_humidity_graph | ||
+ | lambda: |- | ||
+ | if (id(wohnklima_humidity).has_state()) { | ||
+ | it.printf(0, | ||
+ | it.graph(10, | ||
+ | } else { | ||
+ | it.printf(0, | ||
+ | it.printf(80, | ||
+ | } | ||
+ | |||
+ | - id: show_wohnklima_pressure_graph | ||
+ | lambda: |- | ||
+ | if (id(wohnklima_pressure).has_state()) { | ||
+ | it.printf(0, | ||
+ | it.graph(10, | ||
+ | } else { | ||
+ | it.printf(0, | ||
+ | it.printf(80, | ||
+ | } | ||
+ | |||
+ | - id: show_wohnklima_light_sensor_graph | ||
+ | lambda: |- | ||
+ | if (id(wohnklima_light_sensor).has_state()) { | ||
+ | it.printf(0, | ||
+ | it.graph(10, | ||
+ | } else { | ||
+ | it.printf(0, | ||
+ | it.printf(80, | ||
+ | } | ||
+ | |||
+ | - id: show_weather | ||
+ | lambda: |- | ||
+ | id(weather_animation).next_frame(); | ||
+ | it.image(0, 0, id(weather_animation), | ||
+ | if (id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | it.printf(110, | ||
+ | } | ||
+ | if (id(weather_condition).state == " | ||
+ | it.printf(110, | ||
+ | } | ||
+ | it.image(0, 100, id(thermometer_icon)); | ||
+ | it.printf(35, | ||
+ | it.image(110, | ||
+ | it.printf(145, | ||
+ | |||
+ | - id: showqrcode | ||
+ | lambda: |- | ||
+ | it.qr_code(60, | ||
+ | |||
+ | - id: showqrwlan | ||
+ | lambda: |- | ||
+ | it.qr_code(60, | ||
+ | |||
+ | # Define the cycle interval of the pages. | ||
+ | interval: | ||
+ | - interval: 5s | ||
+ | then: | ||
+ | if: | ||
+ | condition: | ||
+ | lambda: ' | ||
+ | then: | ||
+ | - display.page.show_next: | ||
+ | - component.update: | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||