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
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:
ST7789_SLPOUT
command in setup
:tft.writecommand(0x11);
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
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
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
Here’s the full config, for future reference
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
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.
The code above looks complete without any additional libraries.
Thanks for the code @lukasz-tuz, it’s working like a charm (the display).
I got almost everything working now, except for the LEDs because of the GPIO PINs used on the ESP32-S3 are not accepted by FastLED 3.3.2 code. Looks like version 3.5.0 has corrected the PINs mapping but I’m having a hard time using/changing to the newest version on ESPHome
Ah, yes, the FastLED issue. When trying to enable the st7789 I learned about the external_components
feature of ESPHome. That did not really help with the display, but creates an easy way to fix the LEDs.
esphome/components/fastled_base
and esphome/components/fastled_spi
directories.fastled_base
open __init__.py
and simply bump the FastLED code: await light.register_light(var, config)
cg.add_library("fastled/FastLED", "3.5.0")
return var
external_components:
- source:
type: local
path: esphome/components
light:
- platform: fastled_spi
chipset: APA102
data_pin: GPIO42
clock_pin: GPIO45
rgb_order: BGR
num_leds: 7
name: "T-Embed LED Ring"
effects:
- addressable_rainbow:
- addressable_scan:
When building, ESPHome will use local fastled_spi
definition, and will download 3.5.0 version of FastLED. For T-Embed, with ESP32S3, this is completely fine; seems that ESPHome keeps the version downgraded due to some issues coming up on ESP8266.
BTW, T-Embed makes for a great smart home remote Some time ago I tried building my own version of such device, with OLED display and NeoPixel LED ring. It actually worked for a while, but there were stability issues on account of my poor soldering skills.
However, I was able to move ESPHome YAML from that device to T-Embed with very little changes (mostly related to different display controller), and now it works like a charm Now I’m trying to get esphome-lvgl
working, hoping to make a component that implements ESPHome’s Display Menu integration using fancy lvgl
widgets.
EDIT: I just clicked the esphome-remote link. Oh well, looks like the home remote thing has already been done, and much better than my attempts at that Thanks for the link @lmatter!
Thanks @lukasz-tuz, this was a big help.
I’m used to external_components, and I have serveral customizations from original ESPHome components, but somehow, I’ve missed that version configuration on fastled_base.
I’m glad your project is working, and now I’m trying to decide what type of I2C sensor I want to use with this device (maybe SCD41) and a way to increase the size of the original 3D Printed case to fit the sensor.
Thanks again.
You’re welcome! I hope that by standing on the shoulders of you giants I can get a cool remote working. Sadly the T-Embed only has one button. I might have to add another to it somewhere.
Sorry if this is boneheaded, but how do you get this installed on the T-embed? I took the config from @lukasz-tuz, manually built it (modern format) and installed via web.esphome.io but the logs say:
ESP-ROM:esp32s3-20210327
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xb (SPI_FAST_FLASH_BOOT)
Saved PC:0x40043ac8
Invalid chip id. Expected 9 read 3460. Bootloader for wrong chip?
ets_main.c 329
Terminal disconnected: NetworkError: The device has been lost.
What type of ESP should I select when I create a new entry in my local esphome manager? I tried Generic ESP32-WROVER [EDIT: I realized WROVER was wrong and switched to Espressif ESP32 Dev Module - still didn’t work]
Thanks!
In esphome click install|plug into (there is choice of whether the device is pugged into the computer you are running the browser on, or the machine running esphome)
They are the same machine (I don’t run esphome on HA, I run it on my laptop in docker). I’m asking about this step:
Sorry, its shown here Did anyone already trying to get ESPHome to work on LilyGo T-Embed - #19 by lukasz-tuz
platformio_options:
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"
Choose any one and edit it if need be.
Thanks. I must be doing something wrong then because I don’t have esp32s3 as an option. I pulled the latest version of the container - maybe I need a dev version?
[EDIT: I think the issue I’m having is that I’m running esphome:latest. I just found a container called esphome:dev. I’ll try that one]
ok, running esphome-dev gives me the ESP32-S3 choice. But now I’m getting a new issue, which is the editor (and compiler) not recognizing the platformio-options component: I must be still missing something.
According to the docs, the platformio_options
should be indented right
(Although this is contrary to @lukasz-tuz 's post)
That was it! Thanks! I owe the Internet 1 rtfm.
esphome:
name: test2
platformio_options:
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:
# Send the `SLPOUT` command as early as possible
priority: 800
then:
- lambda: |-
id(disp).enable();
id(disp).transfer_byte(0x11);
id(disp).disable();
# Also, turn the lights on
- switch.turn_on: power_on