3.5-RPi-LCD-CTP
1. Introduction
The 3.5-RPi-LCD-CTP is a touch display module that communicates via SPI and I2C interfaces. It features the ST7796S display driver and GT911 touch controller, offering a 320×480 resolution, IPS high-brightness display, and responsive capacitive touch. It combines stability with visual appeal.
2. Product Specifications
📋 Specification Table
| Item | Description |
|---|---|
| Model | 3.5-RPi-LCD-CTP |
| Cover Size | 61.00 (H) × 92.44 (V) mm |
| Display Area | 49.36 (H) × 73.84 (V) mm |
| Resolution | 320 (H) x 480 (V) |
| Panel Type | IPS |
| Touch Type | Capacitive |
| Viewing Angle | 170° |
| Color Gamut | 65% NTSC |
| Brightness | 200cd/m² |
| Contrast Ratio | 1000:1 |
| Backlight Control | PWM imming |
| Refresh Rate | 60Hz |
| Power Consumption | 0.8W |
| Power Supply Voltage | 5V |
| Logic Voltage | 3.3V |
| Interfaces | Display:SPI Touch:I2C |
| Controller ICs | Display:ST7796S Touch:GT911 |
3. Pin Definition

| Pin Number | Label | Description |
|---|---|---|
| 1 | NC | No connection |
| 2, 4 | 5V | Power supply (5V) |
| 3 | TP_SDA | Touch I2C data pin |
| 5 | TP_SCL | Touch I2C clock pin |
| 6, 9, 14, 20, 25 | GND | Ground |
| 7 | TP_INT | Touch interrupt pin |
| 11 | TP_RST | Touch reset pin (active low) |
| 12 | LCD_PWM | Backlight PWM control pin |
| 13 | LCD_RST | Display reset pin (active low) |
| 15 | LCD_DC | Data/Command control pin (high for data, low for command) |
| 19 | MOSI | SPI Master Out / Slave In |
| 21 | MISO | SPI Master In / Slave Out |
| 23 | SCLK | SPI Clock |
| 24 | CE0 | SPI Chip Select (active low) |
| 16–18, 8, 10, 22, 26 | NC | No connection |
4. Product Dimensions

5. Hardware Connection
- Align and connect the module's 26-pin female header to the Raspberry Pi's 40-pin GPIO header.
- It is recommended to use copper standoffs for secure mounting to prevent looseness.

6. Software Setup
6.1. Enable SPI and I2C Interfaces
Open the terminal and execute the following commands to enable the required interfaces:
sudo raspi-config nonint do_spi 0
sudo raspi-config nonint do_i2c 0
6.2 Install Dependencies
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo apt-get install python3-spidev
sudo apt install python3-smbus2
6.3 Example Program
wget https://files.luckfox.com/wiki/Luckfox/Display/3inch5-RPi-LCD-CTP/3inch5-RPi-LCD-CTP-RPI-Demo.zip
unzip 3inch5-RPi-LCD-CTP-RPI-Demo.zip
cd 3inch5-RPi-LCD-CTP-RPI-Demo
sudo python ./main.py
7. Desktop Display Configuration for Bookworm System
Method 1: Configure Device Tree Driver (Recommended)
wget https://files.luckfox.com/wiki/Luckfox/Display/3inch5-RPi-LCD-CTP/St7796s.zip
unzip St7796s.zip
sudo cp st7796s.bin /lib/firmware/
Edit config.txt:
sudo nano /boot/firmware/config.txt
Add the following lines at the end of the [all] section:
dtparam=spi=on
dtoverlay=mipi-dbi-spi,speed=48000000
dtparam=compatible=st7796s\0panel-mipi-dbi-spi
dtparam=width=320,height=480,width-mm=49,height-mm=79
dtparam=reset-gpio=27,dc-gpio=22,backlight-gpio=18
dtoverlay=goodix,addr=0x5d
To apply changes, reboot:
sudo reboot
Method 2: Install Kernel Module and DTBO Driver
📌 Note: Bookworm system requires the official kernel version 6.6.51 or higher.
Install Driver Module
- Check the current kernel version:
uname -a
Sample output (Raspberry Pi 5):
Linux raspberrypi 6.12.47+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.47-1+rpt1 (2025-09-16) aarch64 GNU/Linux
Explanation:
-
Kernel Version: 6.12.47+rpt-rpi-2712
-
Architecture: 64bit ARM(AArch64)
- Download and install the st7796 driver module:
# Download and unzip driver files
wget https://files.luckfox.com/wiki/Luckfox/Display/3inch5-RPi-LCD-CTP/Luckfox-st7796s.zip
unzip Luckfox-st7796s.zip
cd Luckfox-st7796s
# Enter the folder for the corresponding kernel version (as in the example)
cd 6.12.47/64/rpi-2712-RPi5
# Copy the kernel module
sudo cp st7796s.ko /lib/modules/$(uname -r)/kernel/drivers
# Add the module to auto-load on boot
sudo nano /etc/modules
# Add the following line at the end of the file:
st7796s
As shown below:
Resolve kernel module dependencies:
sudo depmod -a
- Configure the device tree overlay:
cd
wget https://files.luckfox.com/wiki/Luckfox/Display/3inch5-RPi-LCD-CTP/Luckfox35CTP.dtbo
sudo cp Luckfox35CTP.dtbo /boot/overlays/
For RPi4 & RPi5
- Follow the steps above to install the driver module
- Edit the config.txt file:
sudo nano /boot/firmware/config.txt
Comment out dual-screen related configurations.
Add the following lines at the end of the**[all]**section:
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=50000
dtparam=spi=on
dtoverlay=Luckfox35CTP,fps=60,speed=48000000,rotate=90,ts_rotate_90
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2
- Create X11 Configuration File
sudo nano /etc/X11/xorg.conf.d/98-spi-screen.conf
Add the following content:
Section "Device"
Identifier "SPI Screen"
Driver "fbdev"
Option "fbdev" "/dev/fb0"
EndSection
🔧 After completing the entire process, if there is no display, try changing /dev/fb0 to /dev/fb1 and rebooting.
- Switch to the X11 Display System
sudo raspi-config nonint do_wayland W1
sudo reboot
For All Raspberry Pi Versions (Requires Bookworm Lite)
⚠️ Only applicable to the following versions:
64bit Lite
32bit Lite
- Edit the config.txt File
sudo nano /boot/firmware/config.txt
Comment out KMS and dual-display settings.
At the end of the [all] section, add the following lines:
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=50000
dtparam=spi=on
dtoverlay=Luckfox35CTP,fps=60,speed=48000000,rotate=90,ts_rotate_90
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2
- Install Required Software
# X11 Services
sudo apt-get install --no-install-recommends xserver-xorg -y
sudo apt-get install --no-install-recommends xinit -y
# Desktop Manager and GUI
sudo apt install lightdm -y
sudo apt install raspberrypi-ui-mods -y
# Git and Browser (Optional)
sudo apt install git -y
sudo apt install chromium-browser -y
# VLC Media Player (Optional)
sudo apt install vlc -y
- Download and Run the Driver
sudo apt install libraspberrypi-dev -y
sudo apt-get install unzip -y
sudo apt-get install cmake -y
# Download and build fbcp
sudo wget https://files.luckfox.com/wiki/Luckfox/Display/3inch5-RPi-LCD-CTP/Rpi-fbcp.zip
sudo unzip ./Rpi-fbcp.zip
cd rpi-fbcp/
sudo rm -rf build
sudo mkdir -m 777 ./build
cd ./build
sudo cmake ..
sudo make -j4
sudo install fbcp /usr/local/bin/fbcp
- Configure Auto-Start for startx and fbcp
- Edit the Bash Shell file:
sudo nano ~/.bashrc
Add the following to the end of the file:
if [ "$(cat /proc/device-tree/model | cut -d ' ' -f 3)" = "5" ]; then
# Configuration for RPi 5B
export FRAMEBUFFER=/dev/fb1
startx 2> /tmp/xorg_errors
else
# Configuration for non-RPi 5
export FRAMEBUFFER=/dev/fb0
startx 2> /tmp/xorg_errors
fi
- Create fbcp systemd Service
sudo nano /etc/systemd/system/fbcp.service
Add the following content:
[Unit]
Description=Framebuffer Copy for Raspberry Pi
After=network.target
[Service]
ExecStartPre=/bin/sleep 20
ExecStart=/usr/local/bin/fbcp
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
Then execute the following commands:
sudo systemctl daemon-reload
sudo systemctl enable fbcp.service
sudo systemctl start fbcp.service
- Enable CLI Auto-login
sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_wayland W1
sudo reboot
Notes
⚠️ The username must be pi, otherwise auto-login will not work properly.
🚀 Each reboot will result in a longer startup time, and SSH availability will be delayed accordingly.
8. Screen Rotation Settings
GUI Rotation
-
Open the Screen Configuration application

-
Check "Touchscreen"
-
Go to Orientation and select the desired rotation angle.

Command Line Rotation
💡 It is recommended to use this command in the Wayland environment. Applicable to Raspberry Pi OS Bookworm and above.
- Install the 'wlr-randr'' tool:
sudo apt install wlr-randr
- View available output names:
wlr-randr
Sample output (e.g., SPI-1):

- Execute the rotation command:
wlr-randr --output SPI-1 --transform 90
📝 Supported rotation parameters:
normal
90
180
270
9. Adjust the backlight
PWM dimming
- Install WiringPi
cd ~
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build
gpio -v
A successful installation will output the gpio version as shown below:

- Manually adjust the display PWM backlight
gpio -g mode 18 pwm # Occupied pins are PWM pins
gpio pwmc 100 # Set PWM clock divider
gpio -g pwm 18 0 # Darkest
gpio -g pwm 18 1023 # Brightest
gpio -g mode 18 out # Release as output
Pinctrl dimming
- Set bright screen
sudo pinctrl set 18 op dh
- Set the screen off
sudo pinctrl set 18 op dl
10. Resources
Downloads
Choose your preferred download source.
| GitHub | Google Drive |
|---|---|
| Download | Download |
Available Resources
| Resource | Directory | Description |
|---|---|---|
| 📖 User Manual | Docs/ | Product documentation and user guide. |
| 💻 Demo Code | Code/ | Demo applications and source code for Raspberry Pi. |
| 📑 Schematic | Schematic/ | Hardware schematic in PDF format. |
| 📄 Datasheets | Docs/datasheets/ | Datasheets for the display driver IC and touch controller. |
| 📐 CAD Drawings | CAD/ | 2D mechanical drawings in DXF/PDF format. |
| 🧩 3D Models | 3D Models/ | STEP models for mechanical and enclosure design. |