2inch LCD Display CTP

I. Introduction

1.1. Product Introduction

2-inch capacitive touch screen, display driver ST7789P3, touch driver CST816D, 320×240 resolution.
This is a 2-inch capacitive touch screen driver board designed for embedded display applications, paired with a 2.0-inch TFT LCD module. It supports 320×240 resolution, color images, text, menu interfaces, and touch interaction.

The display uses the ST7789P3 driver IC, and the touch part uses the CST816D touch IC. The LCD is controlled via SPI, and the capacitive touch communicates with the host via I2C, making it easy to interface with platforms such as STM32, ESP32, Arduino, and Raspberry Pi.

1.2. Product Features

  • 2.0-inch color display with 320×240 resolution
  • Display driver IC: ST7789P3, SPI interface
  • Capacitive touch IC: CST816D, I2C interface
  • Supports 262K colors for colorful icons, buttons, and GUI
  • Onboard level shift IC, supports 3.3V and 5V operating voltage

1.3. Product Specifications

ParameterValue
Dimensions52mm × 37mm
Resolution320 × 240
Display ColorsRGB 262K
Display InterfaceSPI
Touch InterfaceI2C
Display Driver ICST7789P3
Touch Controller ICCST816D
Viewing Area40.8mm × 30.6mm
Supply Voltage3.3V / 5V

1.4. Module Resources

Control Interface: 1.25mm pitch 12P connector

②Capacitive Touch FPC Connector

③LCD Screen FPC Connector

④M2.5 SMD Copper Standoff

1.5. Pin Definition

Pin NameDescription
VCCPower Positive
GNDPower Ground
SCKSPI Clock
MOSISPI Data Output
LCD_RSTLCD Reset
LCD_DCLCD Data/Command Select
LCD_CSLCD Chip Select
LCD_BLLCD Backlight Control
TP_RSTTouch Reset
TP_SCLTouch I2C Clock
TP_SDATouch I2C Data
TP_INTTouch Interrupt

II. Usage

2.1 Hardware Description

2.1.1 Pin Definitions

Pin NameDescription
VCCPower Positive
GNDPower Ground
SCKSPI Clock Signal
MOSISPI Data Output
LCD_RSTLCD Reset Signal
LCD_DCLCD Data/Command Select
LCD_CSLCD Chip Select
LCD_BLLCD Backlight Control
TP_RSTTouch Reset Signal
TP_SCLTouch I2C Clock
TP_SDATouch I2C Data
TP_INTTouch Interrupt

2.2 Arduino Demo Code

2.2.1 Connecting to Arduino UNO

Connect the board to Arduino UNO according to the following table:

Pin NameArduino UNODescription
VCC5VPower Positive
GNDGNDPower Ground
SCKD13SPI Clock Signal
MOSID11SPI Data Output
LCD_RSTD8LCD Reset Signal
LCD_DCD9LCD Data/Command Select
LCD_CSD10LCD Chip Select
LCD_BLD6LCD Backlight Control
TP_RSTD4Touch Reset Signal
TP_SCLA5Touch I2C Clock
TP_SDAA4Touch I2C Data
TP_INTD2Touch Interrupt

2.2.2 Uploading the Code

Select the board model and port number as shown below:

After selection, click compile and upload the code to Arduino UNO.You will see the screen display lines, rectangles, filled blocks, circles, and characters, and then enter the touch function display interface.

2.3 ESP32S3 Demo Code

Connect the board to ESP32S3 according to the following table:

Pin NameESP32S3Description
VCC3V3Power Positive
GNDGNDPower Ground
SCKIO48SPI Clock Signal
MOSIIO47SPI Data Output
LCD_RSTIO12LCD Reset Signal
LCD_DCIO13LCD Data/Command Select
LCD_CSIO14LCD Chip Select
LCD_BLIO38LCD Backlight Control
TP_RSTIO6Touch Reset Signal
TP_SCLIO4Touch I2C Clock
TP_SDAIO5Touch I2C Data
TP_INTIO7Touch Interrupt
Select the board model and port number as shown below. After selection, click compile and upload the code.

2.4 Raspberry Pi Demo Code

For the Raspberry Pi Bullseye system, the example program uses wiringPi pin numbering; for the Bookworm system, it uses BCM pin numbering. Connect the board to the Raspberry Pi according to the following table.

Pin NameRaspberry Pi (BCM)Description
VCC3V3Power Positive
GNDGNDPower Ground
SCKD11SPI Clock Signal
MOSID10SPI Data Output
LCD_RSTD22LCD Reset Signal
LCD_DCD25LCD Data/Command Select
LCD_CSD8LCD Chip Select
LCD_BLD24LCD Backlight Control
TP_RSTD27Touch Reset Signal
TP_SCLD3Touch I2C Clock
TP_SDAD2Touch I2C Data
TP_INTD17Touch Interrupt

2.4.1 Installing WiringPi Library

sudo raspi-config
sudo apt-get install wiringpi
Wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb 
gpio -v # If version 2.52 appears, the installation is successful

For the Bullseye branch system, use the following commands:

git clone https://github.com/WiringPi/WiringPi
cd WiringPi 
./build 
gpio -v

# Running gpio -v will show version 2.70; if it does not appear, the installation has failed.

# If you encounter the error "ImportError: No module named 'wiringpi'" when running the Python version of the example program, please run the following command:

# For Python 2.x

pip install wiringpi

For Python 3.x

pip3 install wiringpi
# Note: If installation fails, try compiling from source:
git clone --recursive http://github.com/WiringPi/WiringPi-Python.git

Note: The --recursive option can automatically pull submodules; otherwise, you need to download them manually. Enter the newly downloaded WiringPi-Python folder and run the following commands to compile and install:

# For Python 2.x

sudo python setup.py install

# For Python 3.x

sudo python3 setup.py install

If you see the following error:# Run "sudo apt install swig" to install swig, then compile and install againsudo apt install swigsudo python3 setup.py install

2.4.2 Installing LGPIO Library

For the Bookworm system, the example program uses the lgpio library. The installation commands are as follows:

wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip 
cd lg-master
make
sudo make install

2.4.3 Running Python Demo

Enter the Python example directory:

cd /home/pi/2inch lcd display demo/raspberry pi/lgpio/python

or

cd /home/pi/2inch lcd display demo/raspberry pi/wiringpi/python
Run:
sudo python3 demo.py

2.4.4 Running C Demo

Enter the C example directory:

cd /home/pi/2inch lcd display demo/raspberry pi/lgpio/c
or
cd /home/pi/2inch lcd display demo/raspberry pi/wiringpi/c

Run:

sudo make clean
sudo mkae
sudo /.main

III. Related Links

Demo

SCH

Proture