How to Waveshare 3.5 LCD with ST7796 setup

Hi, I have tried to get this one working with esphome, but no luck with the display so far. Touch is working, I can get x/y in logs.
Model: https://www.waveshare.com/esp32-s3-touch-lcd-3.5.htm
Wiki: https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-3.5#Datasheets

Tried with quad spi and single, with mipi driver and ILxxxx.

Code:

esphome:
  name: ws-35-panel

psram:
  mode: octal
  speed: 80MHz

esp32:
  variant: esp32s3
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  framework:
    type: esp-idf

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ws-35-panel Fallback Hotspot"
    password: !secret wifi_ap_password

captive_portal:

# Enable logging
logger:
 level: INFO

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key

ota:
  platform: esphome
  password: !secret ota_password
  
web_server:
  port: 80
  
#spi:
#  id: display_qspi
#  type: quad
#  clk_pin: 5
#  data_pins: [1,2,3,4]
spi:
  id: display_spi
  clk_pin: GPIO05
  mosi_pin: GPIO01
  miso_pin: GPIO02

i2c:
  sda: 8
  scl: 7

display:
  - platform: mipi_spi
    model: st7796
    spi_id: display_spi
   # cs_pin: 6
    dc_pin: 3
    #reset_pin: EXIO1 
    rotation: 90
    spi_mode: 3
    color_order: bgr
    pixel_mode: 16bit
    auto_clear_enabled: false
    update_interval: never

#display:
#  - platform: ili9xxx 
#    model: ST7796
#    dc_pin: GPIO03
#    invert_colors: False
#    #data_rate: 40MHz
#    dimensions:
#      height: 320
#      width: 480
#    transform:
#      mirror_x: false
#      mirror_y: false
#    cs_pin:
#      number: -1
#      ignore_strapping_warning: true
#    auto_clear_enabled: false
#    update_interval: never
   # draw_from_origin: true
   # rotation: 0
   # init_sequence:

touchscreen:
  platform: ft63x6
  transform:
    swap_xy: true
    mirror_x: false
    mirror_y: true
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );

lvgl:
  widgets:
    - label:
        align: CENTER
        text: 'Hello World!'

I don’t know your display but just came to my mind, a while ago trying to help someone here with another waveshare display board, touch and lcd reset pins were swapped on the schematics.
Try with exio2.

You haven’t configured the tca9554 I/O Extender, which has the LCD reset pin, so it’s likely holding the LCD controller in reset.

1 Like

Thanks @clydebarrow ! That helped and I also checked some Arduino examples to verify setup. Now I got the famous “Hello World” to work!

esphome:
  name: ws-35-panel

psram:
  mode: octal
  speed: 80MHz

esp32:
  variant: esp32s3
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  framework:
    type: esp-idf

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ws-35-panel Fallback Hotspot"
    password: !secret wifi_ap_password

captive_portal:

# Enable logging
logger:
 level: INFO

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key

ota:
  platform: esphome
  password: !secret ota_password
  
web_server:
  port: 80

# I2C bus configuration
i2c:
  - id: i2c_bus
    sda: 8
    scl: 7
    scan: true

# PCA9554 GPIO extender for display reset
pca9554:
  - id: p_c_a
    address: 0x20
    i2c_id: i2c_bus

# Backlight PWM output and light component
output:
    # Backlight LED
  - platform: ledc
    pin: GPIO06
    id: GPIO06
    frequency: 2000Hz
    channel: 0

light:
  - platform: monochromatic
    output: GPIO06
    name: Display Backlight
    id: display_backlight
    restore_mode: ALWAYS_ON
    gamma_correct: 1

#spi:
#  id: display_qspi
#  type: quad
#  clk_pin: 5
#  data_pins: [1,2,3,4]
spi:
  id: display_spi
  clk_pin: GPIO05
  mosi_pin: GPIO01
  miso_pin: GPIO02

display:
  - platform: mipi_spi
    model: st7796
    spi_id: display_spi
    cs_pin:
      pca9554: p_c_a
      number: 2
    dc_pin: 3
    reset_pin:
      pca9554: p_c_a
      number: 1
    rotation: 90
    spi_mode: 1
    color_order: bgr
    pixel_mode: 16bit
    auto_clear_enabled: false
    update_interval: never
    
#display:
#  - platform: ili9xxx 
#    model: ST7796
#    dc_pin: GPIO03
#    invert_colors: False
#    #data_rate: 40MHz
#    dimensions:
#      height: 320
#      width: 480
#    transform:
#      mirror_x: false
#      mirror_y: false
#    cs_pin:
#      number: -1
#      ignore_strapping_warning: true
#    auto_clear_enabled: false
#    update_interval: never
   # draw_from_origin: true
   # rotation: 0
   # init_sequence:

touchscreen:
  platform: ft63x6
  transform:
    swap_xy: true
    mirror_x: false
    mirror_y: true
  on_touch:
    - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );

### HA sensors
time:
  - platform: homeassistant
    id: homeassistant_time
    timezone: Europe/Stockholm

sensor:
  - platform: homeassistant
    entity_id: sensor.utegivare_temperature
    id: ute_temp
  
lvgl:
  widgets:
    - label:
        align: CENTER
        text: 'Hello World!'
2 Likes