The overview, with examples running, is on the board page.

The Cheap Yellow Display

Sunton's ESP32-2432S028R: a classic ESP32 behind a 2.8 inch 240x320 ILI9341 touch screen, and an RGB LED that lights when its pins are LOW.

What it is

The same classic ESP32 as the ESP32 DevKit V1, on the back of a yellow board that is mostly screen. The screen is an ILI9341, 240 by 320 pixels, and over it is an XPT2046 resistive touch film. A USB socket goes through a CH340 to UART0, which is the serial monitor.

Everything a first sketch needs is on the board, so a CYD project usually has no other parts and no wires at all. The screen, the touch controller and the RGB LED are wired inside the board, as on the real one. Only the JST connectors take wires.

On the real board the screen lies landscape across a landscape board. The drawing here stands the board upright, in portrait, so it fits beside a breadboard. Rotate the part to lay it landscape.

The connectors

Three JST connectors, drawn along the left edge. Their pins are named as Wokwi's drawing of the board names them, so an imported project keeps its wires.

Connector Pin GPIO Notes
P1 VIN - 5 V from USB while the board is plugged in
P1 TX 1 UART0 TX, also on the CH340
P1 RX 3 UART0 RX, also on the CH340
P1 GND - Ground
P3 GND - Ground
P3 IO35 35 Input only, ADC1
P3 IO22 22 The default I2C SCL
P3 IO21 21 The screen's backlight, and the default I2C SDA
CN1 GND - Ground
CN1 IO27 27 A free GPIO
CN1 3V3 - The regulator's 3.3 V

On the real board CN1 carries IO22 as well, the same trace as P3's. Here, as in Wokwi's drawing, IO22 is only on P3, and CN1 is GND, IO27 and 3V3.

There is no EN or RST pin on any connector: reset is the RST button. IO35 is an input only, with no pull-up or pull-down of its own.

The GPIOs inside the board

These are wired to the parts on the board and no wire can reach them. They are listed so a sketch from a tutorial makes sense.

GPIO What it is wired to
2 Screen DC
12 Screen MISO
13 Screen MOSI
14 Screen SCK
15 Screen CS
21 Screen backlight (also on P3)
EN Screen reset: the board's reset resets the panel too
25 Touch CLK
32 Touch DIN (MOSI)
39 Touch DO (MISO), input only
33 Touch CS
36 Touch IRQ, input only, low while the film is pressed
4 RGB LED, red, lit LOW
16 RGB LED, green, lit LOW
17 RGB LED, blue, lit LOW
0 The BOOT button
34 The light sensor (not modeled)
26 The speaker amplifier (not modeled)
5, 18, 19, 23 The microSD slot on VSPI (not modeled)

The runtime gives a sketch arduino-esp32's jczn_2432s028r names for all of these: CYD_TFT_MOSI is 13, CYD_TP_CS is 33, CYD_LED_RED is 4, and so on, with CYD_LED_RED_ON() and the rest for the LED. There is no LED_BUILTIN, as in that variant.

The screen

The screen is the ILI9341 part, on HSPI: MOSI 13, MISO 12, SCK 14, CS 15 and DC 2. Its reset is the board's reset, so a driver is given -1 for it.

A sketch for this board needs no User_Setup.h here. The CYD tutorials install a User_Setup.h for TFT_eSPI and then name no pins in the sketch. Mokxi has that setup built in. If the sketch names no TFT pins, TFT_eSPI gets the board's:

#define ILI9341_2_DRIVER
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#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 21
#define TFT_BACKLIGHT_ON HIGH

On a real board you install the same setup in the TFT_eSPI library folder, as the tutorials say. A sketch that names its own pins keeps them, as it would with any User_Setup.h.

#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

void setup() {
  tft.init();
  tft.setRotation(1); // landscape
  tft.fillScreen(TFT_BLACK);
  tft.drawCentreString("Hello, CYD!", 160, 30, 4);
}

The backlight is on GPIO 21. TFT_eSPI's init() turns it on, as upstream does. Here the backlight lights unless GPIO 21 is driven LOW, so a pin nobody has touched leaves it on. On the real board a transistor needs the pin driven HIGH, so set it HIGH yourself if your sketch does not use TFT_eSPI. It is on or off: it does not dim with PWM.

The panel is not read back. readPixel() and readRect() on the screen give black, because nothing answers over MISO.

The touch film

To touch the screen, press on it while the circuit runs, and drag to move your finger. Let go and the finger lifts.

The XPT2046 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, so it gets an SPI bus of its own, the way the CYD tutorials do it:

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

SPIClass touchscreenSPI = SPIClass(VSPI);
XPT2046_Touchscreen touchscreen(33, 36); // CS, IRQ

void setup() {
  touchscreenSPI.begin(25, 39, 32, 33); // CLK, MISO, MOSI, CS
  touchscreen.begin(touchscreenSPI);
  touchscreen.setRotation(1);
}

The readings are the touch TFT's: twelve bits from where your finger is on the glass. The edges read about 200 and 3900, not 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. Light two or three at once to mix them.

BOOT is GPIO 0 and RST is the chip's reset, which resets the screen too. Both are under the screen in the drawing: press one while the circuit runs to hold it down.

I2C on the connectors

Wire.begin() puts SDA on 21 and SCL on 22, as on the DevKit V1. On this board 21 is also the backlight, so I2C traffic on it flickers the screen. The CYD tutorials use IO27 and IO22 instead:

Wire.begin(27, 22); // SDA on CN1, SCL on P3

WiFi

It joins Mokxi's simulated network, with the network name and password as properties of the board. There is no radio, no 802.11 and no real internet: Simulated WiFi says what is faithful and what is not.

What is modeled

The DevKit V1 model's chip, whole: one Xtensa LX6 core, GPIO, UART0, the timers, ADC1 and LEDC PWM. The screen is the ILI9341 part and the touch film is the XPT2046 of the touch TFT part, each on the GPIOs the board wires it to. The RGB LED lights on the drawing. The board carries its own program string, so it is offered its own examples, and TFT_eSPI gets the board's setup. Sketches compile in the tab.

What is not modeled

  • The light sensor on GPIO 34.
  • The speaker amplifier on GPIO 26, and its connector.
  • The microSD slot on VSPI (GPIO 5, 18, 19 and 23).
  • CN1's second IO22: here IO22 is only on P3.
  • Reading the panel back: it gives black.
  • The second core, ADC2, the DAC, touch sensing on the chip's own pins, Bluetooth and a real radio.

Starter projects

CYD hello draws a greeting and three color blocks with TFT_eSPI, and cycles the RGB LED through red, green and blue.

CYD touch paint draws where you press the screen. Tap the colors along the top to change ink, or "clear" to wipe it.

Elsewhere