Problem with Display ST7789 3.5 inch

Hello everyone, I bought a ST7796 TFT LCD (no touch) on AliExpress because I wanted to use it for my project.
I tried and tried again to make it work with EspHome, but the best result I managed to get is the one you can see in the photo.
If I write the screen dimensions in the script (dimension: Weight480 - Height320) it does not enlarge the black screen you see in the photo, but it only gives me all the pixels of the screen (as you can see in the photo, excluding the black part of the display).
Lo script che utilizzo è questo:

esphome:
  name: acquario
  friendly_name: acquario

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "OajoZHC2mbaaAj85P02yDLBZYbubs8qa1lXWbQIBH4c="

ota:
  - platform: esphome
    password: "84e5766bcd075403bba8c653b4cedaa9"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip: 
    static_ip: 192.168.178.150
    gateway: 192.168.178.1
    subnet: 255.255.255.0
    dns1: 192.168.178.1

captive_portal:
  
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  

color:
  - id: my_fucsia
    hex: f400a1


display:
  - platform: ili9xxx
    model: ST7735
    cs_pin: GPIO2
    dc_pin: GPIO5
    reset_pin: GPIO4
    transform:
      mirror_x: true
      mirror_y: false
    
    # show_test_card: true
    spi_mode: mode3
    invert_colors: false
    
    update_interval: 1s
    
   
    lambda: |-
      
      it.print(13, 60, id(fonts1), id(my_fucsia), "Hello World !!!");
     
font:
  - file: "fonts/arial.ttf"
    id: fonts
    size: 16
  - file: "fonts/arial.ttf"
    id: fonts1
    size: 14

As you can read, I used ST7735 as the display model because it is the only one that works. If I insert the ST7796 model, it only gives me the pixels and no black part with the writing. I also tried to use all the other models suggested by Esphome but none of them work.
Do you have any idea how I can get the entire screen and not just that small black portion?
I also attach another photo with the display PINOUTS


Read the docs paying particular attention to the note about PSRAM and color_palette: 8bit

Hi Clyde, thanks for your reply…to write the esphome script for the display in question, I started from this very article you kindly pointed out to me, but I never managed to get it to work, except by entering ST7735 as the model, but only for that small portion of the screen you see in the picture.
In the various tests I had also inserted these lines in the script psram: mode: octal speed: 80MHz
but don’t worked. I will try again this evening and read the article more carefully, hopefully I will be able to do something right.
Thanks and ciao

Does your board have PSRAM? If it does is it an octal mode PSRAM? If one of those is not true then your psram config as written won’t help. The serial logs will contain information on what is failing.

Hi @Pietrogramma
I have just received a similar device (Integrated ESP32 C3 with touchscreen) and was having the same issue as you over the last weekend. Again a claimed " ST7789 240x280" that only worked with “model: ST7735” and only filled part of the display in default settings. Aliexpress title was “ESP32 C3 Watch MINI TV Buzzer 1.69 inch Round LCD TouchScreen Display ST7789 240x280”
I think this is what I have.

The key for me to be able to set the correct dimensions and offset and not have the device go into a boot-loop was to set color_palette: 8BIT which points to the memory issues identified by @clydebarrow.

Hope this helps you sort your display out.

The key bits of my config so far :

esphome:
  name: esp32_c3_lcd_spotpear
  friendly_name: ESP32 C3 SpotPear LCD

esp32:
  #board: esp32-c3 # Specifies the core chip type
  # Change board to the recognized devkit name
  board: esp32-c3-devkitm-1    
  framework:
    type: arduino


# ===== System Services =====

# --- Networking ---
wifi:
  blah blah 
..... 
# --- Core Services ---
logger:
  level: ${log_level}

# ===== Pin Definitions =====
substitutions:
  # Display Pins (confirmed from schematic)
  pin_lcd_clk: "5"    # GPIO5 - SCLK
  pin_lcd_mosi: "6"   # GPIO6 - MOSI
  pin_lcd_cs: "3"     # GPIO3 - CS
  pin_lcd_dc: "2"     # GPIO2 - DC
  pin_lcd_reset: "8"  # GPIO8 - RESET
  
  # Touchscreen Pins (confirmed from schematic)
  pin_touch_sda: "11"  # GPIO11 - TP_SDA
  pin_touch_scl: "7"   # GPIO7 - TP_SCL
  pin_touch_int: "9"   # GPIO9 - TP_INT
  
  # Buzzer Pin (confirmed from schematic)
  pin_buzzer: "1"      # GPIO1
  
  # System
  log_level: "VERBOSE"

# ===== Hardware Interfaces =====
spi:
  clk_pin: GPIO${pin_lcd_clk}
  mosi_pin: GPIO${pin_lcd_mosi}

i2c:
  sda: GPIO${pin_touch_sda}
  scl: GPIO${pin_touch_scl}
  scan: true
  id: bus_a

# ===== Display Configuration =====
display:
  - platform: ili9xxx
    model: ST7735
    cs_pin: GPIO${pin_lcd_cs}
    dc_pin: GPIO${pin_lcd_dc}
    reset_pin: GPIO${pin_lcd_reset}
    color_order: rgb
    invert_colors: true
    data_rate: 2MHz
    update_interval: 1s
    color_palette: 8BIT
    #show_test_card: true #helps to identify dimensions and offsets
    dimensions:
      height: 240
      width: 280
      offset_width: 20
    lambda: |-
      it.filled_circle(200, 192, 50, id(my_green));
      it.rectangle(0, 0, 150, 150, id(my_red));
      it.print(13, 60, id(font_small), id(my_blue), "Hello World !!!");

# ===== Touchscreen =====
touchscreen:
  - platform: cst816
    id: my_touchscreen
    i2c_id: bus_a
    interrupt_pin: GPIO${pin_touch_int}
    update_interval: 50ms
    on_touch:
      - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
          );

# ===== Audio =====
output:
  - platform: ledc
    pin: GPIO${pin_buzzer}
    id: buzzer_output

switch:
  - platform: template
    name: "Buzzer Switch"
    optimistic: true
    turn_on_action:
      - output.turn_on: buzzer_output
      - output.ledc.set_frequency:
          id: buzzer_output
          frequency: "2441Hz"
      - output.set_level:
          id: buzzer_output
          level: "75%"
    turn_off_action:
      - output.turn_off: buzzer_output

# ===== Fonts & Colors =====
font:
  - file: "gfonts://Roboto"
    id: font_small
    size: 50

color:
  - id: my_red
    red: 100%
    green: 3%
    blue: 5%
  - id: my_green
    red: 5%
    green: 100%
    blue: 2%
  - id: my_blue
    red: 5%
    green: 3%
    blue: 100%

And if you want full 16 bit colour you can use lvgl with buffer_size: 25% and remove the 8bit setting and lambda in the display config.

1 Like