Waveshare ESP32-S3-Touch-LCD-7

Morning Aaron,
That’s all working fine you just need to turn on the backlight which is off by default. Add this…

# Home Assistant API with encryption and renamed ID
api:
  id: ha_api
  encryption:
    key: !secret api_encryption_key
  on_client_connected:
    - if:
        condition:
          lambda: 'return (0 == client_info.find("Home Assistant "));'
        then:
          - switch.turn_on: lcdbacklight

################################################################################
# Switch
################################################################################
switch:
  - platform: gpio
    id: lcdbacklight
    name: lcdbacklight
    pin:
      ch422g: ch422g_hub
      number: 2
      mode:
        output: true
      inverted: false
    restore_mode: ALWAYS_ON

lol :joy: thanks. That fixed it lol. I also added a wire so I can control the backlight brightness.

I am using UART2 (GPIO 43 and 44) and have set the toggle switch to UART2. However, even after disabling the log component output or turning off the ESP Console, the sensor still does not work on the UART2 interface. Has anyone been able to get the sensor working on UART2?

I made my own HMI design for this device.

It’s currently mounted on the wall in my garage.

All the code is shared.
Lots of info in the github repo (link in the thread).

2 Likes

I wanted to reduce the copy and pasting that needs to be done to use this display, so I created an ESPHome package you can use. Hope it helps someone! GitHub - inytar/waveshare-esp32-s3-touch-lcd-7-esphome: ESPHome package to use with waveshare-esp32-s3-touch-lcd-7

Hi, could someone possibly help me? I have Waveshare 7" and 4.3" displays, and I’m trying to add an XL9535 2-channel relay using the YAML code below.

I’ve tested the code and relays on an ESP32 WROOM using SDA: 21 and SCL: 22, and everything works fine. So I connected it to both my 7" and 4.3" screens, changing to SDA: 8 and SCL: 9. For the most part, it works.

The problem I have is that I cannot control Relay 1 - Relay 2 works. I’ve tried changing the pin number from 0–7 and 10–17, but nothing works. I’ve also tried changing inverted: false to true, but there’s no change.

Any help would be greatly appreciated!

i2c:
  sda: GPIO8
  scl: GPIO9
  frequency: 100kHz
  scan: true

xl9535:
  - id: xl9535_hub
    address: 0x20

switch:
  
  - platform: gpio
    name: "Relay 1"
    id: relay_door
    pin:
      xl9535: xl9535_hub
      number: 0
      mode:
        output: true
      inverted: false

  - platform: gpio
    name: "Relay 2"
    id: relay_light
    pin:
      xl9535: xl9535_hub
      number: 1

Hello Derham, can you please tell me the RS485 pin details in ESP32-S3-Touch-LCD-7? i just need to interface the QR scanner through the RS485 so please guide me the tx and rx then if need rts pin.

Hi leev, sorry i haven’t used the RS485 connections yet. Perhaps someone else can chip in with the answer?

Leev, the following has been working for me on the ESP32-S3-Touch-LCD-7.

uart:
  id: modbus_uart
  tx_pin: GPIO16
  rx_pin: GPIO15
  baud_rate: 9600
  stop_bits: 1
  parity: NONE

I really need som help with my ESP32 S3 Waveshare 7" touch display. It stoped working for a couple of month ago. I tried to reflashed with my latest yaml config but the screen is black. I also bought a new screen and that one is also black no matter what yaml configuration I load up. Now I tried with a configuration that worked before - also black screen but I can se some kind of background light. The code that worked before but now gives me a black screen is this: GitHub - runevad/waveshare-esp32-s3-7inch: ESPHome with Waveshare esp32-s3 7inch tablet
I would be greatful for any idea of what I have missed.

´´´

Is the code compiling OK? Because if I remember correctly i needed to add this under esp32:

  cpu_frequency: 240MHz

before it wouldn’t compile, then every time it is updated it gives a black screen. I then unplug it and it restarts fine. If I restart using the restart button it doesn’t boot. A quick unplug and plug in and its fine again. I gave up trying to find out why.

Thanks for your replay. Sorry but that didn’t solve the problem. Hers’s my complete code:

################################################################################
# Substitution Variables
################################################################################
substitutions:
  device_internal_name: esp7display
  device_wifi_name: esp7display
  device_friendly_name: esp7display
  device_ip_address: 192.168.1.190
  device_sampling_time: 30s

  # glyphs
  lightbulb_on:      "\U000F0335"
  lightbulb_off:     "\U000F0336"


################################################################################
# Globals
################################################################################
globals: ##to set default reboot behavior
  - id: wifi_connection
    type: bool
    restore_value: no
    initial_value: "false"


################################################################################
# Board Configuration
################################################################################
esphome:
  name: ${device_internal_name}
  friendly_name: ${device_friendly_name}
  platformio_options:
    build_flags: "-DBOARD_HAS_PSRAM"
    board_build.arduino.memory_type: qio_opi
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 524288

psram:
  mode: quad
  speed: 80MHz

esp32:
  cpu_frequency: 240MHz
  board: esp32s3box
  variant: ESP32S3
  flash_size: 8MB
  framework:
    type: esp-idf
    platform_version: 6.9.0
    version: 5.3.0
    sdkconfig_options:
      COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_ESPTOOLPY_FLASHSIZE_8MB: "y"
      CONFIG_FREERTOS_HZ: "1000"
      CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      CONFIG_COMPILER_OPTIMIZATION_PERF: y

################################################################################
# Enable logging
################################################################################
logger:
  logs:
    component: ERROR

################################################################################
# Enable Home Assistant API
################################################################################
api:
  id: ha_api
  #encryption:
  #  key: !secret api_encryption_key
  on_client_connected:
    - if:
        condition:
          lambda: 'return (0 == client_info.find("Home Assistant "));'
        then:
          - switch.turn_on: lcdbacklight

################################################################################
# OTA
################################################################################
ota:
  platform: esphome
  ##password: !secret web_server_password

################################################################################
# WiFi
################################################################################
wifi:
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password
  output_power: 13
  reboot_timeout: 30min
  ##manual_ip:
  ##  static_ip: ${device_ip_address}
  ##  gateway: !secret gateway_address
  ##  subnet: !secret subnet_address

  ap:
    # ssid: ${device_wifi_name}
    ##password: !secret web_server_password

captive_portal:

################################################################################
# Web Server
################################################################################
web_server:
  port: 80
  version: 3
  include_internal: true
  ##auth:
  ##  username: !secret web_server_user
  ##  password: !secret web_server_password
  local: true

################################################################################
# IO Extender
################################################################################
ch422g:
  - id: ch422g_hub

################################################################################
# Switch
################################################################################
switch:
  - platform: restart
    name: "Restart"
    id: device_restart
  
  - platform: safe_mode
    name: Use Safe Mode
    id: device_safe_mode
    
  - platform: gpio
    id: lcdbacklight
    name: lcdbacklight
    pin:
      ch422g: ch422g_hub
      number: 2
      mode:
        output: true
      inverted: false
    restore_mode: ALWAYS_ON

    

################################################################################
# Sensors
################################################################################
sensor:
  # WiFi
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    id: ${device_internal_name}_wifi_signal_sensor
    update_interval: 10s

################################################################################
# Text Sensors
################################################################################
text_sensor:
  - platform: homeassistant
    id: remote_light
    entity_id: switch.smart_power_strip_socket_2
    on_value:
      then:
        - lvgl.widget.update: # matrix button
            id: btn_light
            state:
              checked: !lambda return (0 == x.compare(std::string{"on"}));
              disabled: !lambda return ((0 == x.compare(std::string{"unavailable"})) or (0 == x.compare(std::string{"unknown"})));
        - lvgl.label.update:
            id: btn_light_icon # the matrix icon
            text: !lambda |-
              static char buf[10];
              std::string icon;
              if (0 == x.compare(std::string{"on"})) {
                  icon = "$lightbulb_on";
              } else {
                  icon = "$lightbulb_off";
              }
              snprintf(buf, sizeof(buf), "%s", icon.c_str());
              return buf;


color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%
  - id: my_pink
    red: 100%
    green: 10%
    blue: 40%
  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%
  - id: my_green
    red: 0%
    green: 100%
    blue: 0%
  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%
  - id: my_gray
    red: 50%
    green: 50%
    blue: 50%
  - id: my_white
    red: 100%
    green: 100%
    blue: 100%
  - id: my_black
    red: 0%
    green: 0%
    blue: 0%

font:
  - file: "fonts/arial.ttf"
    id: arial_98
    size: 98
  - file: "fonts/arial.ttf"
    id: arial_96
    size: 96
  - file: "fonts/arial.ttf"
    id: arial_134
    size: 134
  - file: "fonts/arial.ttf"
    id: arial_128
    size: 128
  - file: "fonts/arial.ttf"
    id: arial_48
    size: 48
  - file: "fonts/arial.ttf"
    id: arial_36
    size: 36
  - file: "fonts/arial.ttf"
    id: arial_24
    size: 24
  - file: "fonts/arial.ttf"
    id: arial_18
    size: 18
  - file: "fonts/arial.ttf"
    id: arial_12
    size: 12
  - file: "gfonts://Roboto"
    id: roboto10
    size: 10
    bpp: 4
  - file: "fonts/materialdesignicons-webfont.ttf"
    id: mdi_42
    size: 42
    bpp: 4
    glyphs: [
      "$lightbulb_on", 
      "$lightbulb_off", 
      ]


############################################ START OF VLGL

lvgl:
  theme:
    arc:
      scroll_on_focus: true
      #group: general
    slider:
      scroll_on_focus: true
      #group: general
    label:
      text_font: arial_18
    button:
      scroll_on_focus: true
      #group: general
      border_width: 2
      text_font: arial_24
      outline_pad: 6
      bg_color: my_blue
      bg_grad_color: 0x005782
      bg_grad_dir: VER
      pressed:
        border_color: my_yellow
      checked:
        border_color: my_blue
        bg_color: my_yellow
      focused:
        border_color: my_white

  style_definitions:
    - id: header_footer
      bg_color: 0x2F8CD8
      bg_grad_color: 0x005782
      bg_grad_dir: VER
      bg_opa: COVER
      border_opa: TRANSP
      radius: 0
      pad_all: 0
      pad_row: 0
      pad_column: 0
      border_color: 0x0077b3
      text_color: 0xFFFFFF
      width: 100%
      height: 30
    - id: matrix
      bg_color: my_green
      bg_grad_color: 0x005782
      bg_grad_dir: VER
      bg_opa: COVER
      border_opa: TRANSP
      radius: 0
      pad_all: 0
      pad_row: 0
      pad_column: 0
      border_color: 0x0077b3
      text_color: 0xFFFFFF
      width: 100%
      height: 30

  top_layer:
      widgets:
        - line:   ######### blue border
            points:
              - 0, 0
              - 799, 0
              - 799, 479
              - 0, 479
              - 0, 0
            line_width: 4
            line_color: my_blue
            line_rounded: true

  log_level: INFO
  color_depth: 16
  buffer_size: 25%
  bg_color: my_black
  text_font: arial_24
  width: 800
  height: 480
  align: center

  pages:
    - id: main_page
      widgets:

        - obj:
            align: CENTER
            width: 450
            height: 420
            pad_all: 6
            bg_opa: TRANSP
            border_opa: TRANSP
            layout:
              type: GRID
              grid_columns: [FR(1), FR(1), FR(1)] 
              grid_rows: [FR(25), FR(25), FR(25), FR(25)]
            widgets:
              - button:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 0
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 1
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  id: btn_light
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 2
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
                  text_font: mdi_42
                  widgets:
                    - label:
                        id: btn_light_icon
                        align: CENTER
                        y: -20
                        text_font: mdi_42
                        text: "$lightbulb_off" # mdi-lightbulb-outline

                    - label:
                        #id: cov_up_east
                        align: CENTER
                        y: 20
                        text: "Light"
                        text_color: my_white
                        text_font: arial_18
                  on_short_click:
                    - homeassistant.action:
                        action: switch.toggle
                        data:
                          entity_id: switch.smart_power_strip_socket_2
                    - logger.log:
                        format: "Light button clicked: %d"
                        args: [ x ]

              - button:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 3
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 1
                  grid_cell_row_pos: 0
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 1
                  grid_cell_row_pos: 1
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 1
                  grid_cell_row_pos: 2
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 1
                  grid_cell_row_pos: 3
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 2
                  grid_cell_row_pos: 0
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 2
                  grid_cell_row_pos: 1
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 2
                  grid_cell_row_pos: 2
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
              - button:
                  grid_cell_column_pos: 2
                  grid_cell_row_pos: 3
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH


########################################################### END OF VLGL


i2c:
  sda: GPIO08
  scl: GPIO09
  scan: True
  id: bus_a

# Define display
display:
  - platform: rpi_dpi_rgb
    id: my_display
    update_interval: never
    auto_clear_enabled: false
    color_order: RGB
    pclk_frequency: 16MHZ
    dimensions:
      width: 800
      height: 480
    de_pin:
      number: 5
    hsync_pin:
      number: 46
      ignore_strapping_warning: true
    vsync_pin:
      number: 3
      ignore_strapping_warning: true
    pclk_pin: 7
    pclk_inverted: true
    reset_pin:
      ch422g: ch422g_hub
      number: 3
    hsync_back_porch: 8
    hsync_front_porch: 8
    hsync_pulse_width: 4
    vsync_back_porch: 16
    vsync_front_porch: 16
    vsync_pulse_width: 4
    data_pins:
      red:
        - 1         #r3
        - 2         #r4
        - 42        #r5
        - 41        #r6
        - 40        #r7
      blue:
        - 14        #b3
        - 38        #b4
        - 18        #b5
        - 17        #b6
        - 10        #b7
      green:
        - 39        #g2
        - 0         #g3
        - 45        #g4
        - 48        #g5
        - 47        #g6
        - 21        #g7

touchscreen:
  platform: gt911
  id: my_touch
  interrupt_pin: GPIO4
  reset_pin:
    ch422g: ch422g_hub
    number: 1
    mode: OUTPUT
  on_touch:
    - lambda: |-
        ESP_LOGI("Touch", "Touch detected at x=%d, y=%d", touch.x, touch.y);
  on_update:
    - lambda: |-
          for (auto touch: touches)  {
              if (touch.state <= 2) {
                ESP_LOGI("Touch points:", "id=%d x=%d, y=%d x.raw=%d, y.raw=%d", touch.id, touch.x, touch.y, touch.x_raw, touch.y_raw);
              }
          }

I have just checked my code which is based on the code you used and the only difference I can see is the 2 lines under type: esp-idf

mine looks like this

esp32:
  board: esp32-s3-devkitc-1
  variant: ESP32S3
  flash_size: 8MB
  cpu_frequency: 240MHz
  framework:
    type: esp-idf
    advanced:
      enable_idf_experimental_features: true
    sdkconfig_options:
      COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_ESPTOOLPY_FLASHSIZE_8MB: "y"
      CONFIG_FREERTOS_HZ: "1000"
      CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240: "y"
      CONFIG_ESPTOOLPY_FLASHMODE_QIO: y
      CONFIG_ESPTOOLPY_FLASHFREQ_120M: y
      CONFIG_SPIRAM_MODE_OCT: y
      CONFIG_IDF_EXPERIMENTAL_FEATURES: y
      CONFIG_SPIRAM_SPEED_120M: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      CONFIG_COMPILER_OPTIMIZATION_PERF: y

I had changed mine form looking exactly like yours for some reason I can’t remember.

I am no expert in this yaml esphome stuff though so I may be very wrong.

Hey, seems that was for the latest update of esphome, I got issues after the update of esphome in home assistant. Comenting out all the sdkconfig_options solved the problem since with the latest esphome update manage this for himself.

OK! thanks for the info. I found a configuration that works. I will rebuild my display from that configuration. This is the configuration: inytar

1 Like

There was a lot that was broken in ESPHome in the last 6 months since I compiled my example. I’ve now updated things to run under 2025.7.2 and it’s back working fine.
A couple of things…

  1. meter rotation - fixed in 2025.7.2
  2. wifi - random problems when specifying ‘buffer_size’ under LVGL
  3. need to use ‘experimental features’ for PSRAM 120MHz

Update can be found at:
https://github.com/DMonkey-hub/esphome/tree/main/examples/ESP32-S3-Touch-LCD-7

1 Like

Hey, glad to hear it works. Can you tell me what model you chose from the list?

Hello
First time poster need assistance
I have issues with the touch on the waveshare ESP32-S3 7inch touch display
I have loaded the Update esphome-19-LVGL-demo.yaml file into the display and the correct items are displayed
Time is showing the correct time if i press the clock face no message box
The test dial is showing 90 pressing any of the buttons from 10 to 100 the test dial does not move
I have attached a picture of the display

Yaml i loaded
# updated to 2025.7.2
################################################################################
# Substitution Variables
################################################################################
substitutions:
  device_internal_name: esphome19
  device_wifi_name: esphome-19
  device_friendly_name: ESPHome 19
  device_ip_address: 192.168.0.189
  device_sampling_time: 30s

################################################################################
# Globals
################################################################################
globals: ##to set default reboot behavior
  - id: wifi_connection
    type: bool
    restore_value: no
    initial_value: "false"


################################################################################
# Board Configuration
################################################################################
esphome:
  name: ${device_internal_name}
  friendly_name: ${device_friendly_name}
  platformio_options:
    build_flags: "-DBOARD_HAS_PSRAM"
    board_build.arduino.memory_type: qio_opi
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 524288

psram:
  mode: octal
  speed: 120MHz

esp32:
  board: esp32s3box
  variant: esp32s3
  flash_size: 8MB
  cpu_frequency : 240MHz
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      CONFIG_ESPTOOLPY_FLASHSIZE_8MB: "y"
      CONFIG_FREERTOS_HZ: "1000"
      CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240: y
      CONFIG_ESPTOOLPY_FLASHMODE_QIO: y
      CONFIG_ESPTOOLPY_FLASHFREQ_120M: y
      CONFIG_SPIRAM_MODE_OCT: y
      CONFIG_IDF_EXPERIMENTAL_FEATURES: y
      CONFIG_SPIRAM_SPEED_120M: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      #CONFIG_COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_COMPILER_OPTIMIZATION_PERF: y
      #CONFIG_COMPILER_OPTIMIZATION_DEBUG: y
    advanced:
      enable_idf_experimental_features: True


################################################################################
# Enable logging
################################################################################
logger:
  logs:
    component: ERROR

################################################################################
# Enable Home Assistant API
################################################################################
api:
#  reboot_timeout: 0s
#  encryption:
#    key: !secret api_encryption_key

################################################################################
# OTA
################################################################################
ota:
  platform: esphome  
  password: "40e3f66f6934698b70a9220c3e9f7c8a"

################################################################################
# WiFi
################################################################################
wifi:
#  networks:
  ssid: "Optus_8DE49C"
  password: "tauntpheer5PtEy"
  manual_ip:
    static_ip: 192.168.0.189
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 192.168.0.1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "waveshare-7inch-display-1"
    password: "6ufMS4f6yW0I"

captive_portal:

################################################################################
# Web Server
################################################################################
#web_server:
#  port: 80
#  version: 2
#  include_internal: true
#  auth:
#    username: !secret web_server_user
#    password: !secret web_server_password
#  local: true

################################################################################
# IO Extender
################################################################################
ch422g:
  - id: ch422g_hub

################################################################################
# Switch
################################################################################
switch:
  - platform: restart
    name: "Restart"
    id: device_restart
  
  - platform: safe_mode
    name: Use Safe Mode
    id: device_safe_mode
    
  - platform: gpio
    id: lcdbacklight
    name: lcdbacklight
    pin:
      ch422g: ch422g_hub
      number: 2
      mode:
        output: true
      inverted: false
    restore_mode: ALWAYS_ON

################################################################################
# Interval
################################################################################
interval:
  - interval: 10s
    then:
      - if:
          condition:
            wifi.connected:
          then:
            - lambda: |-
                id(wifi_connection) = true;
          else:
            - lambda: |-
                id(wifi_connection) = false;

time:
  - platform: homeassistant
    id: esptime
    on_time:
      - seconds: "*"
        then:
          - script.execute: clock_update

################################################################################
# Sensors
################################################################################
sensor:
  # WiFi
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    id: ${device_internal_name}_wifi_signal_sensor
    update_interval: ${device_sampling_time}

  # Uptime
  - platform: uptime
    name: "Uptime Sensor"
    id: ${device_internal_name}_uptime_sensor
    update_interval: ${device_sampling_time}
    internal: true
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: ${device_internal_name}_uptime_human
            state: !lambda |-
              int seconds = round(id(${device_internal_name}_uptime_sensor).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? to_string(days) + "d " : "") +
                (hours ? to_string(hours) + "h " : "") +
                (minutes ? to_string(minutes) + "m " : "") +
                (to_string(seconds) + "s")
              ).c_str();

#  - platform: homeassistant
#    id: battery_charging
#    entity_id: sensor.1be6e4_Battery_Power
#    internal: true

#  - platform: homeassistant
#    id: grid_output
#    entity_id: sensor.grid_output
#    internal: true

#  - platform: homeassistant
#    id: grid_input
#    entity_id: sensor.grid_input
#    internal: true

#  - platform: homeassistant
#    id: solar_gen
#    entity_id: sensor.1be6e4_ac_output_total_power
#    internal: true

#  - platform: homeassistant
#    id: home_use
#    entity_id: sensor.1be6e4_total_consumption_power
#    internal: true

#  - platform: homeassistant
#    id: battery_soc
#    entity_id: sensor.1be6e4_remaining_battery_capacity
#    internal: true

################################################################################
# Text Sensors
################################################################################
text_sensor:
  #-------------------------------------------------------------------------------
  # ESP32 internal sensors
  #-------------------------------------------------------------------------------
  - platform: wifi_info
    ip_address:
      name: IP Address
      id: ${device_internal_name}_ip_address
    ssid:
      name: Connected SSID
      id: ${device_internal_name}_connected_ssid
    mac_address:
      name: Mac Wifi Address
      id: ${device_internal_name}_mac_address
  #-------------------------------------------------------------------------------
  # Custom Text sensors
  #-------------------------------------------------------------------------------
  - platform: template
    name: Uptime Human Readable
    id: ${device_internal_name}_uptime_human
    icon: mdi:clock-start

  - platform: template
    name: RTC
    id: label_clock


#image:
#  - file: "image.png"
#    id: my_image
#    # resize: 320x480
#    type: RGB565

color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%
  - id: my_pink
    red: 100%
    green: 10%
    blue: 40%
  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%
  - id: my_green
    red: 0%
    green: 100%
    blue: 0%
  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%
  - id: my_gray
    red: 50%
    green: 50%
    blue: 50%
  - id: my_white
    red: 100%
    green: 100%
    blue: 100%
  - id: my_black
    red: 0%
    green: 0%
    blue: 0%


font:
  - file: "fonts/arial.ttf"
    id: arial_98
    size: 98
  - file: "fonts/arial.ttf"
    id: arial_96
    size: 96
  - file: "fonts/arial.ttf"
    id: arial_134
    size: 134
  - file: "fonts/arial.ttf"
    id: arial_128
    size: 128
  - file: "fonts/arial.ttf"
    id: arial_48
    size: 48
  - file: "fonts/arial.ttf"
    id: arial_36
    size: 36
  - file: "fonts/arial.ttf"
    id: arial_24
    size: 24
  - file: "fonts/arial.ttf"
    id: arial_12
    size: 12
  - file: "gfonts://Roboto"
    id: roboto10
    size: 10
    bpp: 4

script:
  - id: clock_update
    then:
      - lvgl.indicator.update:
          id: second_hand
          value: !lambda |-
            return id(esptime).now().second;
      - lvgl.indicator.update:
          id: minute_hand
          value: !lambda |-
            return id(esptime).now().minute;
      - lvgl.indicator.update:
          id: hour_hand
          value: !lambda |-
            auto now = id(esptime).now();
            return std::fmod(now.hour, 12) * 60 + now.minute;


            



############################################ START OF VLGL


lvgl:
  log_level: none #INFO
  color_depth: 16
  bg_color: my_gray
  text_font: arial_12
  width: 320
  height: 480
  align: center
  id: screen
  style_definitions:
    - id: date_style
      align: center
      text_color: 0x000000
      bg_opa: cover
      radius: 4
      pad_all: 2

  theme:
    button:
      scroll_on_focus: true
      #group: general
      border_width: 2
      text_font: arial_24
      outline_pad: 6
      pressed:
        border_color: my_yellow
      checked:
        border_color: my_blue
      focused:
        border_color: my_gray
    label:
      text_font: arial_24

  msgboxes:
  - id: message_box
    close_button: true
    title: Message box
    body:
      text: "This is a sample message box."
      bg_color: my_black
    buttons:
      - id: msgbox_apply
        text: "Apply"
      - id: msgbox_close
        text: "\uF00D"
        on_click:
          then:
            - lvgl.widget.hide: message_box


  widgets:
    - obj:
        height: 320
        width: 480
        align: center
        pad_all: 0
        bg_opa: 0%
        widgets:
        - button:  ########################## bottom buttons
            x: 40
            y: 260
            #align: center
            width: 50
            height: 50
            id: btn_id1
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "10"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 10                
                - lvgl.widget.redraw: 
                
        - button:
            x: 120
            y: 260
            #align: center
            width: 50
            height: 50
            id: btn_id2
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "20"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 20                
                - lvgl.widget.redraw: 
        - button:
            x: 200
            y: 260
            #align: center
            width: 50
            height: 50
            id: btn_id3
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "30"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 30                
                - lvgl.widget.redraw: 

        - button:
            x: 280
            y: 260
            #align: center
            width: 50
            height: 50
            id: btn_id4
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "40"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 40                
                - lvgl.widget.redraw: 

        - button:
            x: 360
            y: 260
            #align: center
            width: 50
            height: 50
            id: btn_id5
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "50"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 50                
                - lvgl.widget.redraw: 

        - button:  ########################## top buttons
            x: 40
            y: 10
            #align: center
            width: 50
            height: 50
            id: btn_id6
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "60"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 60                
                - lvgl.widget.redraw: 
                
        - button:
            x: 120
            y: 10
            #align: center
            width: 50
            height: 50
            id: btn_id7
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "70"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 70                
                - lvgl.widget.redraw: 
        - button:
            x: 200
            y: 10
            #align: center
            width: 50
            height: 50
            id: btn_id8
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "80"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 80                
                - lvgl.widget.redraw: 

        - button:
            x: 280
            y: 10
            #align: center
            width: 50
            height: 50
            id: btn_id9
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "90"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 90                
                - lvgl.widget.redraw: 

        - button:
            x: 360
            y: 10
            #align: center
            width: 50
            height: 50
            id: btn_id10
            #checkable: true
            widgets:
              - label:
                  align: center
                  text: "100"
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 100                
                - lvgl.widget.redraw: 

        # Example meter:
        - meter:
            #align: center
            x: 230
            y: 60
            width: 200
            height: 200
            widgets:
              - label:
                  y: 30
                  align: center
                  text: "Test"
            scales:
              range_from: 0
              range_to: 100
              angle_range: 240
              rotation: 150
              ticks:
                count: 51
                length: 3
                major:
                  stride: 5
                  length: 13
                  label_gap: 13
              indicators:
                - line:
                    id: soc_needle
                    width: 2
                    color: 0xFF0000
                    r_mod: -4
                    value: 88
                - tick_style:
                    start_value: -10
                    end_value: 40
                    color_start: 0x0000bd #FF0000
                    color_end: 0xbd0000 #0000FF

            # Example action:
            on_click:
              then:
                - lvgl.indicator.update:
                    id: soc_needle
                    value: 0                
                - lvgl.widget.redraw: 


        - obj: ######################################### Elegant Clock - https://community.home-assistant.io/t/esphome-elegant-lvgl-clock/772365
            height: 200
            width: 200
            x: 20
            y: 60
            pad_all: 4
            bg_opa: 0%
            border_width: 0  
            widgets:
            - meter:
                height: 100%
                width: 100%
                align: center
                bg_color: my_white

                scales:
                  # Minor ticks
                  - ticks:
                      width: 2
                      count: 61
                      length: 10
                      color: my_black
                    range_from: 0
                    range_to: 60
                    angle_range: 360
                    rotation: 270

                    # Minuite hand
                    indicators:
                      - line:
                          id: minute_hand
                          width: 3
                          color: my_black
                          r_mod: -1
                  # Major ticks
                  - angle_range: 330
                    rotation: 300
                    range_from: 1
                    range_to: 12
                    ticks:
                      width: 3
                      count: 12
                      length: 20
                      color: my_black                       

                  # Hour hand
                  - angle_range: 360
                    rotation: 270
                    range_from: 0
                    range_to: 720
                    indicators:
                      - line:
                          id: hour_hand
                          width: 4
                          color: my_black
                          r_mod: -40

                  # Second hand
                  - angle_range: 360
                    rotation: 270
                    range_from: 0
                    range_to: 60
                    indicators:
                      - line:
                          id: second_hand
                          width: 2
                          color: my_red
                          r_mod: -10
                on_click:
                    - lvgl.widget.show: message_box
         


########################################################### END OF VLGL


i2c:
  sda: GPIO08
  scl: GPIO09
  scan: True
  id: bus_a

# Define display
display:
  - platform: rpi_dpi_rgb
    id: my_display
    update_interval: never
    auto_clear_enabled: false
    color_order: RGB
    pclk_frequency: 16MHZ
    dimensions:
      width: 800
      height: 480
    de_pin:
      number: 5
    hsync_pin:
      number: 46
      ignore_strapping_warning: true
    vsync_pin:
      number: 3
      ignore_strapping_warning: true
    pclk_pin: 7
    pclk_inverted: true
    reset_pin:
      ch422g: ch422g_hub
      number: 3
#    enable_pin:
#      ch422g: ch422g_hub
#      number: 2  
    hsync_back_porch: 8
    hsync_front_porch: 8
    hsync_pulse_width: 4
    vsync_back_porch: 16
    vsync_front_porch: 16
    vsync_pulse_width: 4
    data_pins:
      red:
        - 1         #r3
        - 2         #r4
        - 42        #r5
        - 41        #r6
        - 40        #r7
      blue:
        - 14        #b3
        - 38        #b4
        - 18        #b5
        - 17        #b6
        - 10        #b7
      green:
        - 39        #g2
        - 0         #g3
        - 45        #g4
        - 48        #g5
        - 47        #g6
        - 21        #g7

touchscreen:
  platform: gt911
  id: my_touch
  display: my_display
  i2c_id: bus_a 
  interrupt_pin: GPIO4
  reset_pin:
    ch422g: ch422g_hub
    number: 1
    mode: OUTPUT
  on_touch:
    - lambda: |-
        ESP_LOGI("Touch", "Touch detected at x=%d, y=%d", touch.x, touch.y);
  on_update:
    - lambda: |-
          for (auto touch: touches)  {
              if (touch.state <= 2) {
                ESP_LOGI("Touch points:", "id=%d x=%d, y=%d x.raw=%d, y.raw=%d", touch.id, touch.x, touch.y, touch.x_raw, touch.y_raw);
              }
          }  
  on_release:
    then:
      - if:
          condition: lvgl.is_paused
          then:
            - lvgl.resume:
            - lvgl.widget.redraw:     


Logs from ESPHome when i touch the display

[08:54:20][I][Touch:803]: Touch detected at x=0, y=0
[08:54:20][I][Touch points::808]: id=0 x=0, y=0 x.raw=216, y.raw=356
[08:54:21][I][Touch:803]: Touch detected at x=0, y=0
[08:54:21][I][Touch points::808]: id=0 x=0, y=0 x.raw=227, y.raw=364
[08:54:21][I][Touch:803]: Touch detected at x=0, y=0
[08:54:21][I][Touch points::808]: id=0 x=0, y=0 x.raw=217, y.raw=366
[08:54:22][I][Touch:803]: Touch detected at x=0, y=0
[08:54:22][I][Touch points::808]: id=0 x=0, y=0 x.raw=221, y.raw=360
[08:54:22][I][Touch:803]: Touch detected at x=0, y=0
[08:54:22][I][Touch points::808]: id=0 x=0, y=0 x.raw=221, y.raw=368
[08:54:22][I][Touch:803]: Touch detected at x=0, y=0
[08:54:23][I][Touch points::808]: id=0 x=0, y=0 x.raw=221, y.raw=363
[08:54:23][I][Touch:803]: Touch detected at x=0, y=0
[08:54:23][I][Touch points::808]: id=0 x=0, y=0 x.raw=219, y.raw=372
[08:54:23][I][Touch:803]: Touch detected at x=0, y=0
[08:54:23][I][Touch points::808]: id=0 x=0, y=0 x.raw=223, y.raw=364

![Demo_19|375x500](upload://1bzx0szP15izm322E2fJEEdSBSn.jpeg)

Hi, I’m away at the moment so can’t test it.

You could try installing an older esphome using…

I also noticed that 2025.8.3 is out today and there is a fox in the
pipeline for the touchpad so best to try that first.

Let me know how it goes.

A fix, not a fox in the pipeline :blush: