3.5″ TFT Touchscreen for Raspberry Pi

I recently purchased one of these cheap 3.5″ TFT displays for the Raspberry Pi from eBay for £10 and spent many hours trawling the web trying to get it working.




This is a summary of all the steps I needed to follow from various sources.

Running the latest Debian Stretch Lite

First step is to install the Waveshare drivers:

wget http://www.waveshare.com/w/upload/9/9d/LCD-show-151020.tar.gz
tar xzvf LCD-show-151020.tar.gz
cd LCD-show
sudo ./LCD35-show

Raspberry Pi will then reboot.

Create udev rules:
sudo nano /etc/udev/rules.d/95-ads7846.rules


SUBSYSTEM==”input”, KERNEL==”event[0-9]*”, ATTRS{name}==”ADS7846*”, SYMLINK+=”input/touchscreen”

Reboot the Pi again.

Install dependencies for pygame

sudo apt-get install python-pip git libsdl-dev libsdl-image1.2-dev \
libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libportmidi-dev \
libavformat-dev libswscale-dev libjpeg-dev libfreetype6-dev \
evtest tslib libts-bin

The latest sdl libraries caused all sorts of issues with the touchscreen on Debian jessie/stretch. It works but the x/y values from the touchscreen were very intermittent.

Downgrading to sdl 1.2.15-5 fixed the issue. (More info here)

#enable wheezy package sources
echo "deb http://archive.raspbian.org/raspbian wheezy main
" > /etc/apt/sources.list.d/wheezy.list
#set stable as default package source (currently jessie)
echo "APT::Default-release \"stable\";
" > /etc/apt/apt.conf.d/10defaultRelease
#set the priority for libsdl from wheezy higher then the jessie package
echo "Package: libsdl1.2debian
Pin: release n=jessie
Pin-Priority: -10
Package: libsdl1.2debian
Pin: release n=wheezy
Pin-Priority: 900
" > /etc/apt/preferences.d/libsdl
apt-get update
apt-get -y --force-yes install libsdl1.2debian/wheezy

Once the library has been downgraded then it’s time to calibrate the touchscreen:
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 TSLIB_CALIBFILE=/etc/pointercal ts_calibrate

Follow the onscreen instructions to calibrate the TFT Screen.

Install pygame library required for python:
sudo pip install pygame

I then used the following code as an example to build a python driven menu for the Pi:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.