TZT ESP32 2.4" LCD w/ touchscreen

Hi All!
I purchased four of these boards thinking they were CYDs. Close but no cupie doll.

Does anyone have any pinout info for this board? The LCD and touchscreen definitions I use for the ESP32-2432S028R (ie the standard CYD defs) talk to WIFI but not the LCD or touchscreen.

The boards came with a working demo programmed in, so I know the hardware is working.
I have tried reaching out to the manufacturer but so far, no answer. Their web page is here: TZT ESP32 LVGL WIFI&Bluetooth Development Board 2.4 inch LCD TFT Module 240*320 Smart Display Screen With Touch WROOM - TFT/OLED Display Module - TUOZHANTENG HK co.,LTD
Any help is much appreciated.
Phil.

I have the same bard and git the screen to work. Backlight IO is different:
#define TFT_BL 27

I still haven't figured out the touch...

Did you find out more?

marcus

Hi Marcus,

I kind of gave up on that board and bought a handful of ‘proper’ CYD boards (at an even lower price).

I have an LVGL project that I need consistency for so I’ll come back to the 2.4” boards at some later date and use them for little projects around my house (or not) …

I did find the attached documentation though – hope it helps :blush:

(attachments)

Getting started 2.4 Inch.pdf (6.04 MB)
ESP32-2432S024 Specifications-EN.pdf (786 KB)

Hi Phil,
thanks for the infos. I think they are not quite accurate. The seller now promised to send the appropriate documentation. There seen to be over a dozen CYD-style boards.
Marcus

Hi Marcus,

The files came directly from the manufacturer so….

I have this same board ESP32-2432S024 and I haven't been able to get anything on the screen. I get debug prints on terminal so I know my code is running, but screen stays black.
I am using following User_Setup.h configuration (TFT_eSPI 2.5.43):

#define ILI9341_DRIVER  
#define TFT_MISO 12
#define TFT_MOSI 13 
#define TFT_SCLK 14
#define TFT_CS   15  
#define TFT_DC   2  
#define TFT_RST  -1  
#define TFT_BL  27  // I have tried 21 as well
#define TFT_BACKLIGHT_ON HIGH 
#define TOUCH_CS 33     

Does these pin values look same as yours?

I have attached my User_setup.h for this board. I have since given up on it and put them into my parts bin…

(attachments)

User_Setup_24.h (15.9 KB)

Finally I got it working with following files and yes I am using CST816D.h. (Available here GitHub - fbiego/CST816S: An Arduino library for the Hynitron CST816S capacitive touch screen IC or here CST816S - Arduino Libraries)

! With CST820.h I didn't get it work, it registered touch, but touch position is always 0,0.

User_Setup.h

// User defined information reported by "Read_User_Setup" test & diagnostics example
#define USER_SETUP_INFO "User_Setup"

#define ILI9341_DRIVER       // Generic driver for common displays

#define TFT_WIDTH  240
#define TFT_HEIGHT 320 // ST7789 240 x 320

#define ESP32_DMA
#define TFT_BL   27            // LED back-light control pin
#define TFT_BACKLIGHT_ON HIGH  // Level to turn ON back-light (HIGH or LOW)
#define TFT_MISO 12
#define TFT_MOSI 13 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 14
#define TFT_CS   15  // Chip select control pin
#define TFT_DC   2  // Data Command control pin
#define TFT_RST  -1  // Reset pin (could connect to Arduino RESET pin)
//#define TOUCH_CS 33     // Chip select pin (T_CS) of touch screen


#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts


#define SMOOTH_FONT

#define SPI_FREQUENCY  80000000

// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY  80000000

// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY  2500000  //2500000

Piece of test code:

#include <CST816D.h>
#include <TFT_eSPI.h>  // Hardware-specific library
#include <SPI.h>

// #define I2C_SDA 4
// #define I2C_SCL 5
// #define TP_INT 0
// #define TP_RST 1

#define I2C_SDA 33
#define I2C_SCL 32
#define TP_RST 25
#define TP_INT 21

CST816D touch(I2C_SDA, I2C_SCL, TP_RST, TP_INT);

TFT_eSPI tft = TFT_eSPI();

void setup() {
  Serial.begin(115200);
  touch.begin(); 
  tft.begin();
  tft.fillScreen(TFT_YELLOW);
}

void loop() {
  bool touched;
  uint8_t gesture;
  uint16_t touchX, touchY;
  touched = touch.getTouch(&touchX, &touchY, &gesture);

  if (!touched) {
  } else {
    Serial.println((String) "Touch Data x: " + touchX + (String) ", y: " + touchY + (String) ", gesture: " + gesture);
    //Drawing
    tft.fillCircle(touchX, touchY, 5, TFT_BLACK);
  }
}

Gesture detection is not working, unfortunately, but I try to figure it out why not.
EDIT: Interrupts are not working, I have tested pins 21, 22, 23...

Well done!

Hi Phil
I’m trying to get the TZT Esp32 2432S024C board working but I’m confused with CST186S ( which is loaded into the library of Arduino) and the CST186D.h file which I can’t find or know where to place. As when I run the Arduino sketch it can’t find CST186D. Sorry I’m probably asking a silly question.
Tom

Hi Silverrider,

I gave up on the 2432S024C and I simply have no idea what a CST186S is. Sorry, but I can’t help you.

Hello,
According to the link you posted your board is not a 2432S024C but a 2432S024R instead, I just bought the same board and the touchscreen is Resistive not Capacitive.
I fiddled it it for a few hours and got both the display and tough to work fine. Hope you still have them in your parts bin so you can put them to good use.
Here is what I came up with:
User_Setup.h

// User defined information reported by "Read_User_Setup" test & diagnostics example
#define USER_SETUP_INFO "User_Setup"

#define ST7789_DRIVER 
// #define ILI9341_DRIVER       // Generic driver for common displays

#define TFT_WIDTH  240
#define TFT_HEIGHT 320 // ST7789 240 x 320
//  #define TFT_RGB_ORDER TFT_RGB  // Colour order Red-Green-Blue
 #define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
// #define TFT_INVERSION_ON
#define TFT_INVERSION_OFF

#define ESP32_DMA
#define TFT_BL   27            // LED back-light control pin
#define TFT_BACKLIGHT_ON HIGH  // Level to turn ON back-light (HIGH or LOW)
#define TFT_MISO 12
#define TFT_MOSI 13 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 14
#define TFT_CS   15  // Chip select control pin
#define TFT_DC   2  // Data Command control pin
#define TFT_RST  -1  // Reset pin (could connect to Arduino RESET pin)
#define TOUCH_CS 33     // Chip select pin (T_CS) of touch screen

#define USE_HSPI_PORT

#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts


#define SMOOTH_FONT

#define SPI_FREQUENCY  80000000

// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY  80000000

// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY  2500000  //2500000

I modified this code from Random Nerd Tutorials for the CYD to test the touch feature:

/*  Rui Santos & Sara Santos - Random Nerd Tutorials
    THIS EXAMPLE WAS TESTED WITH THE FOLLOWING HARDWARE:
    1) ESP32-2432S028R 2.8 inch 240×320 also known as the Cheap Yellow Display (CYD): https://makeradvisor.com/tools/cyd-cheap-yellow-display-esp32-2432s028r/
      SET UP INSTRUCTIONS: https://RandomNerdTutorials.com/cyd/
    2) REGULAR ESP32 Dev Board + 2.8 inch 240x320 TFT Display: https://makeradvisor.com/tools/2-8-inch-ili9341-tft-240x320/ and https://makeradvisor.com/tools/esp32-dev-board-wi-fi-bluetooth/
      SET UP INSTRUCTIONS: https://RandomNerdTutorials.com/esp32-tft/
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/

#include <SPI.h>

/*  Install the "TFT_eSPI" lbirary by Bodmer to interface with the TFT Display - https://github.com/Bodmer/TFT_eSPI
    *** IMPORTANT: User_Config.h available on the internet will probably NOT work with the examples available at Random Nerd Tutorials ***
    *** YOU MUST USE THE User_Config.h FILE PROVIDED IN THE LINK BELOW IN ORDER TO USE THE EXAMPLES FROM RANDOM NERD TUTORIALS ***
    FULL INSTRUCTIONS AVAILABLE ON HOW CONFIGURE THE LIBRARY: https://RandomNerdTutorials.com/cyd/ or https://RandomNerdTutorials.com/esp32-tft/   */
#include <TFT_eSPI.h>

// Install the "XPT2046_Touchscreen" library by Paul Stoffregen to use the Touchscreen - https://github.com/PaulStoffregen/XPT2046_Touchscreen
// Note: this library doesn't require further configuration
#include <XPT2046_Touchscreen.h>

TFT_eSPI tft = TFT_eSPI();

// Touchscreen pins
#define XPT2046_IRQ 36   // T_IRQ
#define XPT2046_MOSI 13  // T_DIN
#define XPT2046_MISO 12  // T_OUT
#define XPT2046_CLK 14   // T_CLK
#define XPT2046_CS 33    // T_CS

SPIClass touchscreenSPI = SPIClass(HSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define FONT_SIZE 2

// Touchscreen coordinates: (x, y) and pressure (z)
int x, y, z;

// Print Touchscreen info about X, Y and Pressure (Z) on the Serial Monitor
void printTouchToSerial(int touchX, int touchY, int touchZ) {
  Serial.print("X = ");
  Serial.print(touchX);
  Serial.print(" | Y = ");
  Serial.print(touchY);
  Serial.print(" | Pressure = ");
  Serial.print(touchZ);
  Serial.println();
}

// Print Touchscreen info about X, Y and Pressure (Z) on the TFT Display
void printTouchToDisplay(int touchX, int touchY, int touchZ) {
  // Clear TFT screen
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);

  int centerX = SCREEN_WIDTH / 2;
  int textY = 80;
 
  String tempText = "X = " + String(touchX);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);

  textY += 20;
  tempText = "Y = " + String(touchY);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);

  textY += 20;
  tempText = "Pressure = " + String(touchZ);
  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);
}

void setup() {
  Serial.begin(115200);

  // Start the SPI for the touchscreen and init the touchscreen
  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  touchscreen.begin(touchscreenSPI);
  // Set the Touchscreen rotation in landscape mode
  // Note: in some displays, the touchscreen might be upside down, so you might need to set the rotation to 3: touchscreen.setRotation(3);
  touchscreen.setRotation(1);

  // Start the tft display
  tft.init();
  // Set the TFT display rotation in landscape mode
  tft.setRotation(1);

  // Clear the screen before writing to it
  tft.fillScreen(TFT_WHITE);
  tft.setTextColor(TFT_BLACK, TFT_WHITE);
  
  // Set X and Y coordinates for center of display
  int centerX = SCREEN_WIDTH / 2;
  int centerY = SCREEN_HEIGHT / 2;

  tft.drawCentreString("Hello, world!", centerX, 30, FONT_SIZE);
  tft.drawCentreString("Touch screen to test", centerX, centerY, FONT_SIZE);
}

void loop() {
  // Checks if Touchscreen was touched, and prints X, Y and Pressure (Z) info on the TFT display and Serial Monitor
  if (touchscreen.tirqTouched() && touchscreen.touched()) {
    // Get Touchscreen points
    TS_Point p = touchscreen.getPoint();
    // Calibrate Touchscreen points with map function to the correct width and height
    x = map(p.y, 200, 3800, 1, SCREEN_HEIGHT);
    y = map(p.x, 240, 3700, 1, SCREEN_WIDTH);
    z = p.z;

    printTouchToSerial(x, y, z);
    printTouchToDisplay(x, y, z);

    delay(100);
  }
}

Well done!

I buried these at the back of a cupboard, so I’ll have to dig them out some time and give this a go.

Thanks very much!

have the same board and still not able to have something on the screen. Did you get to some point?
yours too need boot and reset button to be pressed together at the same time for the entire flashing process?

Hi!

I have not played with this board since my last post. I put them in a drawer and bought more of the 2.8” units.

Well done, thx a million.

Thank you, your User_Setup.h did the trick, I wanted two buttons to send messages out to MQTT to open my gate via HASS, here is the code I used with the above User_Setup.h copied into TFT_eSPI library folder, and 2.4 CYD.

#include <SPI.h>
#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h>
#include <WiFi.h>
#include <PubSubClient.h>

// ===== TFT Setup =====
TFT_eSPI tft = TFT_eSPI();

#define XPT2046_IRQ 36
#define XPT2046_MOSI 13
#define XPT2046_MISO 12
#define XPT2046_CLK 14
#define XPT2046_CS 33

SPIClass touchscreenSPI = SPIClass(HSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320

// ===== Wi-Fi & MQTT Settings =====
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* mqtt_server = "10.1.1.1;
WiFiClient espClient;
PubSubClient client(espClient);

// ===== Button Struct =====
struct Button {
  int x, y, w, h;
  String text;
  uint16_t color;
};

Button btnOpen = {20, 100, 90, 60, "OPEN", TFT_GREEN};
Button btnClose = {130, 100, 90, 60, "CLOSE", TFT_RED};

void drawButton(Button btn) {
  tft.fillRect(btn.x, btn.y, btn.w, btn.h, btn.color);
  tft.drawRect(btn.x, btn.y, btn.w, btn.h, TFT_WHITE);
  tft.setTextColor(TFT_WHITE, btn.color);
  tft.drawCentreString(btn.text, btn.x + btn.w / 2, btn.y + 20, 2);
}

bool isTouchInButton(int tx, int ty, Button btn) {
  return (tx > btn.x && tx < (btn.x + btn.w) && ty > btn.y && ty < (btn.y + btn.h));
}

void connectWiFi() {
  Serial.print("Connecting to WiFi...");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" connected");
}

void connectMQTT() {
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    if (client.connect("ESP32ButtonClient")) {
      Serial.println(" connected");
    } else {
      Serial.print(" failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);
    }
  }
}

void setup() {
  Serial.begin(115200);

  // Touchscreen
  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
  touchscreen.begin(touchscreenSPI);
  touchscreen.setRotation(1);

  // TFT
  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);
  drawButton(btnOpen);
  drawButton(btnClose);

  // Wi-Fi + MQTT
  connectWiFi();
  client.setServer(mqtt_server, 1883);
  connectMQTT();
}

void loop() {
  if (!client.connected()) {
    connectMQTT();
  }
  client.loop();

  if (touchscreen.tirqTouched() && touchscreen.touched()) {
    TS_Point p = touchscreen.getPoint();
    int tx = map(p.y, 200, 3800, 1, SCREEN_HEIGHT);
    int ty = map(p.x, 240, 3700, 1, SCREEN_WIDTH);

    if (isTouchInButton(tx, ty, btnOpen)) {
      Serial.println("OPEN pressed - sending MQTT message");
      client.publish("espbutton/button", "OPEN");
      delay(300); // debounce
    }
    else if (isTouchInButton(tx, ty, btnClose)) {
      Serial.println("CLOSE pressed - sending MQTT message");
      client.publish("espbutton/button", "CLOSE");
      delay(300); // debounce
    }
  }
}

Thanks! Been fiddling all morning just to see on the schematics provided by philmoore174 that the pinout was different from the "proper" CYDs. I was also using the RNT example and with the modifications you did it worked!

Hi. I spend some time trying to turn on monitor and touch on that board this is my User_Setup.h

#define USER_SETUP_INFO "User_Setup"

#define ST7789_DRIVER

#define TFT_WIDTH  240
#define TFT_HEIGHT 320

#define ESP32_DMA
#define TFT_BL   27
#define TFT_BACKLIGHT_ON HIGH
#define TFT_MISO 12
#define TFT_MOSI 13
#define TFT_SCLK 14
#define TFT_CS   15
#define TFT_DC   2
#define TFT_RST  -1

#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF

#define SMOOTH_FONT

#define SPI_FREQUENCY  80000000
#define SPI_READ_FREQUENCY  80000000
#define SPI_TOUCH_FREQUENCY  2500000
#define TFT_RGB_ORDER TFT_BGR
#define TFT_INVERSION_OFF

I used XPT2046_Touchscreen library for touch and that sketch to calibrate it

#include <TFT_eSPI.h>
#include <SPI.h>
#include <XPT2046_Touchscreen.h>

#define TFT_CS   15
#define TFT_DC   2
#define TFT_RST  -1
#define TOUCH_CS 33
#define TOUCH_IRQ 255

TFT_eSPI tft = TFT_eSPI();
XPT2046_Touchscreen ts(TOUCH_CS, TOUCH_IRQ);

void setup() {
  Serial.begin(115200);
  SPI.begin(14, 12, 13);
  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);
  ts.begin();
  ts.setRotation(1);
}

void loop() {
  if (ts.touched()) {
    TS_Point p = ts.getPoint();
    int touchX = map(p.y, 0, 3878, 0, 320);
    int touchY = map(p.x, 206, 3863, 0, 240);
    Serial.print("RAW X: "); Serial.print(p.x);
    Serial.print(" RAW Y: "); Serial.print(p.y);
    Serial.print("  ->  X: "); Serial.print(touchX);
    Serial.print(" Y: "); Serial.println(touchY);
    tft.fillCircle(touchX, touchY, 3, TFT_RED);
    delay(50);
  }
}

My problem was that screen was tilted in 90 degrees .
I hope that it will help someone .

You're my hero! Thank you so much for this!!!