Learn

ESP32 Cheap Yellow Display pinout: the connectors, the screen and the touch film

Beginner

Or see every lesson.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Cheap Yellow Display: hellolive0.000 s 0.00x
Click to open it in the editor
TFT_eSPI draws on the 2.8 inch screen with the board’s setup, and the RGB LED on GPIO 4, 16 and 17 lights each color on LOW.

The Cheap Yellow Display, Sunton’s ESP32-2432S028R, is a classic ESP32 on the back of a 2.8 inch 240x320 ILI9341 screen with an XPT2046 resistive touch film. Most of its GPIOs are spent on the board itself: the screen, the touch controller, an RGB LED, a light sensor, a speaker amplifier and a microSD slot. What is left comes out on three small JST connectors, P1, P3 and CN1. This page lists every pin on them, then every GPIO the board uses inside, so a sketch from a tutorial makes sense.

The circuit above is the board running in Mokxi: TFT_eSPI writes on the screen and the RGB LED cycles red, green and blue. The numbers on this page are read from the same model the simulator runs, and where Mokxi does less than the board, the page says so.

Every pin on the connectors

P1 has VIN, TX, RX and GND. P3 has GND, IO35, IO22 and IO21. CN1 has GND, IO27 and 3V3. Those are the only pins a wire can reach; everything else is wired to a part on the board. The names are the silkscreen’s, and Mokxi uses the names Wokwi’s drawing of the board gives them, so an imported project keeps its wires.

On the real board CN1 also carries IO22, the same trace as P3’s. In Mokxi, as in Wokwi’s drawing, IO22 is only on P3, and CN1 is GND, IO27 and 3V3. Touch on the chip’s own pins, the DAC and ADC2 are in the table because tutorials use them; Mokxi does not model them, and each row says so.

Cheap Yellow Display: P1, then P3, then CN1
PinGPIOWhat it can doWatch out for
VIN-The 5 V rail from USB, on P1. Put 5 V here to run the board without a cable.Not a GPIO.
TX1UART0 TX: Serial, and the USB-to-serial chip. On P1.Leave free, or uploads and the serial monitor break.
RX3UART0 RX: Serial, and the USB-to-serial chip. On P1.Leave free, or uploads and the serial monitor break.
GND-Ground. There is one on each connector: P1, P3 and CN1.-
IO2121PWM. I2C SDA (default). The screen’s backlight. On P3.Drive it LOW and the screen goes dark; I2C traffic on it flickers the backlight.
IO2222PWM. I2C SCL (default). On P3.On CN1 too on the real board; in Mokxi only on P3.
IO3535ADC1_CH7. Input only. On P3.No output driver and no internal pull-up or pull-down.
3V3-The regulator’s 3.3 V output, on CN1.Not a GPIO.
IO2727PWM. ADC2_CH7 and touch T7 on the chip (not modeled). On CN1.The usual SDA on this board, with Wire.begin(27, 22), so the backlight stays still.

The GPIOs the board uses inside

These are wired to the parts on the board, and no connector brings them out. In Mokxi no wire can reach them either. The runtime gives a sketch arduino-esp32’s jczn_2432s028r names for them: CYD_TFT_MOSI is 13, CYD_TP_CS is 33, CYD_LED_RED is 4 and CYD_LDR is 34.

The screen is on HSPI and the touch controller on lines of its own, which the tutorials drive as VSPI. The microSD slot is on VSPI’s usual pins. The light sensor, the speaker amplifier and the microSD slot are not modeled in Mokxi.

Cheap Yellow Display: the GPIOs inside the board
GPIOWired toName in the jczn_2432s028r variantNotes
2Screen DCCYD_TFT_DCStrapping pin.
12Screen MISOCYD_TFT_MISOStrapping pin. Nothing is read back here: readPixel() gives black.
13Screen MOSICYD_TFT_MOSI-
14Screen SCKCYD_TFT_SCK-
15Screen CSCYD_TFT_CSStrapping pin.
21Screen backlight, also on P3CYD_TFT_BLTFT_eSPI’s init() drives it HIGH.
ENScreen reset-The board’s reset resets the panel too, so TFT_RST is -1.
25Touch CLKCYD_TP_CLK-
32Touch DIN (MOSI)CYD_TP_MOSI-
39Touch DO (MISO)CYD_TP_MISOInput only.
33Touch CSCYD_TP_CS-
36Touch IRQCYD_TP_IRQInput only. Low while the film is pressed.
4RGB LED, redCYD_LED_REDLit when LOW.
16RGB LED, greenCYD_LED_GREENLit when LOW.
17RGB LED, blueCYD_LED_BLUELit when LOW.
0The BOOT buttonCYD_USER_BUTTONStrapping pin: low at reset waits for an upload.
34The light sensorCYD_LDRNot modeled.
26The speaker amplifierCYD_AUDIO_OUTNot modeled, nor its connector.
5microSD CSCYD_SD_SSNot modeled. Strapping pin.
18microSD SCKCYD_SD_SCKNot modeled.
19microSD MISOCYD_SD_MISONot modeled.
23microSD MOSICYD_SD_MOSINot modeled.

Power: VIN, 3V3 and GND

VIN on P1 is the 5 V rail from USB while the board is plugged in, and an input when it is not. 3V3 on CN1 is the regulator’s output, which also runs the screen, so keep what you hang on it small: a sensor, not a motor. GND is on all three connectors.

Every GPIO is 3.3 V and none is 5 V tolerant. Mokxi does not model the regulator’s limits, so a circuit that would overload the real one still runs here.

The screen and the TFT_eSPI setup

The screen is an ILI9341, 240 by 320, on HSPI: MOSI 13, MISO 12, SCK 14, CS 15 and DC 2, with the backlight on GPIO 21. Its reset is the board’s, so a driver is given -1. The CYD tutorials install a User_Setup.h for TFT_eSPI with these pins and then write sketches that name none. On a real board you copy that setup into the TFT_eSPI library folder.

In Mokxi a sketch for this board needs no User_Setup.h. If it names no TFT pins, TFT_eSPI gets the board’s setup: ILI9341_2_DRIVER, MISO 12, MOSI 13, SCLK 14, CS 15, DC 2, RST -1 and BL 21. A sketch that names its own pins keeps them.

The backlight lights unless GPIO 21 is driven LOW, so in Mokxi a pin nobody has touched leaves it on. On the real board a transistor needs the pin driven HIGH. TFT_eSPI’s init() drives it HIGH, as upstream does, so with TFT_eSPI you never notice. The panel is not read back in Mokxi: readPixel() and readRect() give black.

The touch film

The XPT2046 touch controller is not on the screen’s bus. The board wires it to GPIO 25 (CLK), 32 (DIN), 39 (DO) and 33 (CS), with its IRQ on 36. The tutorials give it a bus of its own with XPT2046_Touchscreen: SPIClass touchscreenSPI = SPIClass(VSPI);, then touchscreenSPI.begin(25, 39, 32, 33); and touchscreen.begin(touchscreenSPI);.

In Mokxi you touch the screen by pressing on it while the circuit runs. The readings are twelve bits from where your finger is on the glass, and the edges read about 200 and 3900 rather than 0 and 4095, so map() them to pixels.

The RGB LED and the buttons

The RGB LED is three LEDs from 3.3 V to GPIO 4 (red), 16 (green) and 17 (blue), so each color lights when its pin is LOW and goes out on HIGH. There is no LED_BUILTIN, as in arduino-esp32’s variant for the board.

BOOT is GPIO 0 and RST is the chip’s reset. Neither is on a connector.

Which pin should I use?

For I2C, IO27 and IO22: Wire.begin(27, 22);. Wire.begin() with no pins puts SDA on 21, which is the backlight, so the screen flickers while the bus is busy. For an analog sensor, IO35, which is ADC1 and keeps working with WiFi on; it is input only. For an output such as an LED or a relay, IO27 or IO22. For a second serial port, TX and RX are taken by Serial, so give Serial2.begin() two of the free pins.

Only ADC1 is safe in a project with WiFi, because the radio uses ADC2 on a real ESP32. Mokxi models ADC1 only, so IO27 has no analog reading here.

Questions

What are the CYD’s connectors?

P1 is VIN, TX, RX and GND. P3 is GND, IO35, IO22 and IO21. CN1 is GND, IO22, IO27 and 3V3 on the real board; in Mokxi, as in Wokwi’s drawing, CN1 is GND, IO27 and 3V3 and IO22 is on P3.

Which pins are the CYD’s screen on?

HSPI: MOSI 13, MISO 12, SCK 14, CS 15 and DC 2, with the backlight on 21 and the reset on the board’s EN. TFT_eSPI’s setup for the board is ILI9341_2_DRIVER with RST -1.

Which pins is the CYD’s touch screen on?

The XPT2046 is on CLK 25, MOSI 32, MISO 39 and CS 33, with IRQ on 36. Give it its own SPIClass(VSPI) and call `touchscreenSPI.begin(25, 39, 32, 33)`.

Which pins can I use for I2C on the Cheap Yellow Display?

IO27 for SDA and IO22 for SCL, with `Wire.begin(27, 22)`. The default SDA, 21, is the backlight.

Do I need a User_Setup.h for TFT_eSPI?

On a real board, yes: install the CYD’s setup in the TFT_eSPI library folder. In Mokxi, no: a sketch that names no TFT pins gets that setup.

Why is the RGB LED backwards?

Each color is wired from 3.3 V to its pin, so it lights when the pin is LOW. `digitalWrite(4, LOW)` turns red on.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.