Standalone ST7789 TFT not working with ESPHome

have you try to display an image? because its bootloop

how you use psram: in the yaml code please?

i have this error :

[psram] is an invalid option for [display.st7789v]. Please check the indentation.

when i add psram:

i have a ESP-Wroom-32 too

EDIT : i try

eightbitcolor: true

and it works! thanks @nochlab1 !

in the config add psram: like this

# Enable logging

logger:

psram:

# Enable Home Assistant API

api:

  encryption:
1 Like

I had a problem with the st7789 240x240 display where the CS pin is missing (bought on AliExpress)
I have modified the st7789v component to work with this display.
The operation of st7789 240x320 has not been checked (there is no such display available), but you can try changing it in the file st7789v.cpp lines 151-154.
Maybe it will help someone.
GitHub link

Hi Samoswall,

I really like this to work but I got these faults at compiling:

> INFO Reading configuration /config/esphome/willemesp4.yaml...
> INFO Generating C++ source...
> INFO Compiling app...
> Processing willemesp4 (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)
> --------------------------------------------------------------------------------
> HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
> LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
> Dependency Graph
> |-- ESPAsyncTCP-esphome @ 1.2.3
> |-- ESPAsyncWebServer-esphome @ 2.1.0
> |   |-- ESPAsyncTCP-esphome @ 1.2.3
> |   |-- Hash @ 1.0
> |   |-- ESP8266WiFi @ 1.0
> |-- DNSServer @ 1.1.1
> |-- ESP8266WiFi @ 1.0
> |-- ESP8266mDNS @ 1.2
> |-- SPI @ 1.0
> Compiling /data/willemesp4/.pioenvs/willemesp4/src/esphome/components/st7789v/st7789v.cpp.o
> Compiling /data/willemesp4/.pioenvs/willemesp4/src/esphome/core/entity_base.cpp.o
> Compiling /data/willemesp4/.pioenvs/willemesp4/src/esphome/core/helpers.cpp.o
> Compiling /data/willemesp4/.pioenvs/willemesp4/src/esphome/core/log.cpp.o
> In file included from src/esphome/components/st7789v/st7789v.cpp:2:
> src/esphome/components/st7789v/st7789v.cpp: In member function 'virtual void esphome::st7789v::ST7789V::setup()':
> src/esphome/components/st7789v/st7789v.cpp:115:126: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   115 |   ESP_LOGD(TAG,"inited display buffer %d DisplayBufferHeapList @ %p number of chunks: %d", this->get_buffer_length_(), this->buffers_, this->buffers_->size());
>       |                                                                                                                              ^~~~~~~~
> src/esphome/core/log.h:92:89: note: in definition of macro 'esph_log_d'
>    92 |   esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
>       |                                                                                         ^~~~~~~~~~~
> src/esphome/components/st7789v/st7789v.cpp:115:3: note: in expansion of macro 'ESP_LOGD'
>   115 |   ESP_LOGD(TAG,"inited display buffer %d DisplayBufferHeapList @ %p number of chunks: %d", this->get_buffer_length_(), this->buffers_, this->buffers_->size());
>       |   ^~~~~~~~
> src/esphome/components/st7789v/st7789v.cpp:115:142: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   115 |   ESP_LOGD(TAG,"inited display buffer %d DisplayBufferHeapList @ %p number of chunks: %d", this->get_buffer_length_(), this->buffers_, this->buffers_->size());
>       |                                                                                                                                              ^~~~~~~~
> src/esphome/core/log.h:92:89: note: in definition of macro 'esph_log_d'
>    92 |   esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
>       |                                                                                         ^~~~~~~~~~~
> src/esphome/components/st7789v/st7789v.cpp:115:3: note: in expansion of macro 'ESP_LOGD'
>   115 |   ESP_LOGD(TAG,"inited display buffer %d DisplayBufferHeapList @ %p number of chunks: %d", this->get_buffer_length_(), this->buffers_, this->buffers_->size());
>       |   ^~~~~~~~
> src/esphome/components/st7789v/st7789v.cpp:116:13: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   116 |   if (this->buffers_ == nullptr)
>       |             ^~~~~~~~
>       |             buffer_
> src/esphome/components/st7789v/st7789v.cpp:119:9: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   119 |   this->buffers_->clear_pixels();
>       |         ^~~~~~~~
>       |         buffer_
> src/esphome/components/st7789v/st7789v.cpp: In member function 'virtual void esphome::st7789v::ST7789V::update()':
> src/esphome/components/st7789v/st7789v.cpp:141:13: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   141 |   if (this->buffers_ == nullptr)
>       |             ^~~~~~~~
>       |             buffer_
> src/esphome/components/st7789v/st7789v.cpp: In member function 'void esphome::st7789v::ST7789V::write_display_data()':
> src/esphome/components/st7789v/st7789v.cpp:178:32: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   178 |   for (size_t i = 0; i < this->buffers_->size(); i++)
>       |                                ^~~~~~~~
>       |                                buffer_
> src/esphome/components/st7789v/st7789v.cpp:182:11: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   182 |     this->buffers_->get_chunk(i, chunk, len);
>       |           ^~~~~~~~
>       |           buffer_
> src/esphome/components/st7789v/st7789v.cpp: In member function 'virtual void esphome::st7789v::ST7789V::draw_absolute_pixel_internal(int, int, esphome::Color)':
> src/esphome/components/st7789v/st7789v.cpp:293:9: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   293 |   this->buffers_->set_pixel(pos, (color565 >> 8) & 0xff);
>       |         ^~~~~~~~
>       |         buffer_
> src/esphome/components/st7789v/st7789v.cpp:294:9: error: 'class esphome::st7789v::ST7789V' has no member named 'buffers_'; did you mean 'buffer_'?
>   294 |   this->buffers_->set_pixel(pos+1, (color565 & 0xff));
>       |         ^~~~~~~~
>       |         buffer_
> *** [/data/willemesp4/.pioenvs/willemesp4/src/esphome/components/st7789v/st7789v.cpp.o] Error 1
> ========================== [FAILED] Took 8.61 seconds ==========================

Can you tell what I did wrong? I´m a pretty newby in HA so want to learn.

Thanks very much!

Hi everyone,

I bought from AliExpress the ST7789 panel (https://es.aliexpress.com/item/1005004721706705.html?spm=a2g0o.order_list.order_list_main.11.3083194dhJYywv&gatewayAdapt=glo2esp) and despite it is claimed to be SPI, it has no CLK or MOSI pins

Therefore, this part of the configuration is useless and therefore I see nothing in the screen.

spi:
  clk_pin: GPIO19
  mosi_pin: GPIO18

That’s my code. Any advise? Thanks in advance for your help:

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO19

display:
  - platform: st7789v
    model: Adafruit RR 280x240
    #backlight_pin: GPIO4
    cs_pin: GPIO5
    dc_pin: GPIO16
    reset_pin: GPIO23
    update_interval: 5s
    eightbitcolor: true
    lambda: it.print(0, 0, id(roboto_font), "Hello World!");

The pinout is:

SDA = MOSI
SCL = CLK

Will try tomorrow. Thanks.

Any idea why this configuration does not work with an ESP32-WROOM32 Devkit V1?

#### ST7789  ####
spi:
  clk_pin: GPIO18  #SCL -> GPIO18
  mosi_pin: GPIO23 #SDA -> GPIO23

display:
  - platform: st7789v
    model: Custom
    rotation: 90
    width: 240
    height: 240
    offset_height: 0
    offset_width: 0  
    #backlight_pin: GPIO4
    #cs_pin: GPIO5 #not required
    dc_pin: GPIO1
    reset_pin: GPIO15
    update_interval: 5s
    eightbitcolor: true
    lambda: it.print(10, 10, id(roboto_font), "Hello World!");

It is working with this configuration in my ESP32-WROOM32 Devkit V1.
I hope this can be usefull for someone else.
Thanks for your help, @AaronCake and the rest of you. Great community!

#################
#### ST7789V ####
#################
spi:
  clk_pin: GPIO22      #SCL -> GPIO22
  mosi_pin: GPIO21     #SDA -> GPIO21

display:
  - platform: st7789v
    model: Adafruit RR 280x240 #Custom
    rotation: 90
    backlight_pin: GPIO32
    cs_pin: GPIO5
    dc_pin: GPIO16    #RX -> GPIO16
    reset_pin: GPIO17 #TX -> GPIO17
    update_interval: 5s
    eightbitcolor: true
    lambda: |-
      it.print(10, 10, id(roboto_font), my_red, "Hello World!");
      it.filled_circle(it.get_width() / 2, it.get_height() / 2, 20);
1 Like

I have a newer version of that display, this one: https://www.aliexpress.com/item/1005005039702168.html?spm=a2g0o.order_list.order_list_main.11.119e1802sI1JXj

i tested it with two esp boards, the D1 Mini V4 and S2 Mini.

I think d1 mini has not enough memory, with esphome a got the same exception as mentioned. But with the arduino example it works.

S2 mini works with esphome. Here is my configuration:

esp32:
  board: lolin_s2_mini
  variant: ESP32S2
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 5.0.0

### Display
font:
  - file: "fonts/OpenSans-Regular.ttf"
    id: font_text
    size: 20

color:
   - id: my_red
     red: 100%
     green: 0%
     blue: 0%

image:
  - file: "images/maras.jpg"
    id: my_image

spi:
  clk_pin: GPIO7
  mosi_pin: GPIO11

display:
  - platform: st7789v
    model: Adafruit RR 280x240
    backlight_pin: GPIO39
    cs_pin: GPIO37
    dc_pin: GPIO33
    reset_pin: GPIO15
    lambda: |-
      it.image(10, 5, id(my_image));
      it.print(it.get_width()/2, it.get_height()-5, id(font_text), id(my_red), TextAlign::BOTTOM_CENTER, "Pray for Türkiye");



1 Like

hi
If your LCD is similar to mine, add this line “spi_mode: mode2”.
use esp32 with PSRAM if your lcd size is 240x240

spi:
  clk_pin: 4
  mosi_pin: 5

display:
  - platform: st7789v
    model: "Custom"
    reset_pin: 6
    dc_pin: 7
    rotation: 90
    width: 240
    height: 240
    offset_height: 0
    offset_width: 0  
    spi_mode: mode2 
    # eightbitcolor: true

    lambda: |-

      it.image(0, 0, id(my_image));    
      // it.fill(my_blue);    
      // it.print(10, 120, id(font1), id(my_white), "Hello World!");

For info, same cheap ST7789 display GMT130-V1 works nicely at full 240x240 resolution with Lolin S3 Mini and ESPHome/HomeAssistant :ok_hand:

color:
   - id: my_red
     red: 100%
     green: 0%
     blue: 0%

image:
  - file: "pictures/chat.png"
    id: my_image
    type: RGB24

font:
  - file: "fonts/arial.ttf"
    id: font_text
    size: 15

# Ecran affichage local

spi:
  clk_pin: GPIO36
  mosi_pin: GPIO35

display:
  - platform: st7789v
    model: "Custom"
    reset_pin: 4
    dc_pin: 2
    rotation: 90
    width: 240
    height: 240
    offset_height: 0
    offset_width: 0  
    spi_mode: mode2
    lambda: |-
      it.image(0, 0, id(my_image));
      it.print(it.get_width()/2, it.get_height()-5, id(font_text), id(my_red), TextAlign::BOTTOM_CENTER, "Hello Eric");
1 Like