Hello everyone! I recently decided to dive into the world of smart home automation and came across the Lilygo T-Encoder Pro. It’s a sleek device with a rotary encoder and an AMOLED screen, perfect for controlling various aspects of my home setup. However, getting it configured was a bit of a challenge, so I thought I’d share my journey and tips for anyone else looking to set it up.
Initial Setup and Challenges
I started by following the basic instructions provided by Lilygo, but I quickly realized that setting it up within Home Assistant wasn’t as straightforward as I hoped. The device uses an ESP32-S3 chip, which is compatible with ESPHome, but I had to tweak the configuration quite a bit to get everything working smoothly.
One of the first hurdles was understanding the hardware specifications. The T-Encoder Pro has 16MB of flash memory and 8MB of PSRAM, which is great for running more complex tasks. However, I had to ensure that my ESPHome configuration wasn’t exceeding these limits. I spent a couple of days adjusting settings and testing different configurations before I found the right balance.
The Configuration Process
Here’s a breakdown of how I set up the T-Encoder Pro using ESPHome:
yaml
esphome:
name: t_encoder_pro
friendly_name: T-Encoder Pro
min_version: 2024.6.0
name_add_mac_suffix: false
platformio_options:
board_build.flash_mode: dio
board_build.esp-idf.memory_type: qio_opi
esp32:
board: esp32-s3-devkitc-1
variant: esp32s3
framework: type: esp-idf
flash_size: 16MB
Enable PSRAM
psram:
mode: octal
speed: 80MHz
Add generic ota, api, logging, etc…
Configure the Quad SPI bus
spi:
id: display_qspi
type: quad
clk_pin: GPIO12
data_pins: [GPIO11, GPIO13, GPIO7, GPIO14]
Display configuration
display:
- platform: qspi_dbi
dimensions:
width: 390
height: 390
model: CUSTOM
cs_pin: GPIO10
reset_pin: GPIO4
enable_pin: GPIO3
rotation: 0
invert_colors: false
draw_from_origin: true
auto_clear_enabled: false
update_interval: never
init_sequence:
- [0x01] # Software Reset
- delay 200ms
- [0x11] # Sleep Out
- delay 120ms
- [0x13] # Normal Display Mode On
- [0x20] # Display Inversion Off
- [0x3A, 0x05] # Interface Pixel Format 16bit/pixel
- [0x29] # Display On
- [0x53, 0x28] # Brightness Control On and Display Dimming On
- [0x51, 0x00] # Brightness Adjustment
- [0x58, 0x00] # High Contrast Mode Off
- delay 10ms
font:
- file: “gfonts://Roboto”
id: my_font
size: 115
lvgl:
style_definitions:
- id: black_background
bg_color: 0x000000
bg_opa: 100% # Fully opaque
pages:
- id: main_page
styles: black_background
widgets:
- label:
text: "78"
x: 120
y: 137
text_align: center
text_color: 0xAAAAAA
text_font: my_font
sensor:
- platform: rotary_encoder
id: screen_rotate
pin_a: 1
pin_b: 2
on_clockwise:
- logger.log: “Turned Clockwise”
on_anticlockwise:
- logger.log: “Turned Anti Clockwise”
binary_sensor:
- platform: gpio
id: screen_press
pin: number: 0
on_press:
- logger.log: ‘Button Pressed!’
- if:
condition: rtttl.is_playing
then:
- logger.log: ‘Playback stopping!’
- rtttl.stop
else:
- logger.log: ‘Playing starting!’
- rtttl.play: ‘star_wars:d=16,o=5,b=100:4e,4e,4e,8c,p,g,4e,8c,p,g,4e,4p,4b,4b,4b,8c6,p,g,4d#,8c,p,g,4e,8p’
output:
- platform: ledc
pin: 17
id: buzzer
rtttl:
output: buzzer
id: my_rtttl
gain: 60%
Key Takeaways
-
Understanding Hardware Specifications: Knowing the flash memory and PSRAM capacities was crucial. It helped me optimize the ESPHome configuration to prevent memory issues.
-
Quad SPI Bus Configuration: The display uses a Quad SPI bus, and configuring it correctly was essential for smooth operation. I had to experiment with different settings to ensure the display worked without lag.
-
LVGL and Font Configuration: Customizing the display with LVGL and the right font size made the interface user-friendly. I found that a font size of 115 provided the best readability without overcrowding the screen.
-
Rotary Encoder and Button Integration: Setting up the rotary encoder and button actions required careful scripting. I used logger.log to debug and ensure that each action (clockwise, anticlockwise, press) was correctly registered.
-
RTTTL for Audio Feedback: Adding audio feedback using RTTTL made the device more interactive. I programmed it to play a short melody when the button is pressed, providing immediate auditory confirmation of the action.
Final Thoughts
Configuring the Lilygo T-Encoder Pro was a rewarding experience. It required patience and a lot of trial and error, but seeing the device come to life with all the features working seamlessly made it all worthwhile. I’m now looking forward to integrating it further into my smart home setup and exploring more advanced configurations.
If anyone has questions or needs help with their T-Encoder Pro setup, feel free to reach out! I’m happy to share more details or troubleshoot issues together.
Best regards,
[Your Name]