Complete Functional Pinout Breakdown
Display Interface (SPI – HSPI)
The TFT display communicates via the ESP32‘s HSPI (SPI1) bus. Correct configuration in the TFT_eSPI library’s User_Setup.h file is crucial. Note that GPIO 21, while listed as the backlight control, is often hardwired to be always on in many board revisions.
Touchscreen Controller (SPI – VSPI)
The resistive touchscreen uses the XPT2046 controller on the VSPI (SPI2) bus. For reliable touch functionality, ensure no other peripherals conflict with these pins.
Pro Tip: For best performance with the TFT_eSPI library, use the community-modified branch that supports dual SPI buses, allowing independent and optimized management of the display and touch controller.
microSD Card Slot (SPI – VSPI)
The microSD card shares the VSPI bus with the touchscreen but uses a separate Chip Select line. This allows both peripherals to coexist, though communication cannot happen simultaneously.
Integrated Peripherals & Indicators
-
RGB LED: This surface-mount LED is active-LOW (set pin LOW to turn ON).
-
Red: GPIO 4
-
Green: GPIO 16
-
Blue: GPIO 17
-
Light Dependent Resistor (LDR): Connected to GPIO 34 (an analog input-capable pin). Use analogRead() to measure ambient light for auto-brightness features.
-
Speaker Connector: The 2-pin JST port is driven by GPIO 26. Use PWM audio libraries or simple tone generation.
-
Buttons: BOOT is tied to GPIO 0. RST is connected to the ESP32‘s enable pin.
Maximizing Available GPIOs for Your Projects
This is the most critical section for project planning. While the ESP32 has many pins, the CYD’s design pre-assigns most. Here is a realistic analysis of your free GPIOs.
“Extended IO” Connectors (P3 & CN1)
These headers provide primary access to free pins, but with important caveats.
P3 Connector Pins:
-
GPIO 35: A free, input-only pin. Excellent for reading sensors, buttons, or digital signals. It cannot be used as an output.
-
GPIO 22: A free, versatile GPIO. Crucially, this is one of the ESP32‘s default I2C SCL pins.
-
GPIO 21: NOT FREE. This pin controls the display backlight. It will be held in a fixed state while the display is on.
CN1 Connector Pins:
-
GPIO 27: A free, versatile GPIO.
-
GPIO 22: The same pin as on P3, available here for convenience.
-
3.3V & GND: Provide power to external sensors.
The I2C Solution: Creating a Custom Bus
You cannot use the default I2C pins (GPIO 21=SDA, GPIO 22=SCL) because GPIO 21 is occupied. The solution is to define a custom I2C bus using the free pins on CN1.
#include <Wire.h>
#define CUSTOM_SDA 27
#define CUSTOM_SCL 22
void setup() {
Wire.begin(CUSTOM_SDA, CUSTOM_SCL);
}
Community-Verified Application: Users have successfully connected BME280, AHT10, HTU21D temperature/humidity sensors and DS18B20 (OneWire, using GPIO 27) to these pins, creating compact weather stations and environmental monitors.
Serial Ports: Use with Caution
The P1 connector provides GPIO 1 (TX) and GPIO 3 (RX). These are directly connected to the onboard CH340 USB-to-serial converter.
-
Primary Use: For connecting a secondary GPS module (like NEO-6M/8M). You must use a SoftwareSerial or HardwareSerial on different pins (e.g., GPIO 27 for RX, GPIO 22 for TX) to avoid conflict with USB communication.
-
Warning: As noted by many users, using P1 for other serial peripherals often interferes with programming and serial debugging. It is not generally recommended for beginner projects.
Final Tally: Truly Free GPIO Pins
After accounting for all integrated functions, you have three primary GPIOs for external components:
-
GPIO 35 (Input Only) – Read switches, analog sensors (via ADC), or digital inputs.
-
GPIO 22 (Input/Output) – Perfect for I2C SCL or general-purpose use.
-
GPIO 27 (Input/Output) – Ideal for I2C SDA, OneWire, or a simple output.
This configuration makes the CYD ideal for focused applications like sensor hubs with displays, IoT control panels, or smart clocks, rather than projects requiring dozens of outputs like large robotics.
Practical Configuration and Troubleshooting
Library and IDE Setup
-
Board Definition: In Arduino IDE or PlatformIO, select “ESP32 Dev Module.”
-
TFT_eSPI Library: This is essential. After installing, navigate to its library folder and configure the User_Setup.h file. Select the correct driver (typically ILI9341_DRIVER) and enter the pin definitions from the table above. Comment out unused drivers to save memory.
-
Touch Calibration: Use the TFT_eSPI example “TouchCalibrate” to generate accurate calibration constants for your specific screen.
Common Issues and Solutions
-
“Failed to initialize SD card”: Ensure the microSD card is formatted as FAT32 (not exFAT). Check that the SD_CS pin (GPIO 5) is correctly defined.
-
Intermittent Touch or Display Glitches: This is often a power issue. The CYD can draw significant current, especially with a bright screen and active WiFi. Use a 5V/2A power supply connected via the board’s USB-C port. Avoid powering solely from a weak computer USB port when using all features.
-
Unable to Upload Code (CH340 Driver): On Windows, you may need to install the CH340 USB driver manually. Mac and Linux typically handle it automatically.
Project Ideas and Next Steps
Given its pin constraints, the CYD excels at these applications:
-
WiFi-Enabled Sensor Display: Connect a BME280 (via I2C on GPIO 22/27) and display real-time temperature/pressure/humidity graphs, posting data to MQTT.
-
Smart Home Control Panel: Use the touchscreen as an interface to control lights or relays via MQTT or HTTP. The RGB LED provides clear status feedback.
-
Internet Radio/Audio Player: Use the speaker output with an audio shield (connected via I2C) and the microSD for storing files.
Conclusion
The ESP32 Cheap Yellow Display strikes a remarkable balance between integrated convenience and programmability. While its available GPIOs are limited, strategic use of the CN1 connector for a custom I2C bus and understanding the role of each pin unlocks its true potential. By following this pinout guide, you can avoid common pitfalls and develop efficient, reliable projects that leverage its excellent touchscreen display as the centerpiece of your IoT innovation.
Ready to start coding? Begin with the basic TFT_eSPI examples to test your display and touchscreen, then integrate sensor libraries using the custom I2C pins outlined above. The community is active—share your creations and solutions to help the next maker