Any way to get the new T-Display-S3 AMOLED to work with ESPHome?

Here is the product I’m talking about:

This is going to be a very popular product. The screen is amazing compared to any other esp32 screens I’ve seen. Very bright, high refresh rate and high resolution for its 1.9" size at 240x536.

Unfortunately it’s not supported by ESPHome yet, and the fixes for the original T-Display-S3 at this link don’t work for this new version:

Feel free to create a feature request :point_down:

Thanks, just submitted one.

1 Like

I have it working. New driver required, will submit shortly.

3 Likes

That sounds great. I would love to see it implemented and the configuration for that.

Any details on how to get this going?

Looks like the details can be found here: New T-Display-S3 AMOLED version · Issue #25 · landonr/lilygo-tdisplays3-esphome · GitHub

esphome:
  name: t-amoled
  platformio_options:
    build_unflags: -Werror=all
    board_build.flash_mode: dio

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

logger:
  level: DEBUG

api:
ota:
  password: !secret ota_password
wifi: !include wifi.yaml

external_components:
  source: github://clydebarrow/esphome@amoled
  components: [ qspi_amoled ]
  refresh: 10min

spi:
  id: quad_spi
  clk_pin: 47
  data_pins:
    - ignore_strapping_warning: false
      number: 18
    - 7
    - 48
    - 5

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

image:
  - file: cat.jpg
    id: cat_image
    resize: 180x75
    type: RGB565

display:
  - platform: qspi_amoled
    dimensions:
      height: 240
      width: 536
    transform:
      mirror_x: true
      swap_xy: true
    color_order: rgb
    brightness: 255
    cs_pin: 6
    reset_pin: 17
    enable_pin: 38
    lambda: |-
      auto rand_col = Color::random_color();
      it.filled_rectangle(0, 0, it.get_width(), it.get_height(), rand_col);
      it.image(0, 40, id(cat_image));
      it.print(it.get_width()/2, it.get_height()/2, id(roboto), TextAlign::CENTER, "ESPHome");
psram:
  mode: octal
3 Likes

Touchscreen config:

external_components:
  - source: github://pr#5941
    components: [ cst816]
    refresh: 10min
i2c:
  sda: 3
  scl: 2

touchscreen:
  - platform: cst816
    id: my_touchscreen
    interrupt_pin:
      number: 21
3 Likes

Tried this and am getting the following error:

INFO ESPHome 2023.12.8
INFO Reading configuration /config/esphome/esphome-web-649a94.yaml...
ERROR Unable to load component qspi_amoled.display:
Traceback (most recent call last):
  File "/esphome/esphome/loader.py", line 169, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/data/external_components/c09bccb9/esphome/components/qspi_amoled/display.py", line 83, in <module>
    spi.spi_device_schema(
TypeError: spi_device_schema() got an unexpected keyword argument 'quad'
Failed config

spi: [source <unicode string>:30]
  id: quad_spi
  clk_pin: 47
  
  [data_pins] is an invalid option for [spi]. Please check the indentation.
  data_pins: 
    - ignore_strapping_warning: False
      number: 18
    - 7
    - 48
    - 5
display.qspi_amoled: [source <unicode string>:55]
  
  Platform not found: 'display.qspi_amoled'.
  platform: qspi_amoled
  dimensions: 
    height: 240
    width: 536
  transform: 
    mirror_x: True
    swap_xy: True
  color_order: rgb
  brightness: 255
  cs_pin: 6
  reset_pin: 17
  enable_pin: 38
  lambda: |-

Any suggestions? Would love to get it working and so thankful people far more skilled then I are working on it

You’ll need to build against the dev branch, there are changes that are not yet in the esphome release. The 2024 release has been delayed as the lead developer is on holiday, won’t be back until early Feb.

git clone https://github.com/esphome/esphome.git

cd esphome/
script/setup
source venv/bin/activate

Now esphome will run the dev version.

Also, how are you trying to build this - from the command line or the HA dashboard? Just curious because I and others are nutting out ways to make this kind of thing easier.

Success!! I used the Esphome (dev) add-on (the one found in settings/add-ons) . Was very easy. Thanks so much.

Any idea why a simple home assistant sensor might cause the compile to fail?

sensor:
  - platform: homeassistant
    id: timer_sensor
    accuracy_decimals: 0
    entity_id: sensor.mr012186_shot_timer

with

/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection17send_sensor_stateEPNS_6sensor6SensorEf+0xc): undefined reference to `esphome::sensor::Sensor::has_state() const'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0x8): undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0xc): undefined reference to `esphome::sensor::Sensor::get_state_class()'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::send_sensor_state(esphome::sensor::Sensor*, float)':
/data/build/esphome-web-649a94/src/esphome/components/api/api_connection.cpp:463: undefined reference to `esphome::sensor::Sensor::has_state() const'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::send_sensor_info(esphome::sensor::Sensor*)':
/data/build/esphome-web-649a94/src/esphome/components/api/api_connection.cpp:475: undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: /data/build/esphome-web-649a94/src/esphome/components/api/api_connection.cpp:476: undefined reference to `esphome::sensor::Sensor::get_state_class()'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/core/controller.o:(.literal._ZN7esphome10Controller16setup_controllerEb+0x8): undefined reference to `esphome::sensor::Sensor::add_on_state_callback(std::function<void (float)>&&)'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/esphome/core/controller.o: in function `esphome::Controller::setup_controller(bool)':
/data/build/esphome-web-649a94/src/esphome/core/controller.cpp:29: undefined reference to `esphome::sensor::Sensor::add_on_state_callback(std::function<void (float)>&&)'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/main.o:(.literal._Z5setupv+0x88): undefined reference to `vtable for esphome::homeassistant::HomeassistantSensor'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/main.o:(.literal._Z5setupv+0x8c): undefined reference to `vtable for esphome::homeassistant::HomeassistantSensor'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/main.o:(.literal._Z5setupv+0xdc): undefined reference to `esphome::sensor::Sensor::Sensor()'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/main.o:(.literal._Z5setupv+0xe0): undefined reference to `esphome::sensor::Sensor::set_accuracy_decimals(signed char)'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/main.o: in function `esphome::esp32::ESP32InternalGPIOPin::ESP32InternalGPIOPin()':
/data/build/esphome-web-649a94/src/esphome/components/esp32/gpio.h:10: undefined reference to `esphome::sensor::Sensor::Sensor()'
/data/cache/platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pioenvs/esphome-web-649a94/src/main.o: in function `esphome::preferences::IntervalSyncer::IntervalSyncer()':
/data/build/esphome-web-649a94/src/esphome/components/preferences/syncer.h:9: undefined reference to `esphome::sensor::Sensor::set_accuracy_decimals(signed char)'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esphome-web-649a94/firmware.elf] Error 1
========================= [FAILED] Took 61.90 seconds =========================
1 Like

Did you do esphome clean your_config.yaml?

I had not, but that fixed it. Thanks for your help. Appreciate it.

1 Like

Thanks @clydebarrow !

I have the display working working on a Lilygo T4-S3 board as well. Touchscreen seems to be a CST226SE, no driver yet.

Config snippet:

...
spi:
  id: quad_spi
  clk_pin: 15
  data_pins:
    - 14
    - 10
    - 16
    - 12

display:
  - platform: qspi_amoled
    model: T4-S3
    dimensions:
      height: 600
      width: 450
    transform:
      mirror_x: false
      swap_xy: false 
    color_order: rgb
    brightness: 255
    cs_pin: 11
    reset_pin: 13
    enable_pin: 9
    lambda: |-
      auto rand_col = Color::random_color();
      it.filled_rectangle(0, 0, it.get_width(), it.get_height(), rand_col);
      it.print(it.get_width()/2, it.get_height()/2, id(roboto), TextAlign::CENTER, "ESPHome");

Hey, thanks for that! As you obviously found, I had been adding support for the T4-S3, but it actually wasn’t working for me. I was missing the enable pin.

Damn that thing is bright!!

is there any way to expose the brightness or an on/off switch for the display to home assistant? I’ve managed to set up the buttons to turn the screen on and off using:

binary_sensor:
  - platform: gpio
    name: "Amoled Button 1"
    pin: 
      number: GPIO0
      inverted: true
    internal: false
    on_click: 
      then:
        lambda: |-
          id(amoled).set_brightness(255);

  - platform: gpio
    name: "Amoled Button 2"
    pin: 
      number: GPIO21
      inverted: true
    internal: false
    on_click: 
      then:
        lambda: |-
          id(amoled).set_brightness(0);

but not sure if that is the right way to turn the screen on and off and have not had any luck exposing the brightness to homeassistant.

If you set up a template number you can control it from HA, and use it to set the brightness with a lambda in the set_action.

thank you for the suggestion.

I tried:

number:
  - platform: template
    name: "Amoled Brightness"
    min_value: 0
    max_value: 255
    step: 1
    lambda: |-
     'return id(amoled).brightness';
    set_action:
      then:
        - lambda: id(amoled).set_brightness(x);

it validates and uploads fine but makes the board crash (no display, no wifi).

That enable was weird. Wasn’t clear from my read of the schematics, and their own code seemed to ignore it.

YEAH, it really is!

Do you happen to know how different the CST226 is from the CST816?