TFT display pi 3.5 inch LCDShow (lesson)
overview
This is an assembly lesson where the user extends a raspberry pi desktop to include a display driver for a TFT display[1].
We are using a goodtft/LCDShow TFT screen PCB which uses the XPT2046 chip.
The PCB plugs into the GPIO port and provides a display and a resistive touch overlay using the GPIO header pins.
There are quite a few variants of this board, and some come with a fan mount.

requisites
- you must have internet connectivity
- you need a pi W, pi 3, pi 4, or pi400 with extension card.
- you need a LCDShow compatible TFT display. It is hard to tell from an Internet purchase because some PCB are not well marked. There are several board that use the same main chip:
For the best value this lesson should be run using a raspbian Lite edition.
suppliers
- https://core-electronics.com.au/raspberry-pi-4-metal-case-with-3-5-480x320-tft-touch-screen.html
- https://www.ebay.ca/sch/i.html?_from=R40&_trksid=p2047675.m570.l1313&_nkw=3.5+inch+TFT+raspberry+pi+4&_sacat=0
hardware installation
The installation is as follows:
- follow Lesson:install raspberry_pi_OS to place a lite image on an sdcard and from settings make sure:
- to configure the pi for ssh
- to configure for WiFi
- if you forgot to configure for ssh then on the sdcard touch /boot/ssh.txt which will caused ssh to start on boot
touch /boot/ssh.txt
- if you forgot to setup WiFi then edit /rootfs/etc/wpa_supplicant/wpa_supplicant.conf and add
network={
ssid="sid"
psk="password"
}
- assemble your raspberry pi into the screen case with the four screws supplied
- if the display board has a fan, use the supplied screws to mount the fan
- attach the display PCB to the GPIO header making sure that you use the top-left most pins with nothing over-hanging.
- insert the sdcard image
- plug into the pi
- a keyboard
- a mouse
- a HDMI monitor into port 1 next to the power socket
- a network cable into eth0 socket
- connect power via the USB-C socket
prepare the system
Turn the system on.
- login to a command shell and type
sudo su -
- update the apt sources
sudo apt update
- upgrade the libraries
sudo apt upgrade
Configure ssh for remote access.
- install ssh
sudo apt install ssh -y
- initialize ssh and run it
sudo apt enable ssh sudo apt start ssh
You will need git to obtain the TFT device installation scripts
- obtain git
sudo apt install git -y
- obtain the IP address for reference
ip add
Now you are ready to remote access. If you do not have remote access you will need to use a monitor as well as a keyboard, and later on a mouse.
TFT driver
The driver installation script has been designed to work with X11 pre-installed.
Lets obtain the script and do some inspection.
- login on your pi
ssh -Y <name>@<ip-address>
- or from the keyboard.
- change to the root user to make everything easier and observe the directory
sudo su - pwd
- obtain the script from the manufacturer's website (the URL should have come in the TFT kit)
git clone https://github.com/goodtft/LCD-show.git
- inspect what happened
ls
- now just change the permission recursively (this is a short-cut hack to ensure bash/shell scripts are executable)
chmod -R 755 LCD-show
- now lets inspect the files
cd LCD-show ls -lrta
oot@raspberrypi:~/LCD-show# ls -lrta total 644 drwx------ 3 root root 4096 Aug 17 01:01 .. -rwxr-xr-x 1 root root 6520 Aug 17 01:01 README.md -rwxr-xr-x 1 root root 4019 Aug 17 01:01 PyMouse-1.0.tar.gz -rwxr-xr-x 1 root root 4367 Aug 17 01:01 NANO24-show -rwxr-xr-x 1 root root 750 Aug 17 01:01 MPI5094-show -rwxr-xr-x 1 root root 1836 Aug 17 01:01 MPI5001-show -rwxr-xr-x 1 root root 3244 Aug 17 01:01 MPI4009-show -rwxr-xr-x 1 root root 3242 Aug 17 01:01 MPI4008-show -rwxr-xr-x 1 root root 1064 Aug 17 01:01 MPI3510-show -rwxr-xr-x 1 root root 3436 Aug 17 01:01 MPI3508-show -rwxr-xr-x 1 root root 1022 Aug 17 01:01 MPI3508_480_320-show -rwxr-xr-x 1 root root 1751 Aug 17 01:01 Mouse_Key.py -rwxr-xr-x 1 root root 4200 Aug 17 01:01 MIS35-show -rwxr-xr-x 1 root root 4205 Aug 17 01:01 MHS40-show -rwxr-xr-x 1 root root 4515 Aug 17 01:01 MHS40C-show -rwxr-xr-x 1 root root 4175 Aug 17 01:01 MHS35-show -rwxr-xr-x 1 root root 4366 Aug 17 01:01 MHS35B-show -rwxr-xr-x 1 root root 4202 Aug 17 01:01 MHS32-show -rwxr-xr-x 1 root root 1409 Aug 17 01:01 MHS24-show -rwxr-xr-x 1 root root 855 Aug 17 01:01 LCD-hdmi -rwxr-xr-x 1 root root 1797 Aug 17 01:01 LCD7S-show -rwxr-xr-x 1 root root 1797 Aug 17 01:01 LCD7H-show -rwxr-xr-x 1 root root 1736 Aug 17 01:01 LCD7C-show -rwxr-xr-x 1 root root 1732 Aug 17 01:01 LCD7B-show -rwxr-xr-x 1 root root 3467 Aug 17 01:01 LCD5-show -rwxr-xr-x 1 root root 1808 Aug 17 01:01 LCD55-show -rwxr-xr-x 1 root root 4194 Aug 17 01:01 LCD35-show -rwxr-xr-x 1 root root 4200 Aug 17 01:01 LCD32-show -rwxr-xr-x 1 root root 4200 Aug 17 01:01 LCD28-show -rwxr-xr-x 1 root root 4200 Aug 17 01:01 LCD24-show -rwxr-xr-x 1 root root 4197 Aug 17 01:01 LCD24-3A+-show -rwxr-xr-x 1 root root 4768 Aug 17 01:01 LCD154-show -rwxr-xr-x 1 root root 1738 Aug 17 01:01 LCD101Y-show -rwxr-xr-x 1 root root 1843 Aug 17 01:01 LCD101TMP-show -rwxr-xr-x 1 root root 1837 Aug 17 01:01 LCD101H-show -rwxr-xr-x 1 root root 1222 Aug 17 01:01 DPI7_1024_600-show -rwxr-xr-x 1 root root 1222 Aug 17 01:01 DPI5_7_800_480-show -rwxr-xr-x 1 root root 3215 Aug 17 01:01 system_restore.sh -rwxr-xr-x 1 root root 708 Aug 17 01:01 system_config.sh -rwxr-xr-x 1 root root 3103 Aug 17 01:01 system_backup.sh -rwxr-xr-x 1 root root 6374 Aug 17 01:01 rotate.sh -rwxr-xr-x 1 root root 119448 Aug 17 01:01 python-xlib_0.23-2_all.deb drwxr-xr-x 3 root root 4096 Aug 17 01:01 etc drwxr-xr-x 2 root root 4096 Aug 17 01:01 boot -rwxr-xr-x 1 root root 117184 Aug 17 01:01 xserver-xorg-input-evdev_1%3a2.10.6-1+b1_armhf.deb -rwxr-xr-x 1 root root 41542 Aug 17 01:01 xinput-calibrator_0.7.5-1_armhf.deb drwxr-xr-x 4 root root 4096 Aug 17 01:01 usr -rwxr-xr-x 1 root root 119392 Aug 17 01:01 xserver-xorg-input-evdev_1%3a2.10.6-2_arm64.deb drwxr-xr-x 8 root root 4096 Aug 17 01:01 .git drwxr-xr-x 6 root root 4096 Aug 17 01:01 .
- lets look at system_backup.sh
oot@raspberrypi:~/LCD-show# cat system_backup.sh
#!/bin/bash
if [ ! -d "./.system_backup" ]; then
sudo mkdir ./.system_backup
fi
sudo rm -rf ./.system_backup/*
if [ -f /etc/X11/xorg.conf.d/99-calibration.conf ]; then
sudo cp -rf /etc/X11/xorg.conf.d/99-calibration.conf ./.system_backup
sudo rm -rf /etc/X11/xorg.conf.d/99-calibration.conf
fi
if [ -f /etc/X11/xorg.conf.d/40-libinput.conf ]; then
sudo cp -rf /etc/X11/xorg.conf.d/40-libinput.conf ./.system_backup
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
fi
if [ -d /etc/X11/xorg.conf.d ]; then
sudo mkdir -p ./.system_backup/xorg.conf.d
sudo rm -rf /etc/X11/xorg.conf.d
fi
result=`grep -rn "^dtoverlay=" /boot/config.txt | grep ":rotate=" | tail -n 1`
if [ $? -eq 0 ]; then
str=`echo -n $result | awk -F: '{printf $2}' | awk -F= '{printf $NF}'`
if [ -f /boot/overlays/$str-overlay.dtb ]; then
sudo cp -rf /boot/overlays/$str-overlay.dtb ./.system_backup
sudo rm -rf /boot/overlays/$str-overlay.dtb
fi
if [ -f /boot/overlays/$str.dtbo ]; then
sudo cp -rf /boot/overlays/$str.dtbo ./.system_backup
sudo rm -rf /boot/overlays/$str.dtbo
fi
fi
root_dev=`grep -oPr "root=[^\s]*" /boot/cmdline.txt | awk -F= '{printf $NF}'`
sudo cp -rf /boot/config.txt ./.system_backup
sudo cp -rf /boot/cmdline.txt ./.system_backup/
if test "$root_dev" = "/dev/mmcblk0p7";then
sudo cp -rf ./boot/config-noobs-nomal.txt /boot/config.txt
#sudo cp -rf ./usr/cmdline.txt-noobs-original /boot/cmdline.txt
else
sudo cp -rf ./boot/config-nomal.txt /boot/config.txt
#sudo cp -rf ./usr/cmdline.txt-original /boot/cmdline.txt
fi
if [ -f /usr/share/X11/xorg.conf.d/99-fbturbo.conf ]; then
sudo cp -rf /usr/share/X11/xorg.conf.d/99-fbturbo.conf ./.system_backup/
fi
sudo cp -rf ./usr/99-fbturbo.conf-original /usr/share/X11/xorg.conf.d/99-fbturbo.conf
sudo cp -rf /etc/rc.local ./.system_backup/
sudo cp -rf ./etc/rc.local-original /etc/rc.local
sudo cp -rf /etc/modules ./.system_backup/
sudo cp -rf ./etc/modules-original /etc/modules
if [ -f /etc/modprobe.d/fbtft.conf ]; then
sudo cp -rf /etc/modprobe.d/fbtft.conf ./.system_backup
sudo rm -rf /etc/modprobe.d/fbtft.conf
fi
if [ -f /etc/inittab ]; then
sudo cp -rf /etc/inittab ./.system_backup
sudo rm -rf /etc/inittab
fi
type fbcp > /dev/null 2>&1
if [ $? -eq 0 ]; then
sudo touch ./.system_backup/have_fbcp
sudo rm -rf /usr/local/bin/fbcp
fi
#type cmake > /dev/null 2>&1
#if [ $? -eq 0 ]; then
#sudo touch ./.system_backup/have_cmake
#sudo apt-get purge cmake -y 2> error_output.txt
#result=`cat ./error_output.txt`
#echo -e "\033[31m$result\033[0m"
#fi
if [ -f /usr/share/X11/xorg.conf.d/10-evdev.conf ]; then
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf ./.system_backup
sudo dpkg -P xserver-xorg-input-evdev
#sudo apt-get purge xserver-xorg-input-evdev -y 2> error_output.txt
#result=`cat ./error_output.txt`
#echo -e "\033[31m$result\033[0m"
fi
if [ -f /usr/share/X11/xorg.conf.d/45-evdev.conf ]; then
sudo cp -rf /usr/share/X11/xorg.conf.d/45-evdev.conf ./.system_backup
sudo rm -rf /usr/share/X11/xorg.conf.d/45-evdev.conf
fi
if [ -f ./.have_installed ]; then
sudo cp -rf ./.have_installed ./.system_backup
sudo rm -rf ./.have_installed
fi
- the above script has an error, it is trying to copy a file to /usr/share/X11/xorg.conf.d; see if you can find it and write a test to prevent it when /usr/share/X11/xorg.conf.d does not exist.
- save a copy of the file
cp system_backup.sh system_backup.sh.1
- prevent copy to non-existant directory
# RBH if [ -f /usr/share/X11/xorg.conf.d ]; then sudo cp -rf ./usr/99-fbturbo.conf-original /usr/share/X11/xorg.conf.d/99-fbturbo.conf fi sudo cp -rf /etc/rc.local ./.system_backup/ sudo cp -rf ./etc/rc.local-original /etc/rc.local
- now execute it
./system_backup.sh
- change to the backup directory
cd .system_backup
- inspect what the script did
root@raspberrypi:~/LCD-show/.system_backup# ls -lrta total 24 drwxr-xr-x 7 root root 4096 Aug 17 01:17 .. -rwxr-xr-x 1 root root 1785 Aug 17 01:17 config.txt -rwxr-xr-x 1 root root 103 Aug 17 01:17 cmdline.txt -rwxr-xr-x 1 root root 420 Aug 17 01:17 rc.local -rw-r--r-- 1 root root 203 Aug 17 01:17 modules drwxr-xr-x 2 root root 4096 Aug 17 01:17 .
- examine the files and the modules directory
Now we will examine the other scripts.
- go back to the installation directory
cd /root/LCD-show // or cd ..
- find the scripts
ls -lrta *.sh
root@raspberrypi:~/LCD-show# ls -lrta *.sh -rwxr-xr-x 1 root root 3215 Aug 17 01:01 system_restore.sh -rwxr-xr-x 1 root root 708 Aug 17 01:01 system_config.sh -rwxr-xr-x 1 root root 6374 Aug 17 01:01 rotate.sh -rwxr-xr-x 1 root root 3155 Aug 17 01:10 system_backup.sh
- examine the system_restore.sh
- now run it and not what happens
./system_restore.sh
driver installation
🚩Note: We are going to trial install the TFT driver without an X11 desktop!
- remote login / login to your pi and try to install the driver
sudo su - cd LCD-show
🚩Note: Control-C interrupt it as soon as you see an error.
- execute the installation script and get ready with the Control-C
./LCD35-show
- See if you can fix the error listed below (by editing the LCD35-show file):
cp: cannot create regular file '/usr/share/X11/xorg.conf.d/99-fbturbo.conf': No such file or directory
- put a test in the script to create /usr/share/X11/xorg.conf.d if it does not exist
- re-run the script to its conclusion answering y to the apt installation question. Watch your screen closely!
cd LCD-show ./LCD35-show
Your raspberry pi should now reboot. (I recorded a movie here File:Tft-boot.mov).
TA screen-shot:

advanced
Recall that the LCD-Show installation scripts assumed that there was an X11 system installed and was relying on some directories. We modified those scripts so we could run them without error.
You could choose to restore the system with the system_restore.sh script.
- What happens if you restore the system?
- What happened to your external HDMI display?
uninstall
The installation may be reverted.
- execute
cd LCD-Show sudo ./system_restore.sh
- then you should delete the directory so you can start again
desktop installation
🚩 Recall that the LCD-Show installation scripts assumed that there is an X11 system and we modified the scripts above to remove the errors, and then we tested the scripts.
This section will walk you through the installation of an LXDE desktop from a Lite installation.
🚩 Note: If you have used a desktop image on your sdcard you may skip this section.
We are going to load the LXDE desktop, because it is very light-weight.
We are also going to ensure that ssh is enabled so you will be able to remote from another computer so you can use cut-and-paste from the command-line.
🚩 If you do not have a remote terminal you will need to login with a keyboard and mouse and read your TFT screen and type instead.
LXDE
This desktop is pretty light weight. Install as follows:
- switch to root
sudo su -
- install X components
apt install xinit -y apt install xinit -y apt install lxde-core -y apt install lxterminal -y apt install lxappearance -y
- now install a display manager
apt install lightdm
- Now install local AU utf8 and region
Now re-install the TFT display again because we now have all our Xorg dependencies
cd /root/LCD-show ./LCD35-show
Try starting X; this may not work as I have trouble with the display. I then tried installing
apt install xserver-xorg-video-fbturbo * drop back to your own shell Control-D
- startx
startx
If that fails to start, then removed the fbturbo
apt purge xserver-xorg-video-fbturbo
Then startX again
statx
Problems will be logged to
/var/log/Xorg.0.log
See if you can work out what is going wrong.
result
calibration
The touch screen may require calibration[2].
- install the calibrator
cd /boot cd LCD-show sudo dpkg -i -B xinput-calibrator_0.7.5-1_armhf.deb
- modify the calibration data with that shown by the application
sudo vi /etc/X11/xorg.conf.d/99-calibration.conf
Only resistive touch screens need to be calibrated, and not the capacitive touch screens.
rotation
The screen can be rotated around the major axes in increments of 90 degrees. (I have not expanded how to do so yet. See the reference for instructions.)
screen
These notes will be adapted[3]TBA write the screen rotation notes here.
resistive touch
TBA write the resistive touch rotation notes here.
references
- ↑ LCD Wiki http://www.lcdwiki.com/3.5inch_RPi_Display
- ↑ claibration https://github.com/goodtft/LCD-show/wiki/How-to-calibrate-the-touch-screen/cf471168de560df91b41ede41d6440ecb6ef4bc1
- ↑ display direction http://www.lcdwiki.com/res/Show_Direction_and_Touch/How_to_change_display_direction-GPIO-Resistive_Touch-V1.2.pdf
Need to include lesson plan layout.




