So I have this weird issue.
This is my config
esphome:
name: "lcd-with-touch-esp32"
friendly_name: LCD-With-Touch-ESP32
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "0y8By35x9D8mqZSghntlGOja1GpZg6Fr8gFcNvjxXQg="
ota:
password: "4e3b4930a3ff2672415c158b17331a0d"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.0.85
gateway: 192.168.0.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Lcd-Esp32 Fallback Hotspot"
password: "vxLa8dfwFIL1"
captive_portal:
web_server:
port: 80
spi:
clk_pin: 18
mosi_pin: 23
miso_pin: 14
touchscreen:
platform: xpt2046
id: my_touchscreen
cs_pin: 33
interrupt_pin: 19
update_interval: 20ms
calibration_x_max: 3691
calibration_x_min: 319
calibration_y_max: 453
calibration_y_min: 3873
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%d",
id(my_touchscreen).x,
id(my_touchscreen).y,
id(my_touchscreen).x_raw,
id(my_touchscreen).y_raw
);
display:
- platform: ili9xxx
model: ILI9341
cs_pin: 27
dc_pin: 26
reset_pin: 5
rotation: 270
lambda: |-
auto red = Color(255, 0, 0);
auto green = Color(0, 255, 0);
auto blue = Color(0, 0, 255);
auto white = Color(255, 255, 255);
it.fill(green);
if (id(my_touchscreen).touched)
it.filled_circle(id(my_touchscreen).x, id(my_touchscreen).y, 10, red);
switch:
- platform: gpio
pin:
number: 4
restore_mode: ALWAYS_ON
name: "Living Room Dehumidifier"
Now if i start the esp32 with the display connected and try touching the screen. It does not work.
Then while the power is still connected and the ESP32 is on, If i disconnect the display and reconnect it, the touch starts to work( i can see in the logs the touch coordinates) , but the display doesn’t show any colors on the screen (Some blue color is displayed instead of Green).
Next, If i continues to install the same image over wireless option using OTA, the OTA finishes, it reboots the device and I can see both the display as well as the touch input.
If I follow these exact steps without turning off the ESP32, it works… As soon as I turn it off and turn it on again, the touch stops working.
Can someone let me know what am I doing wrong? Is it the pins I have chosen causing a problem?