Getting Started with ESP32 Cheap Yellow Display Board – CYD (ESP32-2432S028R)

In this guide, you’ll learn how to get started with the ESP32 Cheap Yellow Display (ESP32-2432S028R). This is a TFT Touchscreen display LCD with an ESP32 development board included. This is a great option to build graphical user interfaces (GUI) for your IoT projects.

Getting Started with ESP32 Cheap Yellow Display Board - CYD ESP32-2432S028R

If you have a standalone TFT Touchscreen Display 2.8 inch with ILI9341 driver, you can follow this getting started guide.

Introducing the ESP32 Cheap Yellow Display – CYD (ESP32-2432S028R)

The ESP32-2432S028R development board has become known in the maker community as the “Cheap Yellow Display” or CYD for short. This development board, whose main chip is an ESP32-WROOM-32 module, comes with a 2.8-inch TFT touchscreen LCD, a microSD card interface, an RGB LED, and all the required circuitry to program and apply power to the board.

ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R front

This is a very versatile board to build GUIs for your IoT projects and is much more convenient and practical than using a separate ESP32 board with a TFT screen.

ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R back labeled

Here’s a list of more detailed specifications of this development board:

  • Dual-core MCU, integrated WI-FI and Bluetooth functions
  • Frequency can reach 240MHz
  • 520KB SRAM, 448KB ROM, Flash size is 4MB
  • Module size 50.0×86.0mm
  • Operating Voltage: 5V
  • Power consumption: approximately 115mA
  • Product weight: approximately 50g
  • The module includes:
    • 2.8-inch color TFT display screen with ILI9341 driver chip
    • Display resolution: 240x320px with resistive touchscreen
    • Backlight control circuit
    • TF card interface for external storage
    • Serial interface
    • Temperature and humidity sensor interface (DHT11 interface) and reserved IO port interface
    • It can be programmed with: Arduino IDE, MicroPython, ESP-IDF

In the Extended GPIO connectors, there are at least 4 GPIOs available: GPIO 35, GPIO 22, GPIO 21, and GPIO 27. It also has the TX/RX pins available (see previous image).

Where to buy?

You can click on the link below to check where to buy the ESP32 Cheap Yellow display and its price on different stores.

Installing Arduino Libraries

The ESP32 communicates with the TFT Display and Touchscreen using SPI communication protocol. We’ll be using the TFT_eSPI and XPT2046_Touchscreen libraries.

Installing the TFT_eSPI Library

Open your Arduino IDE and go to Sketch Include Library > Manage Libraries. The Library Manager should open. Search for TFT_eSPI. Select the TFT_eSPI library by Bodmer and install it.

Installing TFT_eSPI library Bodmer Arduino IDE 2

Installing the XPT2046_Touchscreen Library

Open your Arduino IDE and go to Sketch Include Library > Manage Libraries. The Library Manager should open. Search for XPT2046_Touchscreen. Select the XPT2046_Touchscreen library by Paul Stoffregen and install it.

Installing XPT2046_Touchscreen Library by Paul Stoffregen Arduino IDE 2

Prepare User_Setup.h Config File for TFT_eSPI Library

To properly use the TFT_eSPI library, you need a configuration file called User_Setup.h with the right definitions. We’ve already prepared that file so that you don’t have any configuration issues following our examples. You just need to download it and move it to the right folder. Follow the next instructions to learn how to do it.

a) Preparing the Config File – Windows PC

b) Preparing the Config File – Mac OS

a) Preparing the Config File – Windows PC

Having both libraries installed (TFT_eSPI and XPT2046_Touchscreen), download the User_Setup.h configuration file.

User_Setup.h file for TFT_eSPI library Bodmer Arduino IDE 2

In your Arduino IDE, go to File and open the Preferences menu.

Open Arduino IDE 2 Preferences Menu Windows PC

Copy the Arduino IDE “Sketchbook location” path. In my case it’s:

C:\Users\rui_s\Documents\Arduino
Open Sketchbook Location Arduino IDE 2 Browse

Then, in your Windows PC File Explorer tab enter the sketchbook location path to open the Arduino folder (it’s usually under the Documents folder).

Browse to Arduino libraries folder to copy lv_conf.h file Arduino IDE 2

Open the libraries folder:

Open the Arduino IDE 2 Libraries Folder Windows PC

You should see the TFT_eSPI library folder there. Open it.

Open TFT_eSPI folder libraries Arduino IDE 2

You should be in a similar folder path as shown below:

C:\Users\rui_s\Documents\Arduino\libraries\TFT_eSPI

Copy the User_Setup.h file provided earlier and replace the existing file.

Move copy User_Setup.h file to TFT_eSPI library folder Arduino IDE 2

IMPORTANT: other User_Config.h available on the internet will probably NOT work with the examples available at Random Nerd Tutorials. You must use the exact User_Config.h file provided in this article.

b) Preparing the Config File – Mac OS

Having both libraries installed (TFT_eSPI and XPT2046_Touchscreen), download the User_Setup.h configuration file.

Download User_Setup.h file for TFT_eSPI library Bodmer Arduino IDE 2

In your Arduino IDE, open the Settings menu.

Open Arduino IDE 2 Preferences Menu Mac OS

Copy the Arduino IDE “Sketchbook location” path. In my case, it’s:

/Users/rui/Documents/Arduino
Open Sketchbook Location Arduino IDE 2 Browse Mac OS

In Finder, type ~/.arduinoIDE/ and open that directory.

Open the Arduino IDE 2 Folder Mac OS

Open the libraries folder.

Open the Arduino IDE 2 Libraries Folder Mac OS

You should see the TFT_eSPI library folder there. Open it.

Open TFT_eSPI folder libraries Arduino IDE 2 Mac OS

You should be in a similar folder path as shown below:

/Users/rui/Documents/Arduino/libraries/TFT_eSPI

Copy the User_Setup.h file provided earlier and replace the existing file.

Move copy User_Setup.h file to TFT_eSPI library folder Arduino IDE 2 Mac OS

You should now have the User_Setup.h file provided on that path.

Move User_Setup.h file to TFT_eSPI library folder Arduino IDE 2 Mac OS

IMPORTANT: other User_Config.h available on the internet will probably NOT work with the examples available at Random Nerd Tutorials. You must use the exact User_Config.h file provided in this article.

Code – Display Text and Testing the Touchscreen

The following code displays a simple text in your TFT display and allows you to test the touchscreen. When you press the touchscreen with your finger or pen, it should print the coordinates and pressure.

Copy the following code to the Arduino IDE and upload it to your board.

/*  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" library 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 32  // T_DIN
#define XPT2046_MISO 39  // T_OUT
#define XPT2046_CLK 25   // T_CLK
#define XPT2046_CS 33    // T_CS

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

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#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.x, 200, 3700, 1, SCREEN_WIDTH);
    y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);
    z = p.z;

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

    delay(100);
  }
}

View raw code

How the Code Works

Let’s take a quick look at the parts of the code that are relevant to this example.

Libraries

Include the SPI, TFT_eSPI and XPT2046_Touchscreen libraries.

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

Initialize TFT

Create a TFT_eSPI instance:

TFT_eSPI tft = TFT_eSPI();

Initialize Touchscreen

The following lines set the touchscreen pinout:

#define XPT2046_IRQ 36
#define XPT2046_MOSI 32
#define XPT2046_MISO 39
#define XPT2046_CLK 25
#define XPT2046_CS 33

Create a touchscreenSPI and touchscreen instances:

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

Other Variables

Set the screen width, screen height, and font size:

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

Variables to store the coordinates: (x, y) and pressure (z).

int x, y, z;

setup()

Start a serial communication with the Serial Monitor at a baud rate of 115200:

Serial.begin(115200);

Start the SPI for the touchscreen and initialize the touchscreen.

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

Note: in some displays, the touchscreen might be upside down, so you might need to set the rotation to 3: touchscreen.setRotation(3);

Start the TFT display and set the TFT display rotation in landscape mode.

tft.init();
tft.setRotation(1);

Set the TFT screen background to white. Then, set the text color to black with white background.

tft.fillScreen(TFT_WHITE);
tft.setTextColor(TFT_BLACK, TFT_WHITE);

Set X and Y coordinates for the center of the display.

int centerX = SCREEN_WIDTH / 2;
int centerY = SCREEN_HEIGHT / 2;

Display two centered welcome messages in the TFT display:

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

loop()

In the loop(), it constantly checks if the touchscreen was touched.

if (touchscreen.tirqTouched() && touchscreen.touched()) {

When it detects that the touchscreen was touched, it will get the (x,y) coordinates and the pressure (z) from the point.

TS_Point p = touchscreen.getPoint();
// Calibrate Touchscreen points with map function to the correct width and height
x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);
y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);
z = p.z;

Call the printTouchToSerial and printTouchToDisplay functions to print the touchscreen info in the Serial Monitor and TFT display.

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

printTouchToSerial()

The printTouchToSerial() function prints 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();
}

printTouchToDisplay()

The printTouchToDisplay() function prints 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);
}

Demonstration

Upload the code to your board. Go to Tools > Board and select ESP32 > ESP32 Dev Module. Then, select the right COM port in Tools > Port. Finally, click the upload button.

Arduino IDE 2 Upload Button

After uploading the code to your board, it should display the sample “Hello, world!” text centered at the top. Press the touchscreen with your finger to test it.

ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R Touchscreen Demonstration

It should print the coordinates: (x, y) and pressure (z) in the TFT display. You should note that this is a 240x320px resistive touchscreen.

ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R Touchscreen Testing

The coordinates and pressure are also printed on the your Arduino IDE serial monitor:

ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R Touchscreen Testing Arduino IDE Serial Monitor

Wrapping Up

In this tutorial, you learned how to use the ESP32 Cheap Yellow Display board, a versatile board that comes with a TFT touchscreen display, an ESP-WROOM-32 chip, all the required circuitry to power and upload code to the board, and more. This is a great board to add a graphical user interface to your projects.

If you already have a TFT Touchscreen display with ILI9341 driver, you can follow this guide to wire it directly to an ESP32 board to control it.

We hope you found this tutorial useful. We’re preparing more guides about this board, so stay tuned.

To learn more about the ESP32, make sure to take a look at our resources:



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Recommended Resources

Build a Home Automation System from Scratch » With Raspberry Pi, ESP8266, Arduino, and Node-RED.

Home Automation using ESP8266 eBook and video course » Build IoT and home automation projects.

Arduino Step-by-Step Projects » Build 25 Arduino projects with our course, even with no prior experience!

What to Read Next…


Enjoyed this project? Stay updated by subscribing our newsletter!

118 thoughts on “Getting Started with ESP32 Cheap Yellow Display Board – CYD (ESP32-2432S028R)”

  1. I would love to see some more tutorials on this board. If possible using MicroPython. Thanks for keeping me educated and up to date

    Reply
  2. I came across these boards some time ago but couldn’t find much documentation so I put them aside. About a week ago I realized that quite a lot of information has been posted since then so I got them out and started experimenting. In spite of the available data it took me many hours to get things working. Most of the examples given didn’t actually work with 2 SPI busses. I finally got it worked out a couple of days ago. I have not tried the touch library you are using yet but I know from experience that your projects work. I want to thank you for posting an article which makes it easy to use this board.

    Do you have any idea why they used different SPI busses for the display and the touch? It does not seem to have any advantage but it takes away 5 more pins and adds a further level of complexity to the sketch.

    Reply
    • I should have added that I used LovyanGFX and had a great deal of trouble figuring out how to save the touch calibration. LovyanGFX is mostly compatible with TFT_eSPI but presumably works better with 2 SPI busses. When I tried using TFT_eSPI I had a lot of conflicts – mostly because I had no idea what I was doing. I used the TFT_eSPI keypad from the demo but it insisted on using the SPI bus for TFT_eSPI to read the touch pad. Once I abandoned that and wrote my own keypad, everything started working but I had already switched to LovyanGFX.

      Reply
      • Does this article apply to ESP32-8048S050 5” smart display too?
        I intend to use as a terminal using the WiFi link, if it is possible to install VNC viewer on it!
        In this case, I only need 5V or does the capacitive touch need the usb-c connection?
        Thanks

        Reply
        • This guide only works with the ESP32-2432S028R board model. Other boards with built-in displays will require additional configurations which I don’t have at the moment.

          Reply
  3. A nifty board !

    Thanks for covering the topic so well!

    Particularly grocery discounters introduced E-Ink ESLs up to 10 inches (white, black, red).

    It would be great, if you could cover this topic also. I mean the topic of getting and using those displays. I know of some folks that got to manage utilizing those displays privately.

    A good source for the displays would be helpful and a RNT-“recipe” using them.

    Thanks

    Reply
      • Thanks for the reply. Just to mention it: Aaron Christophel is the guy that knows everything about it. However, he might have some potential left of transferring his findings to other people like you do or Bill, Andreas or Scott.

        When it comes to real, ready to use recipies for “cooking”, you are the best. You hit exactly the sweet spot and also convey trust, that it works what you talking about.

        Reply
  4. Hi ! How many pins free to use are left ? In case we need more pins, is there a shield or something ? Thanks for your answer !

    Reply
    • My board, which does not have the “R” at the end of the part number, has ground and 3 pins on one connector and a second connector with ground, positive, and 2 pins. This could be used as an I2C interface to connect a port expander. There are several 8 and 16 bit port expanders available.

      Reply
      • Has anyone ever tried to use there extended Pins and get them work?
        I am struggeling for weeks to get an propper I2C connection. I own 2 of these modules. By adding a BME280 at GPIO21 and GPIO22 and using the module internal 3.3V/GND it was killing the TFT (not working anymore!). I dont know how this can happen.
        This module has also an great issue to work with TFT an SD at same time -> SPI issue.
        I think this module is not realy good designed at the current state and needs to be hw-updated

        Reply
          • Do not use gpio 21. It is connected to tft backlight.
            I have the cud with 2 usb connectors and have had no trouble getting i2c working with Bme280.
            If you need the code let me know.

        • Just use GPIO 22 for SCL and GPIO 27 for SDA as described in ‘Use Different I2C Pins with ESP32 (change default I2C pins)’ in ‘ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals (Arduino IDE)’ .

          Reply
          • I have to agree…..I have been playing with microcontrollers for 2 months and can’t code for toffee. But read and look it is surprising what you can do with reading and tutorials like this.

  5. Apparently there are a few variations of these boards. Currently I have 2 which do not have the “R” at the end of the part number. They differ from most published images in that connector CN1 does not have an open pin. GPIO2 is connected there making this a potential I2C connector. Also, I just ordered 3 more and the product photo shows that they have a “C” USB connector in addition to the micro connector.
    Get them for $9.10 here:
    aliexpress.us/item/3256806284604156.html?spm=a2g0o.order_list.order_list_main.5.162e1802SAGoo2&gatewayAdapt=glo2usa

    Reply
    • Even though it’s not exactly the same as mine, can you try the example provided in this article? You should use the exact config file provided. Let me know if it works!

      Reply
      • As usual, your example works perfectly. I compared your user file with my non-working one. The only difference was that, in mine, the following lines were REMed out:
        379 #define SPI_TOUCH_FREQUENCY 2500000
        384 #define USE_HSPI_PORT
        On my board 379 doesn’t matter but 384 is critical. At the time I wasn’t sure if it applied to the display or the touch so I left it alone and forgot about it. The LovyanGFX library has separate settings for each. Most of the LovyanGFX documentation was in Chinese but Google Translate did a remarkable job of fixing that.

        I have noticed that there are now some very similar boards available with capacitive touch. Maybe you could consider one of them for a future project.

        Thanks again for all the work you do.

        Reply
  6. Dear Rui and Sara,
    I have been trying to get some text on this display for a month or so and I did not succeed. So I am very happy with this example. It took about a quart hour to do the setup and compile and upload the example. It works out of the box.
    Thank you and keep up the good work!

    Reply
  7. Hi Rui and Sara,

    Great job as usual !
    I have bought 2 boards somme weeks ago, and they run correctly but on both the ana input doesn’t run (light sensor). In all cases, the voltage on this input is near of Zero. do you have the same problem on yours ?
    Best regards,
    JMH

    Reply
      • Hi Rui,

        It refers to GPIO 34 where is a resistor bridge of 2 x 1 MOhoms and a photoresistor on the front of the device. See the code below (loaded from the device doc). It can be used to adjust the brightness of the screen related to the ambiant light.

        #define ANALOG_PIN_0 34

        void setup(){
        Serial.begin(115200);
        pinMode(ANALOG_PIN_0,INPUT);
        }

        void loop() {
        int analog_value = 0;
        analog_value = analogRead(ANALOG_PIN_0);
        delay(1000);
        Serial.printf(“Current Reading on Pin(%d)=%d\n”,ANALOG_PIN_0,analog_value);
        delay(3000);
        }

        Reply
  8. Are these libraries specifically for Arduino 2.3.2 or can they download to the 1.8.10 ?
    I’m guessing it’s only for the newer IDE.

    Reply
    • They should work under Arduino 1.8.X as long as you are using the exact libraries versions that I use in this blog post and you install my User_Setup.h file for the TFT_eSPI library

      Reply
  9. Thanks Rui,
    The code works well, good stuff! Thankyou..!!!
    Ive been trying to implement the touchscreen to use as a remote with ESP-Now protocol to another ESP Device for bi-directional motor control but have had no success at all so far.
    Any Ideas..?
    Maybe something to consider including for your lvgl posts…?
    Thanks again, Reece

    Reply
    • I’ve added a note in the blog post: In the Extended GPIO connectors, there are at least 4 GPIOs available: GPIO 35, GPIO 22, GPIO 21, and GPIO 27. It also has the TX/RX pins available.

      Reply
      • Hi I am quite new to microprocessors and this coding stuff but I have at least 3 of the two Usb versions. Macsbug listed above is a good source of info and I have managed to use i2c and connected various sensors with no isssues but I think that gpio 21 is tied into the screen Back light and can cause issues.
        I have successfully got Yo radio to run on these boards and also the macsbug internet radios to work.. there is alot of info on these boards on git hub and Youtube which have helped me no end. I look forward too more from yourselves as I think these boards are great without having to uses lots of leads and breadboards etch and their price is great.
        Many thanks

        Reply
        • Hi Mark,
          how did you manage the audio of Macsbug‘s internet radio through the MAX module? What pins do you use and how did you prevent clipping the audio signal at high gain?

          Reply
          • Hi hans I used the gpios as showns in maxsbug wiring diagram I soldered wires as shown. I realised later than if I have two of the 4 pin connection wires then on the two usb version there is enough GPIO to correctly wire with no soldering but have not tried that yet.
            Another project which works wonderfully is Yoradio, watch the youtube video from Daradici Levanti youtu.be/czBkxkYREG8. this explains how to do it much better radio than macshub version.
            When using external DAC sound quality is great

  10. Another great intro Rui. The CYD has a lot more power in terms of GUI than shown here. Consider using Squareline Studio to create beautiful graphic UIs. Here is a template for getting started with that: github.com/witnessmenow/ESP32-Cheap-Yellow-Display/discussions/102 Also, the designers of the CYD really dropped the ball when they picked the exposed input/output pins. There is a lack of usable ADC inputs if you are using WIFI with this board as you can only use ADC1 when using WIFI. They could have simply used other pins for the display and exposed more useful pins. As for exposed pins, if you are not using the SD card, you can bring out 4 IO pins from there. Here is a properly labeled breakout board in a kicad project that others could use. drive.google.com/drive/folders/165wcDzaYBXRDlv0eurGinze3bf3cezEy?usp=sharing

    Reply
  11. This is fantastic! Great job, as usual!

    I have been using ESP32-324S8035, which is the slightly larger option in my lab for all sorts of displays. For the life of me, I still cannot get the touch option to work no matter how I try. However, these are wonderful options for small systems nonetheless.

    I have found the source: macsbug.wordpress.com/2022/10/02/esp32-3248s035/

    To be extremely useful for those having issues. If you ever get the larger option of these, I would love to see both a tough screen tutorial such as the one provided as well as a step by step for LVGL as well as the TFT_eSPI.

    Once again, you are doing wonderful work and I feel that this site is an incredible tool.

    Reply
    • I recommend buying this exact board, it will definitely work and you’ll be able to find more examples online. I’ll personally have many guides already lined up for this board.

      We’ll also cover LVGL!

      Reply
    • Are you using the latest version of the libraries mentioned in the guide? Are you using my exact User_Setup.h in the correct TFT_eSPI folder?
      If you are using another config file, different libraries or something missing, it will not work.

      Reply
      • Hi Rui,
        yes, I use the correct library versions and I also use your version of the setup file in the correct TFT_eSPI directory.
        The card comes with a demo program which works every time I reinstall it via burn operation!! so I am sure that the card is operational….

        Ezio

        Reply
          • Hi Hans,
            sorry for the late response, but I was away for a few days, and thank you for your help.
            I redid the entire procedure step by step also following your instructions (library version, setup file, erase flash), but nothing changes !!!
            Would there be containers for power?

  12. Awesome tutorial. Very useful!
    If you could add an example of how to use TX/RX for uart to another device that would be very interesting. Also i2c.

    Reply
  13. Hello Rui,
    I have purchased an ESP32 2.8″ board (SKU DIS04028H) from elecrow and am trying to run the display. But all attempts have failed. Neither the supplied User_Setup.h nor the User_Setup.h from RandomTutorials work. Unfortunately I have not found any documentation about the GPIO ports used. Does anyone have any advice?
    Greetings Rudolf

    Reply
  14. Hello Rui,
    I have purchased an ESP32 2.8″ board (SKU DIS04028H) from elecrow and am trying to run the display.
    With the following settings in User_Setup.h the TFT works:

    #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
    #define TFT_BACKLIGHT_ON HIGH
    #define TOUCH_CS 33

    But the display flickers and it appears in quick succession:
    x = -17
    y = -15
    Pressure = 4095
    So something with

    // Touchscreen pins
    #define XPT2046_IRQ 36 // T_IRQ
    #define XPT2046_MOSI 32 // T_DIN
    #define XPT2046_MISO 39 // T_OUT
    #define XPT2046_CLK 25 // T_CLK
    #define XPT2046_CS 33 // T_CS

    is wrong?
    Greetings Rudolf

    Reply
    • Unfortunately this guide wasn’t tested with that board, so I don’t know if it will work… I also don’t have that board, so I can’t test it.
      I recommend contacting the board supplier and requesting the correct User_Setup.h file for your board.

      Reply
  15. Hello Rui,
    I used your exact code and also replaced the user_setup.h file in the correct location.
    I am using VScode and loaded the required libraries.
    I am getting a compile error on this line:
    touchscreen.begin(touchscreenSPI);

    Compiling .pio\build\az-delivery-devkit-v4\src\main.cpp.o
    src/main.cpp: In function ‘void setup()’:
    src/main.cpp:82:35: error: no matching function for call to ‘XPT2046_Touchscreen::begin(SPIClass&)’
    touchscreen.begin(touchscreenSPI);
    ^
    In file included from src/main.cpp:30:
    .pio/libdeps/az-delivery-devkit-v4/XPT2046_Touchscreen/XPT2046_Touchscreen.h:46:7: note: candidate: ‘bool XPT2046_Touchscreen::begin()’
    bool begin();
    ^~~~~
    .pio/libdeps/az-delivery-devkit-v4/XPT2046_Touchscreen/XPT2046_Touchscreen.h:46:7: note: candidate expects 0 arguments, 1 provided

    Reply
  16. Hello Rui,
    today, my original CYD board arrived and I started to explore. I first installed the needed versions of the libraries and copied User_Setup.h into the correct folder. But while compiling your code with Arduino IDE 2.3.2 I get the following error message:

    xtensa-esp32-elf-g++: error: unrecognized command line option ‘-std=gnu++2b’; did you mean ‘-std=gnu++2a’?
    exit status 1

    Compilation error: exit status 1

    What’s going wrong?
    Best regards,
    Hans

    Reply
    • Hello Hans,
      It looks like something is missing in your Arduino IDE (it doesn’t look related to the CYD project).
      Are you able to compile a blank Arduino sketch?

      void setup() {
      // put your setup code here, to run once:

      }

      void loop() {
      // put your main code here, to run repeatedly:

      }

      Reply
      • Hello Rui,

        I found the solution: I had to update my boards file for ESP32. Now it works.

        My first steps on the board after elimination the compiler error show me inverted colours. It took a while to figure out what’s going wrong. I found out that I had to edit the User_Setup.h file and had to set #define TFT_INVERSION_ON. I also edited the configuration file of the display driver ILI9341_Init.h and had to set two lines in comments to make the colours better:
        //writecommand(0xE0); //Set Gamma
        //writecommand(0XE1); //Set Gamma
        Maybe it can help others with the same problems. It seems to appear only on the board with the two USB ports.

        Best regards,
        Hans

        Reply
  17. Why do you define the width/height again:

    #define SCREEN_WIDTH 320
    #define SCREEN_HEIGHT 240

    They are already defined in the User_Setup.h as:
    #define TFT_HEIGHT 320
    #define TFT_WIDTH 240

    Is it necessary to redefine them? Or can we just use the already defined width and height from the User_Setup.h

    Reply
    • In the User_Setup.h is mandatory to have those definitions.
      However in the code, i just define them to do some math to display the text in the right coordinates, so I don’t need to always type 320 or 240 in all operations.

      Example:

      x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);
      y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);

      int centerX = SCREEN_WIDTH / 2;
      int centerY = SCREEN_HEIGHT / 2;

      Reply
  18. OMG, this is very helpfull, I need more tutorials about this DIsplay, I recently bought it, And I need to make some menu with 2 or 3 options and read 4 or 5 sensors to show them.

    Reply
    • We don’t have that planned, but the same library with this config file also works with VS Code. So, if you install the libraries and move the config file to the correct directory, it works.

      Reply
  19. My module is a 3248S035 so I’ve edited the height and width. I have X= -26 | Y= -20|
    PRESSURE = 4096 on the Serial Monitor.
    However the screen is blank and the displayed pressure and coordinates do not alter when the screen is pressed.
    Any suggestions? Also, should the library examples all work since the User_Setup.h file has been replaced? What has been edited in this file?
    Thanks

    Reply
  20. Back again. I downloaded bb_captouch library which correctly detects the GT911 IC
    for the capacitive screen. So touching the screen now shows sensible coordinates on the serial monitor.
    The TFT_eSPI programs don’t light up the screen or show any graphics.
    Any suggestions?

    Reply
  21. Nice tutorial, Maybe next possible topic could be LVGL & SquareLine Studio Together, Then wow… I assume it will blow some minds up! Hi 🙂

    Reply
  22. I have tried your sketch and it does not work on my CYD, several tft examples from other sources do. Your sketch complies OK, and loads without error, but screen remains blank when running although serial monitor output is OK. Touchscreen does not respond!

    Reply
  23. Rui/Sara;
    First of all congratulations on this and all other tutorials you have done. You are a great “teacher”. You always explain everything in detail on an easy to understand language. Thanks for you hard work.

    Reply
  24. Hello Rui,
    at first Thank you for your excellent tutorials.
    I found this branch with full CYD support: github.com/Bodmer/TFT_eSPI/tree/7c60e884afe0c5c8d97846addacd2e80ad532337
    in this branch there is the CYD fully supported. Choose from the User-Setup-Folder: Setup303_CYD_ESP32-2432S028R.h.
    I have installed the library from this branch. It is easy to use, without any addiditional Touch-cofigurations. All TFT_eSPI – Examles which use the Touch are working perfect.
    Regards Friedrich

    Reply
  25. I ran the board. Works according to the tutorial.
    Thanks.
    Then I consider using this module.
    I tried to control it using the “x” position on the screen, I connected LEDs to the outputs on the P3 and CN1 connectors, but they do not turn on. However, the blue LED on the board turns on and off. Specification of P3 and CN1 connectors needed (circuit diagram)

    //added code:
    pinMode(p22, OUTPUT); digitalWrite(p22, LOW);//2
    pinMode(p27, OUTPUT); digitalWrite(p27, LOW);//17
    pinMode(p35, OUTPUT); digitalWrite(p35, LOW);//18
    pinMode(p21, OUTPUT); digitalWrite(p21, LOW);//15

    if ((x > 100) && (x <150)) {
    digitalWrite(p22, LOW);//2
    digitalWrite(p27, LOW);//17
    digitalWrite(p35, LOW);//18
    digitalWrite(p21, LOW);//15
    }
    else {
    digitalWrite(p22, HIGH);//2
    digitalWrite(p27, HIGH);//17
    digitalWrite(p35, HIGH);//18
    digitalWrite(p21, HIGH);//15
    }
    //////////////

    Reply
  26. Again great job;
    I have a older cyd with the single mini USB connector everything works great.
    I just purchased 4 more cyd for a project and they came with both a mini USB and a USB-C connect Still Great.
    Upoaded my test code and everything worked great except all the colors are inverted put a
    tft.invertDisplay(1);
    Now every thing is fine.
    Note boards have same part number ESP32-2432E028 and a fairly comprehensive review of the board shows no diferances other than the USB-C connector.

    Reply
    • Hi Jim!
      I got same cry board as yours with USB C.
      I followed the guide grid test code but my screen is blank. Codes load ok and the RGB led blinks green .
      Any help,please?

      Reply
      • When you powered up the display the first time did the demo come up if not you probaly have a bad board.

        My experiance tells me that if you follwed the RNT guide board will work.
        With that in mind my frst step would be to try using the following to init the board
        tft.init();
        tft.invertDisplay (1);
        If that does not work I would then
        Verify you are actualy uploading code by uploading a simple sketch that outputs some form of data to the serial monitor.
        If that works my guess is a library conflict in otherwords some how you missed a step in the Guide.

        Reply
    • Hello Jim!
      I have the board same as you said and am trying to run with RUI’s test code but no luck so far.
      Serial Terminal outputs, X and Y and pressure no. but screen is still blank and black.
      Tried some suggestions from the replies in this guide but no luck.
      Any help you can suggest?

      Thanks.

      Reply
  27. Hello Rui,
    at first Thank you for your excellent tutorials.
    I found this TFT_eSPI – branch with full CYD support:
    github.com/ggaljoen/TFT_eSPI
    in this branch there is the CYD fully supported. Choose from the User-Setup-Folder: Setup303_CYD_ESP32-2432S028R.h.
    I have installed the library from this branch. It is easy to use, without any addiditional Touch-cofigurations. All TFT_eSPI – Examles which use the Touch are working perfect. Also all my Sketches with Touch for other TFT-Displays work easy with die setup without modifikations of the sketch.
    Regards Friedrich

    Reply
  28. Mine came with a connector with the wires already connected – where can I get more of these – Or at least what type of connector is it to order with…

    Reply
    • My yellow boards
      Model: ESO32-3248S035C use the following connector.

      On Amazon elechawk 1.25mm Pitch Connectors and Pre-Crimped Cables Compatible with JST Molex PicoBlade 1.25mm for Pixhawk Silicone 15cm Wire. https://a.co/d/19sonxm

      Reply
  29. I followed the guide and installed all necessary files as listed in the guide.
    Code loaded but the screen is blank.
    In the guide in RED is says to also download the user_config.h file but I could not find that.

    Any help, please?

    Thanks.

    Reply
    • Hi.
      Please read the whole instructions.
      There’s a section called “Prepare User_Setup.h Config File for TFT_eSPI Library” with the instructions for that.
      If you don’t have configured the file, it will not work.
      Regards,
      Sara

      Reply
      • I did that but it did not work.
        How to find out what type of try display my cue has?
        Mg cue does not look as your in the guide, though.

        Reply
        • You need to check the product page… If your board is different than mine, it’s very likely that it will not work. This guide was designed to work with this exact board model: ESP32-2432S028R

          Reply
          • My board shows board model: ESP32-2432S028.

            Is that will be different than with R?
            The chop says ESP32-WROOM.

  30. I followed the guide line by line and now I am getting this error.
    I am not sure how to fix this.
    Any help, please?

    In file included from C:\Users\jhuss\AppData\Local\Temp\arduino\sketches\A9CA139F159229F8678F454D4C03FA97\sketch\sketch_apr12a.ino.cpp:1:0:
    C:\Users\jhuss\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.15\cores\esp32/Arduino.h:206:12: error: ‘std::round’ has not been declared
    using std::round;
    ^

    exit status 1

    Compilation error: exit status 1

    Reply
    • Hi Javed, not sure if this will help but recently Arduino IDE updated some esperiff esp32 stuff and after that I found almost all sketches would not upload or work and I got similar error messages on every sketch.
      I looked through the core files of Arduino15 and deleted version 2.0.15 and left an older version in restarted Ide and all went back to normal.
      It keeps asking me to update my libraries but I simply ignore it and IDE now works as it did.
      The files were in C/users/user/AppData/Local/Arduino15/packages/esp32/hardware/esp32

      Reply
  31. Dear Ruis,
    I would like to thankyou and the team for all you do, I am very new to the subject and have found sources like yours are invaluable to us newbies.
    I can confirm that your code works perfectly when downloaded to the TWO USB version of the CYD.
    Some of the Tft_espi examples will not work if they require touch because tft_espi library assumes the SPI for tft and touch run on the same pins but the CYD using different Spi for screen and touch which is why your Version works perfectly.
    Regads
    Mark D

    Reply
  32. Hi, it seems some people are struggling with other types of the CYD boards in combination with visual studio code and platformio.

    I have a Sunton 5 inch 800×480 pxl screen with capacitive touch and found this library to get realy easy up and running with lvgl / platformio in visual studio code:

    Library (use library installer in platformio -> home – libraries):
    Search for ‘esp32-smartdisplay’ and install. You can find more information in the readme of this library.

    Demo app for this library: After installing the library, you can download a minimal demo project and open this project in visual studio code, compile and upload to your board:

    github.com/rzeldent/esp32-smartdisplay-demo

    Sunton HMI screens can be found here:
    nl.aliexpress.com/store/1100192306?spm=a2g0o.detail.0.0.3fc4E7t8E7t8Gw

    Google search for sunton for more information about these boards.

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.