{"id":149234,"date":"2024-03-19T15:25:10","date_gmt":"2024-03-19T15:25:10","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=149234"},"modified":"2024-08-03T18:11:31","modified_gmt":"2024-08-03T18:11:31","slug":"cheap-yellow-display-esp32-2432s028r","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/cheap-yellow-display-esp32-2432s028r\/","title":{"rendered":"Getting Started with ESP32 Cheap Yellow Display Board &#8211; CYD (ESP32-2432S028R)"},"content":{"rendered":"\n<p>In this guide, you&#8217;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.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Getting Started with ESP32 Cheap Yellow Display Board - CYD ESP32-2432S028R\" class=\"wp-image-149764\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgray\">If you have a standalone TFT Touchscreen Display 2.8 inch with ILI9341 driver, you can follow <a href=\"https:\/\/randomnerdtutorials.com\/esp32-tft-touchscreen-display-2-8-ili9341-arduino\/\">this getting started guide<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing the ESP32 Cheap Yellow Display &#8211; CYD (ESP32-2432S028R)<\/h2>\n\n\n\n<p>The <a href=\"https:\/\/makeradvisor.com\/tools\/cyd-cheap-yellow-display-esp32-2432s028r\/\" target=\"_blank\" rel=\"noopener\" title=\"\">ESP32-2432S028R<\/a> development board has become known in the maker community as the &#8220;<em>Cheap Yellow Display<\/em>&#8221; 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.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/makeradvisor.com\/tools\/cyd-cheap-yellow-display-esp32-2432s028r\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-front.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R front\" class=\"wp-image-149592\" style=\"width:750px;height:auto\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-front.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-front.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<p>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.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1200\" height=\"609\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-back-labeled.jpg?resize=1200%2C609&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R back labeled\" class=\"wp-image-149597\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-back-labeled.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-back-labeled.jpg?resize=300%2C152&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-back-labeled.jpg?resize=1024%2C520&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-back-labeled.jpg?resize=768%2C390&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>Here&#8217;s a list of more detailed specifications of this development board:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dual-core MCU, integrated WI-FI and Bluetooth functions<\/li>\n\n\n\n<li>Frequency can reach 240MHz<\/li>\n\n\n\n<li>520KB SRAM, 448KB ROM, Flash size is 4MB<\/li>\n\n\n\n<li>Module size 50.0\u00d786.0mm<\/li>\n\n\n\n<li>Operating Voltage: 5V<\/li>\n\n\n\n<li>Power consumption: approximately 115mA<\/li>\n\n\n\n<li>Product weight: approximately 50g<\/li>\n\n\n\n<li>The module includes:\n<ul class=\"wp-block-list\">\n<li>2.8-inch color TFT display screen with ILI9341 driver chip<\/li>\n\n\n\n<li>Display resolution: 240x320px with resistive touchscreen<\/li>\n\n\n\n<li>Backlight control circuit<\/li>\n\n\n\n<li>TF card interface for external storage<\/li>\n\n\n\n<li>Serial interface<\/li>\n\n\n\n<li>Temperature and humidity sensor interface (DHT11 interface) and reserved IO port interface<\/li>\n\n\n\n<li>It can be programmed with: Arduino IDE, MicroPython, ESP-IDF<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclgray\">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).<\/p>\n\n\n\n<p class=\"rntbox rntclgray\">The RGB LED is connected to the following pins: red (GPIO 4), green (GPIO 16), and blue (GPIO 17).<\/p>\n\n\n\n<p>For more information about the Cheap Yellow Display pinout, please check the following guide:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cheap-yellow-display-cyd-pinout-esp32-2432s028r\/\">ESP32 Cheap Yellow Display (CYD) Pinout (ESP32-2432S028R)<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Where to buy?<\/strong><\/p>\n\n\n\n<p>You can click on the link below to check where to buy the ESP32 Cheap Yellow display and its price on different stores.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/cyd-cheap-yellow-display-esp32-2432s028r\/\" target=\"_blank\" rel=\"noopener\" title=\"\">ESP32-2432S028R \u2013 2.8 inch 240\u00d7320 Smart Display TFT with Touchscreen &#8211; Maker Advisor<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-libraries\">Installing Arduino Libraries<\/h2>\n\n\n\n<p>The ESP32 communicates with the TFT Display and Touchscreen using SPI communication protocol. We&#8217;ll be using the <strong>TFT_eSPI<\/strong> and <strong>XPT2046_Touchscreen<\/strong> libraries.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Installing the TFT_eSPI Library<\/h4>\n\n\n\n<p>Open your Arduino IDE and go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong>. The Library Manager should open. Search for&nbsp;<strong>TFT_eSPI<\/strong>. Select the <em>TFT_eSPI library by Bodme<\/em>r and install it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"292\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Installing-TFT_eSPI-library-Bodmer-Arduino-IDE-2.png?resize=306%2C292&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing TFT_eSPI library Bodmer Arduino IDE 2\" class=\"wp-image-149501\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Installing-TFT_eSPI-library-Bodmer-Arduino-IDE-2.png?w=306&amp;quality=100&amp;strip=all&amp;ssl=1 306w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Installing-TFT_eSPI-library-Bodmer-Arduino-IDE-2.png?resize=300%2C286&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 306px) 100vw, 306px\" \/><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Installing the XPT2046_Touchscreen Library<\/h4>\n\n\n\n<p>Open your Arduino IDE and go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong>. The Library Manager should open. Search for&nbsp;<strong>XPT2046_Touchscreen<\/strong>. Select the <em>XPT2046_Touchscreen library by Paul Stoffregen<\/em> and install it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"322\" height=\"275\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Installing-XPT2046_Touchscreen-Library-by-Paul-Stoffregen-Arduino-IDE-2.png?resize=322%2C275&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing XPT2046_Touchscreen Library by Paul Stoffregen Arduino IDE 2\" class=\"wp-image-149502\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Installing-XPT2046_Touchscreen-Library-by-Paul-Stoffregen-Arduino-IDE-2.png?w=322&amp;quality=100&amp;strip=all&amp;ssl=1 322w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Installing-XPT2046_Touchscreen-Library-by-Paul-Stoffregen-Arduino-IDE-2.png?resize=300%2C256&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 322px) 100vw, 322px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Prepare User_Setup.h Config File for TFT_eSPI Library<\/h2>\n\n\n\n<p>To properly use the TFT_eSPI library, you need a configuration file called <span class=\"rnthl rntliteral\">User_Setup.h<\/span> with the right definitions. We&#8217;ve already prepared that file so that you don&#8217;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.<\/p>\n\n\n\n<p><a href=\"#config-file-windows-pc\" title=\"\">a) Preparing the Config File &#8211; Windows PC<\/a><\/p>\n\n\n\n<p><a href=\"#config-file-mac-os\" title=\"\">b) Preparing the Config File &#8211; Mac OS<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"config-file-windows-pc\">a) Preparing the Config File &#8211; Windows PC<\/h3>\n\n\n\n<p>Having both libraries installed (<span class=\"rnthl rntliteral\">TFT_eSPI<\/span> and <span class=\"rnthl rntliteral\">XPT2046_Touchscreen<\/span>), download the <em><strong>User_Setup.h<\/strong> <\/em>configuration file.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32-TFT-Touchscreen\/raw\/main\/configs\/User_Setup.zip\" target=\"_blank\" rel=\"noopener\" title=\"\">Click here to download .zip folder<\/a> with the <strong><em>User_Setup.h<\/em><\/strong> config file (<a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/ESP32-TFT-Touchscreen\/main\/configs\/User_Setup.h\" target=\"_blank\" rel=\"noopener\" title=\"\">view raw file<\/a>)<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"168\" height=\"237\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/User_Setup-file-for-TFT_eSPI-library-Bodmer-Arduino-IDE-2.png?resize=168%2C237&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"User_Setup.h file for TFT_eSPI library Bodmer Arduino IDE 2\" class=\"wp-image-149506\"\/><\/figure><\/div>\n\n\n<p>In your Arduino IDE, go to <strong>File <\/strong>and open the <strong>Preferences<\/strong> menu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"199\" height=\"353\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Arduino-IDE-2-Preferences-Menu-Windows-PC.png?resize=199%2C353&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open Arduino IDE 2 Preferences Menu Windows PC\" class=\"wp-image-149504\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Arduino-IDE-2-Preferences-Menu-Windows-PC.png?w=199&amp;quality=100&amp;strip=all&amp;ssl=1 199w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Arduino-IDE-2-Preferences-Menu-Windows-PC.png?resize=169%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 169w\" sizes=\"(max-width: 199px) 100vw, 199px\" \/><\/figure><\/div>\n\n\n<p>Copy the Arduino IDE &#8220;<strong>Sketchbook location<\/strong>&#8221; path. In my case it&#8217;s:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\Users\\rui_s\\Documents\\Arduino<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"783\" height=\"485\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse.png?resize=783%2C485&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open Sketchbook Location Arduino IDE 2 Browse\" class=\"wp-image-149503\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse.png?w=783&amp;quality=100&amp;strip=all&amp;ssl=1 783w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse.png?resize=300%2C186&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse.png?resize=768%2C476&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/figure><\/div>\n\n\n<p>Then, in your Windows PC File Explorer tab enter the sketchbook location path to open the Arduino folder (it&#8217;s usually under the <em>Documents <\/em>folder).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"448\" height=\"91\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Browse-to-Arduino-libraries-folder-to-copy-lv_conf-file-Arduino-IDE-2.png?resize=448%2C91&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Browse to Arduino libraries folder to copy lv_conf.h file Arduino IDE 2\" class=\"wp-image-149508\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Browse-to-Arduino-libraries-folder-to-copy-lv_conf-file-Arduino-IDE-2.png?w=448&amp;quality=100&amp;strip=all&amp;ssl=1 448w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Browse-to-Arduino-libraries-folder-to-copy-lv_conf-file-Arduino-IDE-2.png?resize=300%2C61&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/figure><\/div>\n\n\n<p>Open the <em>libraries <\/em>folder:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"357\" height=\"69\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Windows-PC.png?resize=357%2C69&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open the Arduino IDE 2 Libraries Folder Windows PC\" class=\"wp-image-149507\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Windows-PC.png?w=357&amp;quality=100&amp;strip=all&amp;ssl=1 357w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Windows-PC.png?resize=300%2C58&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 357px) 100vw, 357px\" \/><\/figure><\/div>\n\n\n<p>You should see the <em>TFT_eSPI <\/em>library folder there. Open it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"556\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-TFT_eSPI-folder-libraries-Arduino-IDE-2.png?resize=750%2C556&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open TFT_eSPI folder libraries Arduino IDE 2\" class=\"wp-image-149514\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-TFT_eSPI-folder-libraries-Arduino-IDE-2.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-TFT_eSPI-folder-libraries-Arduino-IDE-2.png?resize=300%2C222&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>You should be in a similar folder path as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\Users\\rui_s\\Documents\\Arduino\\libraries\\TFT_eSPI<\/code><\/pre>\n\n\n\n<p>Copy the <em>User_Setup.h<\/em> file provided earlier and <strong>replace<\/strong> the existing file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"948\" height=\"920\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2.png?resize=948%2C920&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Move copy User_Setup.h file to TFT_eSPI library folder Arduino IDE 2\" class=\"wp-image-149509\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2.png?w=948&amp;quality=100&amp;strip=all&amp;ssl=1 948w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2.png?resize=300%2C291&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2.png?resize=768%2C745&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 948px) 100vw, 948px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntcred\"><strong>IMPORTANT:<\/strong> other <em>User_Setup.h<\/em> available on the internet will probably NOT work with the examples available at Random Nerd Tutorials. You must use the exact <em>User_Setup.h<\/em> file provided in this article.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"config-file-mac-os\">b) Preparing the Config File &#8211; Mac OS<\/h3>\n\n\n\n<p>Having both libraries installed (<span class=\"rnthl rntliteral\">TFT_eSPI<\/span> and <span class=\"rnthl rntliteral\">XPT2046_Touchscreen<\/span>), download the <strong>User_Setup.h<\/strong> configuration file.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32-TFT-Touchscreen\/raw\/main\/configs\/User_Setup.zip\" target=\"_blank\" rel=\"noopener\" title=\"\">Click here to download .zip folder<\/a> with the <strong><em>User_Setup.h<\/em><\/strong> config file (<a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/ESP32-TFT-Touchscreen\/main\/configs\/User_Setup.h\" target=\"_blank\" rel=\"noopener\" title=\"\">view raw file<\/a>)<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"221\" height=\"45\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Download-User_Setup-file-for-TFT_eSPI-library-Bodmer-Arduino-IDE-2.png?resize=221%2C45&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Download User_Setup.h file for TFT_eSPI library Bodmer Arduino IDE 2\" class=\"wp-image-149519\"\/><\/figure><\/div>\n\n\n<p>In your Arduino IDE, open the <strong>Settings <\/strong>menu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"446\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Arduino-IDE-2-Preferences-Menu-Mac-OS.png?resize=398%2C446&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open Arduino IDE 2 Preferences Menu Mac OS\" class=\"wp-image-149524\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Arduino-IDE-2-Preferences-Menu-Mac-OS.png?w=398&amp;quality=100&amp;strip=all&amp;ssl=1 398w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Arduino-IDE-2-Preferences-Menu-Mac-OS.png?resize=268%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 268w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/figure><\/div>\n\n\n<p>Copy the Arduino IDE &#8220;<strong>Sketchbook location<\/strong>&#8221; path. In my case, it&#8217;s:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/Users\/rui\/Documents\/Arduino<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"461\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse-Mac-OS.png?resize=750%2C461&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open Sketchbook Location Arduino IDE 2 Browse Mac OS\" class=\"wp-image-149525\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse-Mac-OS.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-Sketchbook-Location-Arduino-IDE-2-Browse-Mac-OS.png?resize=300%2C184&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>In Finder, type <em>\/Users\/rui\/Documents\/Arduino<\/em> and open that directory.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"47\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Folder-Mac-OS.png?resize=350%2C47&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open the Arduino IDE 2 Folder Mac OS\" class=\"wp-image-149527\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Folder-Mac-OS.png?w=350&amp;quality=100&amp;strip=all&amp;ssl=1 350w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Folder-Mac-OS.png?resize=300%2C40&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/figure><\/div>\n\n\n<p>Open the <em>libraries <\/em>folder.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"247\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Mac-OS.png?resize=900%2C247&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open the Arduino IDE 2 Libraries Folder Mac OS\" class=\"wp-image-149528\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Mac-OS.png?w=900&amp;quality=100&amp;strip=all&amp;ssl=1 900w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Mac-OS.png?resize=300%2C82&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-the-Arduino-IDE-2-Libraries-Folder-Mac-OS.png?resize=768%2C211&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/figure><\/div>\n\n\n<p>You should see the <em>TFT_eSPI <\/em>library folder there. Open it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"217\" height=\"40\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Open-TFT_eSPI-folder-libraries-Arduino-IDE-2-Mac-OS.png?resize=217%2C40&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open TFT_eSPI folder libraries Arduino IDE 2 Mac OS\" class=\"wp-image-149526\"\/><\/figure><\/div>\n\n\n<p>You should be in a similar folder path as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/Users\/rui\/Documents\/Arduino\/libraries\/TFT_eSPI<\/code><\/pre>\n\n\n\n<p>Copy the <em>User_Setup.h<\/em> file provided earlier and <strong>replace<\/strong> the existing file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"395\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2-Mac-OS.png?resize=750%2C395&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Move copy User_Setup.h file to TFT_eSPI library folder Arduino IDE 2 Mac OS\" class=\"wp-image-149521\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2-Mac-OS.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-copy-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2-Mac-OS.png?resize=300%2C158&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>You should now have the <em>User_Setup.h<\/em> file provided on that path.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"378\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2-Mac-OS.png?resize=750%2C378&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Move User_Setup.h file to TFT_eSPI library folder Arduino IDE 2 Mac OS\" class=\"wp-image-149523\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2-Mac-OS.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Move-User_Setup-file-to-TFT_eSPI-library-folder-Arduino-IDE-2-Mac-OS.png?resize=300%2C151&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntcred\"><strong>IMPORTANT:<\/strong> other <em>User_Setup.h<\/em> available on the internet will probably NOT work with the examples available at Random Nerd Tutorials. You must use the exact <em>User_Setup.h<\/em> file provided in this article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code &#8211; Display Text and Testing the Touchscreen<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Copy the following code to the Arduino IDE and upload it to your board.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n    THIS EXAMPLE WAS TESTED WITH THE FOLLOWING HARDWARE:\n    1) ESP32-2432S028R 2.8 inch 240\u00d7320 also known as the Cheap Yellow Display (CYD): https:\/\/makeradvisor.com\/tools\/cyd-cheap-yellow-display-esp32-2432s028r\/\n      SET UP INSTRUCTIONS: https:\/\/RandomNerdTutorials.com\/cyd\/\n    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\/\n      SET UP INSTRUCTIONS: https:\/\/RandomNerdTutorials.com\/esp32-tft\/\n    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\n    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*\/\n\n#include &lt;SPI.h&gt;\n\n\/*  Install the &quot;TFT_eSPI&quot; library by Bodmer to interface with the TFT Display - https:\/\/github.com\/Bodmer\/TFT_eSPI\n    *** IMPORTANT: User_Setup.h available on the internet will probably NOT work with the examples available at Random Nerd Tutorials ***\n    *** YOU MUST USE THE User_Setup.h FILE PROVIDED IN THE LINK BELOW IN ORDER TO USE THE EXAMPLES FROM RANDOM NERD TUTORIALS ***\n    FULL INSTRUCTIONS AVAILABLE ON HOW CONFIGURE THE LIBRARY: https:\/\/RandomNerdTutorials.com\/cyd\/ or https:\/\/RandomNerdTutorials.com\/esp32-tft\/   *\/\n#include &lt;TFT_eSPI.h&gt;\n\n\/\/ Install the &quot;XPT2046_Touchscreen&quot; library by Paul Stoffregen to use the Touchscreen - https:\/\/github.com\/PaulStoffregen\/XPT2046_Touchscreen\n\/\/ Note: this library doesn't require further configuration\n#include &lt;XPT2046_Touchscreen.h&gt;\n\nTFT_eSPI tft = TFT_eSPI();\n\n\/\/ Touchscreen pins\n#define XPT2046_IRQ 36   \/\/ T_IRQ\n#define XPT2046_MOSI 32  \/\/ T_DIN\n#define XPT2046_MISO 39  \/\/ T_OUT\n#define XPT2046_CLK 25   \/\/ T_CLK\n#define XPT2046_CS 33    \/\/ T_CS\n\nSPIClass touchscreenSPI = SPIClass(VSPI);\nXPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);\n\n#define SCREEN_WIDTH 320\n#define SCREEN_HEIGHT 240\n#define FONT_SIZE 2\n\n\/\/ Touchscreen coordinates: (x, y) and pressure (z)\nint x, y, z;\n\n\/\/ Print Touchscreen info about X, Y and Pressure (Z) on the Serial Monitor\nvoid printTouchToSerial(int touchX, int touchY, int touchZ) {\n  Serial.print(&quot;X = &quot;);\n  Serial.print(touchX);\n  Serial.print(&quot; | Y = &quot;);\n  Serial.print(touchY);\n  Serial.print(&quot; | Pressure = &quot;);\n  Serial.print(touchZ);\n  Serial.println();\n}\n\n\/\/ Print Touchscreen info about X, Y and Pressure (Z) on the TFT Display\nvoid printTouchToDisplay(int touchX, int touchY, int touchZ) {\n  \/\/ Clear TFT screen\n  tft.fillScreen(TFT_WHITE);\n  tft.setTextColor(TFT_BLACK, TFT_WHITE);\n\n  int centerX = SCREEN_WIDTH \/ 2;\n  int textY = 80;\n \n  String tempText = &quot;X = &quot; + String(touchX);\n  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);\n\n  textY += 20;\n  tempText = &quot;Y = &quot; + String(touchY);\n  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);\n\n  textY += 20;\n  tempText = &quot;Pressure = &quot; + String(touchZ);\n  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);\n}\n\nvoid setup() {\n  Serial.begin(115200);\n\n  \/\/ Start the SPI for the touchscreen and init the touchscreen\n  touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);\n  touchscreen.begin(touchscreenSPI);\n  \/\/ Set the Touchscreen rotation in landscape mode\n  \/\/ Note: in some displays, the touchscreen might be upside down, so you might need to set the rotation to 3: touchscreen.setRotation(3);\n  touchscreen.setRotation(1);\n\n  \/\/ Start the tft display\n  tft.init();\n  \/\/ Set the TFT display rotation in landscape mode\n  tft.setRotation(1);\n\n  \/\/ Clear the screen before writing to it\n  tft.fillScreen(TFT_WHITE);\n  tft.setTextColor(TFT_BLACK, TFT_WHITE);\n  \n  \/\/ Set X and Y coordinates for center of display\n  int centerX = SCREEN_WIDTH \/ 2;\n  int centerY = SCREEN_HEIGHT \/ 2;\n\n  tft.drawCentreString(&quot;Hello, world!&quot;, centerX, 30, FONT_SIZE);\n  tft.drawCentreString(&quot;Touch screen to test&quot;, centerX, centerY, FONT_SIZE);\n}\n\nvoid loop() {\n  \/\/ Checks if Touchscreen was touched, and prints X, Y and Pressure (Z) info on the TFT display and Serial Monitor\n  if (touchscreen.tirqTouched() &amp;&amp; touchscreen.touched()) {\n    \/\/ Get Touchscreen points\n    TS_Point p = touchscreen.getPoint();\n    \/\/ Calibrate Touchscreen points with map function to the correct width and height\n    x = map(p.x, 200, 3700, 1, SCREEN_WIDTH);\n    y = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);\n    z = p.z;\n\n    printTouchToSerial(x, y, z);\n    printTouchToDisplay(x, y, z);\n\n    delay(100);\n  }\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32-TFT-Touchscreen\/raw\/main\/examples\/ESP32_TFT_Touchscreen_Basic\/ESP32_TFT_Touchscreen_Basic.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works<\/h2>\n\n\n\n<p>Let&#8217;s take a quick look at the parts of the code that are relevant to this example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Libraries<\/h3>\n\n\n\n<p>Include the <span class=\"rnthl rntliteral\">SPI<\/span>, <span class=\"rnthl rntliteral\">TFT_eSPI<\/span> and <span class=\"rnthl rntliteral\">XPT2046_Touchscreen<\/span> libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;SPI.h&gt;\n#include &lt;TFT_eSPI.h&gt;\n#include &lt;XPT2046_Touchscreen.h&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Initialize TFT<\/h3>\n\n\n\n<p>Create a <span class=\"rnthl rntliteral\">TFT_eSPI<\/span> instance:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TFT_eSPI tft = TFT_eSPI();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Initialize Touchscreen<\/h3>\n\n\n\n<p>The following lines set the touchscreen pinout:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define XPT2046_IRQ 36\n#define XPT2046_MOSI 32\n#define XPT2046_MISO 39\n#define XPT2046_CLK 25\n#define XPT2046_CS 33<\/code><\/pre>\n\n\n\n<p>Create a <span class=\"rnthl rntliteral\">touchscreenSPI<\/span> and <span class=\"rnthl rntliteral\">touchscreen<\/span> instances:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>SPIClass touchscreenSPI = SPIClass(VSPI);\nXPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Other Variables<\/h3>\n\n\n\n<p>Set the screen width, screen height, and font size:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define SCREEN_WIDTH 320\n#define SCREEN_HEIGHT 240\n#define FONT_SIZE 2<\/code><\/pre>\n\n\n\n<p>Variables to store the coordinates: (x, y) and pressure (z).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>int x, y, z;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">setup()<\/h3>\n\n\n\n<p>Start a serial communication with the Serial Monitor at a baud rate of 115200:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Start the SPI for the touchscreen and initialize the touchscreen.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>touchscreenSPI.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);\ntouchscreen.begin(touchscreenSPI);\ntouchscreen.setRotation(1);<\/code><\/pre>\n\n\n\n<p class=\"rntbox rntclgray\"><strong>Note:<\/strong> in some displays, the touchscreen might be upside down, so you might need to set the rotation to 3: <span class=\"rnthl rntliteral\">touchscreen.setRotation(3);<\/span><\/p>\n\n\n\n<p>Start the TFT display and set the TFT display rotation in landscape mode.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>tft.init();\ntft.setRotation(1);<\/code><\/pre>\n\n\n\n<p>Set the TFT screen background to white. Then, set the text color to black with white background.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>tft.fillScreen(TFT_WHITE);\ntft.setTextColor(TFT_BLACK, TFT_WHITE);<\/code><\/pre>\n\n\n\n<p>Set X and Y coordinates for the center of the display.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>int centerX = SCREEN_WIDTH \/ 2;\nint centerY = SCREEN_HEIGHT \/ 2;<\/code><\/pre>\n\n\n\n<p>Display two centered welcome messages in the TFT display:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>tft.drawCentreString(\"Hello, world!\", centerX, 30, FONT_SIZE);\ntft.drawCentreString(\"Touch screen to test\", centerX, centerY, FONT_SIZE);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">loop()<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, it constantly checks if the touchscreen was touched.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (touchscreen.tirqTouched() &amp;&amp; touchscreen.touched()) {<\/code><\/pre>\n\n\n\n<p>When it detects that the touchscreen was touched, it will get the (x,y) coordinates and the pressure (z) from the point.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>TS_Point p = touchscreen.getPoint();\n\/\/ Calibrate Touchscreen points with map function to the correct width and height\nx = map(p.x, 200, 3700, 1, SCREEN_WIDTH);\ny = map(p.y, 240, 3800, 1, SCREEN_HEIGHT);\nz = p.z;<\/code><\/pre>\n\n\n\n<p>Call the <span class=\"rnthl rntliteral\">printTouchToSerial<\/span> and <span class=\"rnthl rntliteral\">printTouchToDisplay<\/span> functions to print the touchscreen info in the Serial Monitor and TFT display.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>printTouchToSerial(x, y, z);\nprintTouchToDisplay(x, y, z);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">printTouchToSerial()<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">printTouchToSerial()<\/span> function prints touchscreen info about X, Y, and Pressure (Z) on the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void printTouchToSerial(int touchX, int touchY, int touchZ) {\n  Serial.print(\"X = \");\n  Serial.print(touchX);\n  Serial.print(\" | Y = \");\n  Serial.print(touchY);\n  Serial.print(\" | Pressure = \");\n  Serial.print(touchZ);\n  Serial.println();\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">printTouchToDisplay()<\/h3>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">printTouchToDisplay()<\/span> function prints touchscreen info about X, Y, and Pressure (Z) on the TFT Display.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void printTouchToDisplay(int touchX, int touchY, int touchZ) {\n  \/\/ Clear TFT screen\n  tft.fillScreen(TFT_WHITE);\n  tft.setTextColor(TFT_BLACK, TFT_WHITE);\n\n  int centerX = SCREEN_WIDTH \/ 2;\n  int textY = 80;\n \n  String tempText = \"X = \" + String(touchX);\n  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);\n\n  textY += 20;\n  tempText = \"Y = \" + String(touchY);\n  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);\n\n  textY += 20;\n  tempText = \"Pressure = \" + String(touchZ);\n  tft.drawCentreString(tempText, centerX, textY, FONT_SIZE);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>Upload the code to your board. Go to <strong>Tools <\/strong>&gt; <strong>Board <\/strong>and select <strong>ESP32 <\/strong>&gt; <strong>ESP32 Dev Module<\/strong>. Then, select the right COM port in <strong>Tools <\/strong>&gt; <strong>Port<\/strong>. Finally, click the upload button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"36\" height=\"39\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/05\/arduino-ide-2-upload-button.png?resize=36%2C39&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE 2 Upload Button\" class=\"wp-image-146269\" style=\"width:36px;height:auto\"\/><\/figure><\/div>\n\n\n<p>After uploading the code to your board, it should display the sample &#8220;Hello, world!&#8221; text centered at the top. Press the touchscreen with your finger to test it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Demonstration.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R Touchscreen Demonstration\" class=\"wp-image-149593\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Demonstration.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Demonstration.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>It should print the coordinates: (x, y) and pressure (z) in the TFT display. You should note that this is a 240x320px resistive touchscreen.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R Touchscreen Testing\" class=\"wp-image-149594\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The coordinates and pressure are also printed on the your Arduino IDE serial monitor:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"291\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing-Arduino-IDE-Serial-Monitor.png?resize=784%2C291&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Cheap Yellow Display CYD Board ESP32-2432S028R Touchscreen Testing Arduino IDE Serial Monitor\" class=\"wp-image-149601\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing-Arduino-IDE-Serial-Monitor.png?w=784&amp;quality=100&amp;strip=all&amp;ssl=1 784w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing-Arduino-IDE-Serial-Monitor.png?resize=300%2C111&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/ESP32-Cheap-Yellow-Display-CYD-Board-ESP32-2432S028R-Touchscreen-Testing-Arduino-IDE-Serial-Monitor.png?resize=768%2C285&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 784px) 100vw, 784px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>If you already have a <a href=\"https:\/\/randomnerdtutorials.com\/esp32-tft-touchscreen-display-2-8-ili9341-arduino\/\">TFT Touchscreen display<\/a> with ILI9341 driver, you can <a href=\"https:\/\/randomnerdtutorials.com\/esp32-tft-touchscreen-display-2-8-ili9341-arduino\/\">follow this guide to wire it directly to an ESP32 board<\/a> to control it.<\/p>\n\n\n\n<p>We hope you found this tutorial useful. Here&#8217;s a list of other projects\/tutorials you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/touchscreen-on-off-button-cheap-yellow-display-esp32-2432s028r\/\">ESP32 Touchscreen On\/Off Button \u2013 Cheap Yellow Display (ESP32-2432S028R)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/lvgl-cheap-yellow-display-esp32-2432s028r\/\">LVGL with ESP32 Cheap Yellow Display Board (ESP32-2432S028R)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cheap-yellow-display-cyd-pinout-esp32-2432s028r\/\">ESP32 Cheap Yellow Display (CYD) Pinout (ESP32-2432S028R)<\/a><\/li>\n<\/ul>\n\n\n\n<p>To learn more about the ESP32, make sure to take a look at our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (eBook)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/smart-home-ebook\/\" title=\"\">SMART HOME with Raspberry Pi, ESP32, and ESP8266 eBook<\/a><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/learn-lvgl-esp32-ebook\/\">Learn LVGL: Build GUIs for ESP32 Projects (eBook)<\/a><\/strong><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\" title=\"\"><strong>Free ESP32 Guides and Tutorials<\/strong><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you&#8217;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 &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Getting Started with ESP32 Cheap Yellow Display Board &#8211; CYD (ESP32-2432S028R)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/cheap-yellow-display-esp32-2432s028r\/#more-149234\" aria-label=\"Read more about Getting Started with ESP32 Cheap Yellow Display Board &#8211; CYD (ESP32-2432S028R)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":149764,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,299,264],"tags":[],"class_list":["post-149234","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Getting-Started-ESP32-Cheap-Yellow-Display-Board-ESP32-2432S028R.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/149234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=149234"}],"version-history":[{"count":31,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/149234\/revisions"}],"predecessor-version":[{"id":161364,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/149234\/revisions\/161364"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/149764"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=149234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=149234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=149234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}