Just wanted to share a basic working config for this device (ESP32-2432S028R)
Heads-up: I try to keep the configs in these posts updated but sometimes the configs in my repo are more up-to-date!
Here are the device-specific bits of the config separated out from everything else:
esp32:
board: esp32dev
framework:
type: arduino
i2c:
- sda: 27
scl: 22
scan: true
spi:
- id: tft
clk_pin: 14
mosi_pin: 13
miso_pin:
number: 12
ignore_strapping_warning: true
- id: touch
clk_pin: 25
mosi_pin: 32
miso_pin: 39
output:
- id: backlight_pwm
platform: ledc
pin: 21
- id: output_red
platform: ledc
pin: 4
inverted: true
- id: output_green
platform: ledc
pin: 16
inverted: true
- id: output_blue
platform: ledc
pin: 17
inverted: true
light:
- id: backlight
platform: monochromatic
output: backlight_pwm
name: Display Backlight
restore_mode: ALWAYS_ON
- id: led
platform: rgb
red: output_red
green: output_green
blue: output_blue
restore_mode: ALWAYS_OFF
# sensor:
# - platform: adc
# pin: 34
# name: "Brightness"
# update_interval: 60s
display:
- id: main_display
platform: ili9xxx
model: ILI9341
spi_id: tft
cs_pin:
number: 15
ignore_strapping_warning: true
dc_pin:
number: 2
ignore_strapping_warning: true
invert_colors: false
update_interval: never
auto_clear_enabled: false
touchscreen:
- id: main_touchscreen
platform: xpt2046
spi_id: touch
cs_pin: 33
interrupt_pin: 36
threshold: 400
calibration:
x_min: 280
x_max: 3860
y_min: 340
y_max: 3860
transform:
mirror_x: true
# on_touch:
# - lambda: |-
# ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
# touch.x,
# touch.y,
# touch.x_raw,
# touch.y_raw
# );
lvgl:
buffer_size: 25%
I like to keep device-specific code like that its own file separate from everything else so that I can use the Packages component to import it into multiple relevant projects, rather than duplicate the whole thing into each one. In my case I save it into a file called templates/ESP32-2432S028R.yaml
.
In the spirit of not duplicating code into multiple projects, I create another file that is not device-specific but is common/repetitive among all my projects. In my case I chose to call it templates/common.yaml
and it has code like so:
esphome:
name: "${device_name}"
friendly_name: "${friendly_name}"
logger:
level: INFO
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
web_server:
port: 80
ota:
- platform: esphome
api:
Finally, this is how I use both of the above files together in a project.:
substitutions:
device_name: sunton-28-test-device
friendly_name: Sunton 2.8 Test Device
packages:
common: !include templates/common.yaml
device: !include templates/ESP32-2432S028R.yaml
# dashboard: !include templates/dashboard_320x240.yaml
#sensor: ...
Note: The contents of the dashboard
package referenced above aren’t in this post but I have it in the example to illustrate the power of setting up a config this way. In my case templates/dashboard_320x240.yaml
is a file that I’ve created with HA sensors and LVGL pages in it, and it can be reused on any of my devices that support the same resolution as this one.
If someone wants to help get this device listed on devices.esphome.io then be my guest! I was too lazy to dig into that but hopefully posting here is just as helpful.
Concerns / Potential Improvements
- Touch gestures such as scrolling in LVGL don’t seem to work very well, but I haven’t spent any time figuring it out as basic touches and holds work fine.
Some things to consider before purchasing
- There’s no PSRAM which might limit use of images.
- The display has satisfactory viewing angles despite being a TN panel.
- The resistive touch is surprisingly okay, but not great.
- Micro-B Cables are very fragile and don’t provide a great connection, especially if ever bumped or bent.
More in my GitHub repo