Did anyone already trying to get ESPHome to work on LilyGo T-Embed

Hey there,

yesterday my LilyGo T-Embed arrived and I directly installed ESPHome onto it. With these board settings I’m able to install ESPHome:

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino
    version: 2.0.5
    platform_version: 5.2.0
  variant: esp32s3

(AFAIK the ESP32-S3 isn’t fully supported by ESPHome)

The pinout is available on GitHub and first I tried to get the display to work.

spi:
  clk_pin: GPIO12
  mosi_pin: GPIO11

display:
  - platform: st7789v
    model: Custom
    height: 320
    width: 170
    offset_height: 0
    offset_width: 0
    backlight_pin: GPIO16
    cs_pin: GPIO10
    dc_pin: GPIO17
    reset_pin: GPIO9

Unfortunately, the screen stays off. Did anyone already trying to get ESPHome to work on LilyGo T-Embed? Is it perhaps due to the board settings that it doesn’t work?

Thanks in advance

Lilygo are notorious for docs that are quite simply wrong. EG Can I use strapping pins for I2c? - #8 by Hellis81

Perhaps these are more accurate T-Embed/pin_config.h at 1f7fbe0a88027a2251e59db1256ad5f81368aff3 · Xinyuan-LilyGO/T-Embed · GitHub

Does this device have a touch screen ?

I haven’t got a embed board but all other lilygo products I have ever bought has had pinout diagrams that is incorrect.
Usually the pins that are for their hardware is correct and only the exposed leftover pins are incorrect.
But it wouldn’t surprise me if this too is wrong.

pin_control.h is certainly different to the image.

Thanks and sorry for the late reply. I was busy in the last days

i changed it to

spi:
  clk_pin: GPIO12
  mosi_pin: GPIO11

display:
  - platform: st7789v
    model: Custom
    height: 320
    width: 170
    offset_height: 0
    offset_width: 0
    backlight_pin: GPIO15
    cs_pin: GPIO10
    dc_pin: GPIO13
    reset_pin: GPIO9

but unfortunately still no image

I have not yet tried this board in ESPHome, but I know that it is based on the t-display S3. It doesn’t use SPI to access the screen, but a faster parallel access. In Arduino you need to mod the standard eTFT-SPI lib from Bodmer to get it to work (faster than SPI).
So I presume that is the issue. Check this link T-Display S3 - How to install in Arduino IDE - YouTube from Volos Projects how to use it in the Arduino dev env.
Maybe someone got the T- display S3 working in ESPHome, that config should work for the T-embed.

Chris

I found this Unable to install to ESP32-S3 (LilyGO T-Display-S3) - #14 by landonr
It might work for the t-embed

Thank you. That’s a solution. The Display backlight worked, until I tried to customize it further. :sweat_smile:
I’m at least one step further. Backlight works, but no image visible. I hope it will soon be easier to equip the T-Embed with ESPHome

That would be completely contrary to the docs and the sample code.

Any luck with this? I just got one and see many possibilities haha.

Unfortunately not. Currently, I don’t have the motivation to try further

Following some of the links above it’s documented pretty well here (fairly basic text and rectangles)

and a more complex one here mostly C code within ESPHome lambdas

I got it to work using patched libraries from LilyGO’s GitHub repo for T-Embed and custom component from tdisplay3. I did have to add a switch for GPIO46. This GPIO is working as a power switch for board’s peripherals.

Looking at diff between upstream and LilyGO’s version of TFT_eSPI library, there aren’t many changes in LilyGO version, so it’s really weird that native ESPHome components do not work out of the box (they seem to be based on TFT_eSPI). Two differences I noticed are:

  • LiliyGO example code for T-Embed write ST7789_SLPOUT command in setup:
    tft.writecommand(0x11);
    
  • T-Embed’s version of TFT_eSPI seems to be running at a higher SPI frequency.

Anyway, when I added ESPHome automation to write 0x11 on boot, I got some output on the screen (garbage and faint “Hello world” text"). Still need to setup development environment for ESPHome to experiment with SPI frequencies, but I’m moderately optimistic about this :smiley:

On the other hand, I might just hack together some custom components for TFT_eSPI and lvlg, and use that, we’ll see how it goes :smiley:

1 Like

I’m using the ESPHome code for the ST7789V component from October (or prior) to test this display and it has the same command on Setup but it’s still not working for me:


void ST7789V::setup() {
  ESP_LOGCONFIG(TAG, "Setting up SPI ST7789V...");
  this->spi_setup();
  this->dc_pin_->setup();  // OUTPUT

  this->init_reset_();

  this->write_command_(ST7789_SLPOUT);  // Sleep out
  delay(120);                           // NOLINT

Edit - I forgot to mention earlier that the reason I’m still using the OLD component for ST7789V is because I had issues with SPI for some new boards using the latest version, and the old version had fixed that, but not in this case.

The only success related to display on screen of T-embed i have so far is to flash the tft from examples of T-Embed’s official github repository here. T-Embed/example/tft at 1f7fbe0a88027a2251e59db1256ad5f81368aff3 · Xinyuan-LilyGO/T-Embed · GitHub
However, i had to replace the TFT_eSPI library in Arduino’s libraries folder with the one in lib folder of T-Embed github repository which is here T-Embed/lib/TFT_eSPI at 1f7fbe0a88027a2251e59db1256ad5f81368aff3 · Xinyuan-LilyGO/T-Embed · GitHub
Anybody managed to flash its own code on T-Embed and make screen working?

ok i got some sketches working now. Mainly as @lukasz-tuz mentioned, you have to ensure GPIO46 (POWER_ON PIN) is high and also you have to write command
tft.writecommand(0x11);
also better to use tft.init(); instead of tft.begin(); and due to some weird reason, i have to pull out the usb cable from power and then plug-in again to completely erase the cache of display screen from previously flashed sketch.

OK, after some trial and error I finally got the native ESPHome’s st7789v component to work with LilyGO’s T-Embed. Turns out, sending the SLPOUT command is required, but should be done as early as possible:

on_boot:
  priority: 800
  then:
    - lambda: |-
        id(disp).enable();
        id(disp).transfer_byte(0x11);
        id(disp).disable();

For the display itself, custom config for the st7789v can be used:

display:
  - platform: st7789v
    model: CUSTOM
    eightbitcolor: False
    rotation: 270
    width: 170
    height: 320
    offset_width: 0
    offset_height: 35
    backlight_pin: GPIO15
    cs_pin: GPIO10
    dc_pin: GPIO13
    reset_pin: GPIO9
    id: disp
    lambda: |-
      it.strftime(10, 20, id(roboto), "%H:%M", id(home_time).now());

Note how it’s not a 320x170 display, but a rotated 170x320 :smiley:

Here’s the full config, for future reference :slight_smile:

esphome:
  name: <project-name>
  platformio_options:
    # build_flags: |-
    #   -DARDUINO_USB_CDC_ON_BOOT=1 -DLV_CONF_INCLUDE_SIMPLE
    board_build.mcu: esp32s3
    board_build.name: "LilyGO T-Embed ESP32-S3"
    board_build.upload.flash_size: "16MB"
    board_build.upload.maximum_size: 16777216
    board_build.vendor: "LilyGO"
  on_boot:
    priority: 800
    then:
      - lambda: |-
          id(disp).enable();
          id(disp).transfer_byte(0x11);
          id(disp).disable();
      - switch.turn_on: power_on

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: !secret ota_password

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

spi:
  clk_pin: GPIO12
  mosi_pin: GPIO11

switch:
  - platform: gpio
    pin:
      number: GPIO46
      mode:
        output: True
    name: "Power On"
    id: power_on
  - platform: gpio
    pin:
      number: GPIO15
      mode:
        output: True
    name: "Display Backlight"
    id: backlight

time:
  - platform: homeassistant
    id: home_time


font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 96

display:
  - platform: st7789v
    model: CUSTOM
    eightbitcolor: False
    rotation: 270
    width: 170
    height: 320
    offset_width: 0
    offset_height: 35
    backlight_pin: GPIO15
    cs_pin: GPIO10
    dc_pin: GPIO13
    reset_pin: GPIO9
    id: disp
    lambda: |-
      it.strftime(10, 20, id(roboto), "%H:%M", id(home_time).now());

sensor:
  - platform: rotary_encoder
    internal: True
    name: "Rotary Encoder"
    pin_a: GPIO02
    pin_b: GPIO01

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO00
      inverted: True
    name: "Rotary Button"
    internal: True
7 Likes

Thanks for your efforts on this! In addition to the config above, it sounds like I need to use the libraries from here. Any other patches or tweaks? Ultimately I’d like to get this working with the esphome-remote project.