Standalone ST7789 TFT not working with ESPHome

I bought an 1.3" ST7789 TFT display from AliExpress (like this one) and I’m trying to get it to work with ESPHome but running into boot loop issues. I cut the config file way back with this SUPER simple yaml:

esphome:
  name: attictemp1
  platform: ESP8266
  board: d1_mini

logger:
  level: DEBUG

spi:
  clk_pin: D5
  mosi_pin: D7

font:
  - file: "comic.ttf"
    id: my_font
    size: 22

display:
  - platform: st7789v
    backlight_pin: D0
    cs_pin: D3
    dc_pin: D1
    reset_pin: D2
    lambda: |-
      it.print(0, 0, id(my_font), "Hello World!");

the compiled binary is less than 300k and the device is wired like this:

You can see that my display device has no CS pin, I don’t know if that’s a problem or not but the CS pin definition is required by ESPHome.

When it fires up ESPHome boot loops with Could not allocate buffer for display!. Here is the full log:

17:16:05.303 -> e[1;31m[E][display:017]: Could not allocate buffer for display!e[0m
17:16:05.303 -> 
17:16:05.303 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
17:16:05.303 -> 
17:16:05.303 -> Exception (29):
17:16:05.303 -> epc1=0x4000e1b2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
17:16:05.337 -> 
17:16:05.337 -> >>>stack>>>
17:16:05.337 -> 
17:16:05.337 -> ctx: cont
17:16:05.337 -> sp: 3ffff620 end: 3fffffc0 offset: 0190
17:16:05.337 -> 3ffff7b0:  3fff04a4 00000000 3fff04a4 402024a2  
17:16:05.337 -> 3ffff7c0:  00000001 00000002 3fff04a4 402039d8  
17:16:05.337 -> 3ffff7d0:  3ffe88c8 3fff059c 00000020 00000000  
17:16:05.337 -> 3ffff7e0:  3ffefd44 00000000 3ffee99c 402087f4  
17:16:05.337 -> 3ffff7f0:  3fff059c 00000002 3ffee99c 40208865  
17:16:05.371 -> 3ffff800:  3ffef9bc 00000001 3ffee99c 402037d5  
17:16:05.371 -> 3ffff810:  3fff059c 00000003 00000000 00000000  
17:16:05.371 -> 3ffff820:  3fff04a4 00000000 3ffff860 4020ead9  
17:16:05.371 -> 3ffff830:  00000000 3ffeea0c 00000001 3fff0584  
17:16:05.371 -> 3ffff840:  3fff04a4 3fff04b4 00000000 402050c6  
17:16:05.371 -> 3ffff850:  0000000a 00000012 feefeffe feefeffe  
17:16:05.371 -> 3ffff860:  3ffefd3c 4023ae78 402043c4 402043a4  
17:16:05.371 -> 3ffff870:  00000007 00000000 3ffe8818 4023ae78  
17:16:05.405 -> 3ffff880:  00000000 00000007 00000005 00000013  
17:16:05.405 -> 3ffff890:  3ffe883b 4023ae8b 00000000 00000008  
17:16:05.405 -> 3ffff8a0:  00000009 00000011 3ffe883d 4023aead  
17:16:05.405 -> 3ffff8b0:  00000000 00000007 00000012 00000012  
17:16:05.405 -> 3ffff8c0:  3ffe883f 4023aee3 00000000 00000007  
17:16:05.405 -> 3ffff8d0:  00000008 00000017 3ffe8841 4023aefa  
17:16:05.405 -> 3ffff8e0:  00000000 00000007 00000008 00000017  
17:16:05.405 -> 3ffff8f0:  3ffe8843 4023af11 00000000 0000000e  
17:16:05.439 -> 3ffff900:  0000000b 0000000b 3ffe8845 4023af27  
17:16:05.439 -> 3ffff910:  00000000 00000017 00000006 00000005  
17:16:05.439 -> 3ffff920:  3ffe8847 4023af2c 00000000 00000012  
17:16:05.439 -> 3ffff930:  00000009 00000007 3ffe8849 4023af3a  
17:16:05.439 -> 3ffff940:  00000000 00000016 00000005 00000003  
17:16:05.439 -> 3ffff950:  3ffe8656 4023af3d 00000000 00000008  
17:16:05.439 -> 3ffff960:  0000000d 00000011 3ffe865c 4023af5f  
17:16:05.473 -> 3ffff970:  00000000 00000008 0000000a 00000011  
17:16:05.473 -> 3ffff980:  3ffe87a8 4023af81 00000000 00000008  
17:16:05.473 -> 3ffff990:  0000000d 00000011 3ffe87b3 4023afa3  
17:16:05.473 -> 3ffff9a0:  00000000 00000008 0000000d 00000011  
17:16:05.473 -> 3ffff9b0:  3ffe87be 4023afc5 00000000 00000008  
17:16:05.473 -> 3ffff9c0:  0000000d 00000011 3ffe884b 4023afe7  
17:16:05.473 -> 3ffff9d0:  00000000 00000007 0000000d 00000012  
17:16:05.473 -> 3ffff9e0:  3ffe87f9 4023b00b 00000000 00000008  
17:16:05.507 -> 3ffff9f0:  0000000d 00000011 3ffe8839 4023b02d  
17:16:05.507 -> 3ffffa00:  00000000 00000007 0000000d 00000012  
17:16:05.507 -> 3ffffa10:  3ffe884d 4023b051 00000000 00000007  
17:16:05.507 -> 3ffffa20:  0000000d 00000012 3ffe884f 4023b075  
17:16:05.507 -> 3ffffa30:  00000000 00000008 0000000d 00000012  
17:16:05.507 -> 3ffffa40:  3ffe8851 4023b099 00000000 0000000e  
17:16:05.507 -> 3ffffa50:  00000007 0000000b 3ffe8853 4023b0a4  
17:16:05.507 -> 3ffffa60:  00000000 00000008 00000010 00000011  
17:16:05.541 -> 3ffffa70:  3ffe8855 4023b0c6 00000000 00000008  
17:16:05.541 -> 3ffffa80:  0000000e 00000012 3ffe869c 4023b0ea  
17:16:05.541 -> 3ffffa90:  00000000 00000008 0000000d 00000011  
17:16:05.541 -> 3ffffaa0:  3ffe8729 4023b10c 00000000 00000008  
17:16:05.541 -> 3ffffab0:  00000010 00000011 3ffe866c 4023b12e  
17:16:05.541 -> 3ffffac0:  00000000 00000008 0000000e 00000011  
17:16:05.541 -> 3ffffad0:  3ffe88cb 4023b150 00000000 00000008  
17:16:05.574 -> 3ffffae0:  0000000d 00000011 3ffe8900 4023b172  
17:16:05.574 -> 3ffffaf0:  00000000 00000008 0000000f 00000011  
17:16:05.574 -> 3ffffb00:  3ffe8857 4023b194 00000000 00000008  
17:16:05.574 -> 3ffffb10:  00000011 00000011 3ffe869a 4023b1c7  
17:16:05.574 -> 3ffffb20:  00000000 00000008 0000000c 00000011  
17:16:05.574 -> 3ffffb30:  3ffe8859 4023b1e9 00000000 00000008  
17:16:05.574 -> 3ffffb40:  0000000f 00000011 3ffe885b 4023b20b  
17:16:05.608 -> 3ffffb50:  00000000 00000008 0000000d 00000011  
17:16:05.608 -> 3ffffb60:  3ffe8792 4023b22d 00000000 00000008  
17:16:05.608 -> 3ffffb70:  0000000c 00000011 3ffe885d 4023b24f  
17:16:05.608 -> 3ffffb80:  00000000 00000008 00000013 00000012  
17:16:05.608 -> 3ffffb90:  3ffe88d3 4023b285 00000000 00000008  
17:16:05.608 -> 3ffffba0:  00000012 00000011 3ffe867c 4023b2b8  
17:16:05.608 -> 3ffffbb0:  00000000 00000008 00000012 00000011  
17:16:05.608 -> 3ffffbc0:  3ffe8667 4023b2eb 00000000 00000008  
17:16:05.642 -> 3ffffbd0:  0000000b 00000011 3ffe885f 4023b30d  
17:16:05.642 -> 3ffffbe0:  00000000 00000008 00000013 00000016  
17:16:05.642 -> 3ffffbf0:  3ffe8672 4023b34f 00000000 00000007  
17:16:05.642 -> 3ffffc00:  0000000e 00000012 3ffe872d 4023b373  
17:16:05.642 -> 3ffffc10:  00000000 00000008 0000000f 00000012  
17:16:05.642 -> 3ffffc20:  3ffe8764 4023b397 00000000 00000007  
17:16:05.642 -> 3ffffc30:  0000000f 00000012 3ffe8861 4023b3bb  
17:16:05.642 -> 3ffffc40:  00000000 00000008 00000010 00000011  
17:16:05.676 -> 3ffffc50:  3ffe869f 4023b3dd 00000000 00000008  
17:16:05.676 -> 3ffffc60:  0000000e 00000012 3ffe8698 4023b401  
17:16:05.676 -> 3ffffc70:  00000000 00000008 00000016 00000011  
17:16:05.676 -> 3ffffc80:  3ffe88ef 4023b434 00000000 00000008  
17:16:05.676 -> 3ffffc90:  00000010 00000011 3ffe8863 4023b456  
17:16:05.676 -> 3ffffca0:  00000000 00000008 0000000e 00000012  
17:16:05.676 -> 3ffffcb0:  3ffe8865 4023b47a 00000000 00000008  
17:16:05.710 -> 3ffffcc0:  0000000f 00000011 3ffe8867 4023b49c  
17:16:05.710 -> 3ffffcd0:  ffffffff 00000019 0000000e 00000005  
17:16:05.710 -> 3ffffce0:  3ffe8869 4023b4a6 00000000 0000000e  
17:16:05.710 -> 3ffffcf0:  0000000b 0000000b 3ffe886b 4023b4bc  
17:16:05.710 -> 3ffffd00:  00000000 00000007 0000000d 00000012  
17:16:05.710 -> 3ffffd10:  3ffe886d 4023b4e0 00000000 0000000e  
17:16:05.710 -> 3ffffd20:  0000000b 0000000b 3ffe88dc 4023b4f6  
17:16:05.710 -> 3ffffd30:  00000000 00000007 0000000d 00000012  
17:16:05.744 -> 3ffffd40:  3ffe8743 4023b51a 00000000 0000000e  
17:16:05.744 -> 3ffffd50:  0000000c 0000000b 3ffe88cf 4023b530  
17:16:05.744 -> 3ffffd60:  00000000 00000007 0000000b 00000013  
17:16:05.744 -> 3ffffd70:  3ffe886f 4023b556 00000000 0000000e  
17:16:05.744 -> 3ffffd80:  0000000c 00000011 3ffe8871 4023b578  
17:16:05.744 -> 3ffffd90:  00000000 00000007 0000000c 00000012  
17:16:05.744 -> 3ffffda0:  3ffe871e 4023b59c 00000000 00000009  
17:16:05.744 -> 3ffffdb0:  00000006 00000010 3ffe8873 4023b5ac  
17:16:05.778 -> 3ffffdc0:  ffffffff 0000000a 00000009 00000015  
17:16:05.778 -> 3ffffdd0:  3ffe8972 4023b5d6 00000000 00000008  
17:16:05.778 -> 3ffffde0:  0000000d 00000012 3ffe89e5 4023b5fa  
17:16:05.778 -> 3ffffdf0:  00000000 00000007 00000006 00000012  
17:16:05.778 -> 3ffffe00:  3ffe8650 4023b60c 00000000 0000000e  
17:16:05.778 -> 3ffffe10:  00000011 0000000b 3ffe88d7 4023b62d  
17:16:05.778 -> 3ffffe20:  00000000 0000000e 0000000c 0000000b  
17:16:05.812 -> 3ffffe30:  3ffe8875 4023b643 00000000 0000000e  
17:16:05.812 -> 3ffffe40:  0000000c 0000000b 3ffe873c 4023b659  
17:16:05.812 -> 3ffffe50:  00000000 0000000d 0000000c 00000012  
17:16:05.812 -> 3ffffe60:  3ffe8877 4023b67d 00000000 0000000d  
17:16:05.812 -> 3ffffe70:  0000000b 00000012 3ffe8954 4023b6a1  
17:16:05.812 -> 3ffffe80:  00000000 0000000e 0000000a 0000000b  
17:16:05.812 -> 3ffffe90:  3ffe8879 4023b6b7 00000000 0000000e  
17:16:05.846 -> 3ffffea0:  0000000b 0000000b 3ffe874d 4023b6cd  
17:16:05.846 -> 3ffffeb0:  00000000 0000000a 0000000a 0000000f  
17:16:05.846 -> 3ffffec0:  3ffe887b 4023b6eb 00000000 0000000e  
17:16:05.846 -> 3ffffed0:  0000000b 0000000b 3ffe8738 4023b701  
17:16:05.846 -> 3ffffee0:  00000000 0000000e 0000000b 0000000c  
17:16:05.846 -> 3ffffef0:  3ffe887d 4023b719 00000000 0000000e  
17:16:05.846 -> 3fffff00:  0000000f 0000000c 3ffe887f 4023b731  
17:16:05.846 -> 3fffff10:  00000000 0000000e 0000000d 0000000b  
17:16:05.880 -> 3fffff20:  3ffe8632 4023b747 ffffffff 0000000e  
17:16:05.880 -> 3fffff30:  0000000b 00000011 3ffe8881 4023b769  
17:16:05.880 -> 3fffff40:  00000000 0000000e 0000000c 0000000b  
17:16:05.880 -> 3fffff50:  3ffe8883 4023b77f 00000000 00000007  
17:16:05.880 -> 3fffff60:  0000000a 00000012 00000000 00000000  
17:16:05.880 -> 3fffff70:  00000000 feefeffe feefeffe feefeffe  
17:16:05.880 -> 3fffff80:  3ffefd44 3fff04a4 00000708 feefeffe  
17:16:05.880 -> 3fffff90:  feefeffe feefeffe feefeffe 3ffeec08  
17:16:05.914 -> 3fffffa0:  3fffdad0 00000000 3ffeebc8 40206cc4  
17:16:05.914 -> 3fffffb0:  feefeffe feefeffe 3ffe850c 40100385  
17:16:05.914 -> <<<stack<<<
17:16:05.914 -> 
17:16:05.914 -> last failed alloc call: 40201048(64800)
17:16:05.914 -> 
17:16:05.914 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
17:16:05.914 -> 
17:16:05.914 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,7)
17:16:05.948 -> 
17:16:05.948 -> load 0x4010f000, len 3584, room 16 
17:16:05.948 -> tail 0
17:16:05.948 -> chksum 0xb0
17:16:05.948 -> csum 0xb0
17:16:05.948 -> v2843a5ac
17:16:05.948 -> ~ld
17:16:06.016 -> e[0;32m[I][logger:166]: Log initializede[0m
17:16:06.016 -> e[0;32m[I][app:029]: Running through setup()...e[0m
17:16:06.016 -> e[0;35m[C][spi:022]: Setting up SPI bus...e[0m
17:16:06.016 -> e[0;35m[C][st7789v:010]: Setting up SPI ST7789V...e[0m

Anyway, Googling around I found an issue someone opened up 10 days ago here: https://github.com/esphome/issues/issues/1478 and it appears to be unresolved and sounds very similar to my issue so maybe it’s already been reported…?

Any suggestions?

Thanks,
-Greg

I can’t solve your issue but here is an interesting article about whether or not you need a CS pin on these displays.

https://www.instructables.com/id/Adding-CS-Pin-to-13-LCD/

Hello @SpikeyGG,

same problem here, i test the screen wit arduino and its ok (https://wikifab.org/wiki/Afficher_une_image_sur_un_%C3%A9cran_ST7789 ) but it boot loop with EspHome.

Have you succeed in to make it works please?

According to the tutorial given by @zoogara, i am not sure that the CS pin is the problem, because it is only needed if you have several SPI hardware on the same line…and even if you declare a fake CS_PIN in Esphome, that make any difference for Esphome if its fake or not. Perhaps i am wrong…

The driver in ESP Home is for st7789V and the “V” mean nothing in the datasheet.

The only difference i noticed is the CS pin is present for the st7789V models, not the st7789. Perhaps its the difference…

Thanks

EDIT 16/12/2020 : work great with a ESP32, not a ESP8266. But now the screen is only use with 135x240 pixel like the TTGo screen…dont know how used the entire screen 240x320 pixels…

Does anybody got a solution??

Same problem for me here. Could not allocate buffer for display. Perhaps there is not enough ram? I tried disabling the portal, OTA, HA api, but no difference.

If not enough memory, could this be caught at compile time rather than runtime?

In the end I used an ESP32, and it worked.

What ep32 board are you using because i am trying with a esp32 and having same issue

The module I was using was esp32doit-devkit-v1

ok because 135x240 works but 240x240 isn’t working

Did you ever get it to work?

Yes, it worked

hello,

havent try since last time…perhaps esphome driver now accept resolution higher than 135x240…

@dave_t_uk nice to heard “yes, it worked”, but can you provide your YAML code please, to help :slight_smile:

yep, only 135x240 work and now there is a “custom” option but it doesnt work higher than 135x240 like the “TTGO TDisplay 135x240” type :

display:
  - platform: st7789v
    model: Custom
    height: 135
    width: 240
    offset_height: 0
    offset_width: 0
    backlight_pin: GPIO22
    cs_pin: GPIO5
    dc_pin: GPIO16
    reset_pin: GPIO17
    lambda: |-
      it.image(0, 0, id(my_image));

error :

[E][display:022]: Could not allocate buffer for display!

if height is above 135 pixel…

!!!EDIT!!! : works with 160, 200, 220, 230 pixels, after : crash : bootloop

so maximum is

height: 230
width: 240

i have a 320x240…not good to have 1/3 of screen unused…

aha ok thanks
so its a little misleading as they added support but it still doesn’t work

i found this esphome/esphome at fix_st7789v · fraxinas/esphome · GitHub so it looks like someone once trie dto fix it then stopped in middle

https://github.com/esphome/issues/issues/3877

i see you fill an issue but you doesnt give your yaml code and log error, so i open one with thoses details

OK thanks i was asking more of a question as it was probably verified that it works on a esp32 before it was merged

1 Like

Your welcome!

yes…strange it doesnt work…i have some display of ST7789 and hope to make it work one day with EspHome…

Adding psram: to the config worked for me on a “wrover” board

And besides for one of my “wroom” boards adding eightbitcolor: true made it work

(its 320x240 as height being longer was acting weird till I realized at least for the display I had)

I’m using one of these 240x0240 SPI boards with an ESP32-C3 and it seems to be working fine at full resolution so far but the project is still a work in progress.

My current test code is :

esphome:
  name: solar-hw-v4
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    version: latest 
  variant: esp32c3

# Enable logging
logger:

# Enable Home Assistant API
api:
#  encryption:
#    key: "password"

ota:
  password: "password"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Solar-Hw-V4 Fallback Hotspot"
    password: "password"
  

dallas:
  - pin: GPIO10
    update_interval: 5s
    
spi:
  clk_pin: GPIO19
  mosi_pin: GPIO18
    
# Individual sensors

sensor:
  - platform: dallas
    address: 0x0a00000472332328
#    address: 0xb500000440cf7028
    name: "Test Temperature"
    id: test_temp


  - platform: wifi_signal
    name: "C3-01M-HW-test-WiFi"
    update_interval: 10s 
    

# Display stuff

display:
  - platform: st7789v
    model: "Custom"
    reset_pin: GPIO0
    dc_pin: GPIO1
    rotation: 90
    width: 240
    height: 240
    offset_height: 0
    offset_width: 0    
    eightbitcolor: true
    update_interval: 5s
    lambda: |-
      it.printf(120, 40, id(font7), my_red, TextAlign::TOP_CENTER, " %.1f°", id(test_temp).state);
      it.line(0, 160, 240, 160, id(my_blue));      
      it.print(120, 180, id(font5), my_white, TextAlign::TOP_CENTER,  "Boost On");      
      // this line = the text is centered 120 pixels in from left and 180 pixels down 
font:
  - file: 'fonts/slkscr.ttf'
    id: font1
    size: 8

  - file: 'fonts/bebas-neue-regular.ttf'
    id: font2
    size: 48

  - file: 'fonts/arial.ttf'
    id: font3
    size: 14

  - file: 'fonts/bebas-neue-regular.ttf'
    id: font4
    size: 32
    
  - file: 'fonts/arial.ttf'
    id: font5
    size: 42
    
  - file: 'fonts/bebas-neue-regular.ttf'
    id: font6
    size: 54    

  - file: 'fonts/bebas-neue-regular.ttf'
    id: font7
    size: 106
    
color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%
  - 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_black
    red: 0%
    green: 0%
    blue: 0%
  - id: my_gray
    red: 50%
    green: 50%
    blue: 50%
  - id: my_white
    red: 100%
    green: 100%
    blue: 100%