Problem with XPT2046 touch on a ILI9488 4" display

I am using a ESP32DevKitCv4 and a 2,8" ILI9341 display with a XPT2046 touch controller. Display and touch function is working fine with the test sketch. When I press the displays I get the pressure, x and y values, when not pressing no values are displayd on serial monitor.
I also have a ILI9488 4" display with a XPT2046 touch controller and when I use that display (both displays have the same Pin layout) the display is working, but the touch function is delivering contstantly Pressure 4095, x=0, y=0 and is not reacting when touching.

PinOut of display 2,8" and 4" - both the same:
VCC
GND
CS
RESET
DC
MOSI
SCK
LED
MISO
T_CLK - Touchscreenpins from here on
T_CS -
T_DIN
T_DO
T_IRQ

SCK and T_CLK are connected both with GPIO 18
MOSI and T_DIN are connected both with GPIO23
MISO and T-DO are connected both with GPIO 19
the remaining connectiosn are direct between ESP and display as defined in the sketch

The wiring is easy and works with the 2,8" display

tippe oder füge den Code hier ein
#include <Preferences.h>   // zumschreiben und lesen im Flash Memory
Preferences preferences;  // Namespace preferences .. bezeichnung frei vergebbar

   // #include <Adafruit_GFX.h> // alternativ - muss aber mehr umgeschrieben werden. Die Arduino library ist schneller und universeller
#include <Arduino_GFX_Library.h>
//#include <SPI.h>  // wurde nicht gebraucht für Adafruit.GFX library
#include <XPT2046_Touchscreen.h>

    
#include <font/FreeSans9pt7b.h>
#include <font/FreeSansBold9pt7b.h>
#include<font/FreeSans12pt7b.h>
#include <font/FreeSansBold12pt7b.h>
    // #include <font/FreeMono12pt7b.h>
#include <UrlEncode.h>   // wird für whats app messages gebraucht - relativ einfach - infos von randomnerdtutorials.com
#include <HTTPClient.h>  // indirekt auch für whats app   - achtung bei esp8266

                         //  vv  Verdrahtungscheck lt AZ Delivery Schaltplan für 2,8"TFT im Wandgehäuse - passt auch für 4" display
#define TFT_SCK    18   //  auch auf T-CLK   -  ist OK lt AZD 
#define TFT_MOSI   23   //  auch auf T-DIN     -  ist OK lt AZD
#define TFT_MISO   19   // auch auf T-DO    -  ist OK lt AZD
#define TFT_CS     5    // ist OK lt AZD  (war beim ersten Versuch lt techtutorialsx auf 22)   
#define TFT_DC     4   //  ist OK lt AZD  (war beim ersten Versuch lt techtutorialsx auf 21)
#define TFT_RESET  22  //ist OK lt AZD  (war beim ersten Versuch lt techtutorialsx auf 17)


const int tftled = 15;  // GPIO 15 für Helligkeitsteuerung des TFT Displays - auf LED pin des displays
                        // wird nur beim Booten verwendet - geht aber für die Verwendung als TFT LED

#define HAVE_TOUCHPAD
#define CS_PIN    14
#define TIRQ_PIN  27

 Arduino_ESP32SPI bus = Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_SCK, TFT_MOSI, TFT_MISO);
 Arduino_ILI9488_18bit display = Arduino_ILI9488_18bit(&bus, TFT_RESET);  // für 4" Display von Amazon Okt23
 // Arduino_ILI9341 display = Arduino_ILI9341(&bus, TFT_RESET);   // für 2.8" Display von AZ Delivery


XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);  //
//XPT2046_Touchscreen ts(CS_PIN);  //



#include "defwifi.h"     // definition of wifi parameters in separate tab

void setup(void)
{

Serial.begin(115200);

/*
// tried also with that, but didn´t helped
pinMode(TFT_CS, OUTPUT);
pinMode(CS_PIN, OUTPUT);
digitalWrite(TFT_CS, HIGH);
digitalWrite(CS_PIN, HIGH);
*/
delay(1000);
ts.begin();
ts.setRotation(1);
Serial.println();

Wifistart();  // in a sperate tab

analogWrite(tftled,127); // LED des displays auf GPIO 32 - PWM Ansteuerung 0-255 = 0-100% Helligkeit 

  display.begin();
  display.setRotation(1); // 90 grad    ist Querformat , 0 = hochformat
  display.fillScreen(WHITE);
    //display.setFont(&FreeSans9pt7b);
  //display.setFont(&FreeSansBold9pt7b);
  display.setFont(&FreeSansBold12pt7b);
  
  display.setTextSize(1);
  display.setCursor(0, 20);  // horizontal, vertikal
  
  display.setTextColor(BLACK);
  display.println(" Hello world");
   display.println(" Test Oktober");
  delay(1000);  

 // Send Message to WhatsAPP
// sendMessage("Peter, hello from ESP32 - this is a test from the ESP32-ILI9341 testversuch-sketch from Nov.23");
}

void loop() {


if (ts.touched()) {
    TS_Point p = ts.getPoint();
    Serial.print("Pressure = ");
    Serial.print(p.z);
    Serial.print(", x = ");
    Serial.print(p.x);
    Serial.print(", y = ");
    Serial.print(p.y);
    delay(30);
    Serial.println();
  }

}

the print out from the serial monitor is:
------------------------------
06:44:00.449 -> Pressure = 4095, x = 0, y = 0
06:44:00.483 -> Pressure = 4095, x = 0, y = 0
06:44:00.526 -> Pressure = 4095, x = 0, y = 0
06:44:00.598 -> Pressure = 4095, x = 0, y = 0
06:44:00.598 -> Pressure = 4095, x = 0, y = 0
06:44:00.607 -> Pressure = 4095, x = 0, y = 0
06:44:00.607 -> Pressure = 4095, x = 0, y = 0
06:44:00.637 -> Pressure = 4095, x = 0, y = 0
06:44:00.682 -> Pressure = 4095, x = 0, y = 0
06:44:00.724 -> Pressure = 4095, x = 0, y = 0
06:44:00.755 -> Pressure = 4095, x = 0, y = 0
06:44:00.755 -> Pressure = 4095, x = 0, y = 0
06:44:00.787 -> Pressure = 4095, x = 0, y = 0
06:44:00.822 -> Pressure = 4095, x = 0, y = 0
06:44:00.853 -> Pressure = 4095, x = 0, y = 0
and so on...
-------------------------------------

From the provider of the 4" display ther is not much support, but the display controller and touch controller chip is known and should be sufficient.
Tried different other defintions, but that didn´t helped
Do you have any ideas what to do?
Thank you for help ...

I have an ILI9488 display with an XPT2046 touchscreen where the ILI9488 does not tristate MISO when /CS is inactive. With MISO being driven all the time, T_DO was being drowned out. So I had to tristate it myself with a 74AHC125 on the MISO line, with the /OE pin controlled by /CS.

Also, watch out for MISO being disabled in your library's setup. It was in mine. Watch for the Interface Mode Control register (0xB0) being set to 0x80 - you'll want it to be set to 0x00 if you want to be able to read data from the ILI9488.

Sounds as a good solution . Can you please give me a rough drawing (by hand) how to connect the MISO with the additional IC and the display?

Here's the kind of thing I was describing:

And if need be, you can use one of the other buffers in the 125 to do the same thing to DO on the 2046.

Also, if you know you're never ever going to want to read data back from the ILI9341, here's a no parts solution: skip the 125 and just not hook up the MISO output. The XPT2046 then has the ESP32's SDI/MISO pin all to itself.

Thank you for this good and detailed explanation .. now I understand it.
Will try it next week ...

Tied it today in the morning with disconnectiong the MISO from the ILI9488 and only have it on the XPT2046 and it WORKS ..

Your advice is GREAT ... SUPER :slight_smile:

best regards form Austria .. Peter

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.