How to enable touch on Adafruit 3.5" TFT LCD board


I’m new with a project like this so there’s still many things I don’t understand but I hope you can help me out! I’m trying to enable touch functionality on my Adafruit 3.5" 480x320 TFT LCD breakout board. Using the lvgl_examples repository. Display is working good with the display driver being HX8357. Touch controller is ADCRAW with the pins:
(26) GPIO Y+
(27) GPIO X-
Touch does not work, it only displays x:0 y:0 as seen in the image below.

Other pins that are connected are:
(12) MOSI
(13) RST
(14) CLK
(15) DC
(18) CS
(19) MISO

What MCU/Processor/Board and compiler are you using?

ESP-WROOM-32 microcontroller, ESP-IDF v4.3-dev-907-g6c17e3a64, Adafruit 3.5" 480x320 TFT LCD

What LVGL version are you using?


What do you want to achieve?

Just to get touch to register on ESP IDF

What have you tried so far?

I had the pins for ADCRAW set as they were suggested when I first selected the touch controller. Those were the same as stated above except it was (32) instead of (4) and (33) instead of (5) but that gave an error in the adcraw.h

In file included from ../components/lvgl_esp32_drivers/lvgl_touch/adcraw.c:5:
../components/lvgl_esp32_drivers/lvgl_touch/adcraw.h:58:46: error: 'ADC1_CHANNEL_32' undeclared here (not in a function); did you mean 'ADC1_CHANNEL_3'?
 #define GPIO_TO_ADC_ELEMENT(x) [x] = CONCAT3(ADC1, _CHANNEL_, x)    // ADC1_, x, _CHANNEL
../components/lvgl_esp32_drivers/lvgl_touch/adcraw.h:54:25: note: in definition of macro '_CONCAT3'
 #define _CONCAT3(a,b,c) a ## b ## c
../components/lvgl_esp32_drivers/lvgl_touch/adcraw.h:58:38: note: in expansion of macro 'CONCAT3'
 #define GPIO_TO_ADC_ELEMENT(x) [x] = CONCAT3(ADC1, _CHANNEL_, x)    // ADC1_, x, _CHANNEL
../components/lvgl_esp32_drivers/lvgl_touch/adcraw.c:49:2: note: in expansion of macro 'GPIO_TO_ADC_ELEMENT'

Since IO32 and IO33 are ADC1_CH4 and ADC1_CH5 respectively, I changed it in the config to reflect those numbers and the error went away but the touch still doesn’t work.
I’ve measured with the voltmeter if there’s any signal coming from the x/y pins against ground. I expect to see 3V from some of the pins but it only shows about 100 mV on all of them.

I also tried using a different touch controller like XPT2046 with the pins:
(12) MOSI
(14) CLK
(18) CS
(19) MISO
(25) IRQ - although I don’t have an IRQ pin on this board, however I did set the touch detection to pressure only so I assume the pin isn’t needed
This setup compiled but it’s stuck in a boot loop with the error

disp_spi: Adding SPI devicee[0m
e[0;32mI (70) disp_spi: Clock speed: 26000000Hz, mode: 0, CS pin: 18e[0m
e[0;31mE (70) spi_master: spi_master_init_driver(206): host_id not initializede[0m
assertion "ret==ESP_OK" failed: file "../components/lvgl_esp32_drivers/lvgl_touch/tp_spi.c", line 47, function: tp_spi_add_device_config

abort() was called at PC 0x400f0db3 on core 1

I don’t think it’s hardware issue because when running touchscreendemoshield sketch from Adafruit in Arduino IDE, the touch does register

Code to reproduce

Running the widgets example from lv_examples repository on ESP-IDF, Adafruit 3.5" TFT LCD with touch controller set as ADCRAW or XPT2046

Screenshot and/or video


Touch screen

Serial output when using ADCRAW

Serial output when using XPT2046