This is my first ESPHome project - to set up a display using a 3.5 inch CYD which I randomly bought of Aliexpress. On the back it just has ESP32-035 written on it with a central USB C and a ESP32 N4XX chip. Could find very little on it on googleing but with a bit of trial and error I found a config that worked, so I thought I would share it. I have to say thank you to littleCdev https://github.com/littleCdev/ESP32-035/ who posted some code for this device that helped me get the pins right. Also it seems the tft and touchscreen use the same spi pins - which set me in the right direction.
esphome:
name: cyd35
friendly_name: cyd35
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: 14
# mosi_pin: 3
# miso_pin: 36
output:
- id: backlight_pwm
platform: ledc
pin: GPIO27
- 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
initial_state:
state: on
restore_mode: ALWAYS_ON
- id: led
name: display led
internal: false
platform: rgb
red: output_red
green: output_green
blue: output_blue
restore_mode: ALWAYS_OFF
display:
- id: main_display
platform: ili9xxx
model: ILI9341
dimensions:
height: 320
width: 480
spi_id: tft
cs_pin:
number: GPIO15
ignore_strapping_warning: true
dc_pin:
number: GPIO2
ignore_strapping_warning: true
reset_pin: GPIO3
invert_colors: false
update_interval: never
auto_clear_enabled: false
transform:
mirror_x: true
swap_xy: true
mirror_y: true
touchscreen:
- id: main_touchscreen
platform: xpt2046
spi_id: tft
cs_pin: 33
interrupt_pin: 36
threshold: 400
calibration:
x_min: 480
x_max: 3860
y_min: 320
y_max: 3860
transform:
mirror_x: false
swap_xy: true
mirror_y: true
This is for a landscape view with usb port on left. All seems to work from tft and touch. (Except that I can change colours/brightness on the built in LED from home assistant, but cannot do a simple on/off of the LED). I hope this helps someone.
