[Review / Guide] WaveShare / SainSmart 3.2 inch RPi LCD

Here is a display module for Raspberry Pi and boards with a RPi compatible GPIO header (Banana Pi, BPro…).

It features a 3.2″ inches RGB TFT with 320×240 resolution, a resistive touchpanel and 3 GPIO buttons.

It mounts directly on the GPIO header and doesn’t need any external components or cables.

It is sold $28.49 at SainSmart online store.


1- Specifications

LCD Size 3.2″ inches (display area : 66mm x 49mm)
LCD Resolution 320 x 240 RGB565
Video output SPI
Video controller ILI9341
Touch panel type Resistive
Touch panel output SPI + 1 interrupt
Touch controller Texas Instruments TSC2046
Additional features 3 GPIO buttons
Powering 3.3 / 5V via GPIO header
Size 86mm x 51mm x 25mm (including pin header extrusion)
Price / Availability $28.49 at Sainsmart

2- Pictures

20150710_170729 20150710_170744

Our little 2046 touch controller

Our little 2046 touch controller


Viewing angles are great

20150710_171436 20150710_171453

3- Pinout

Unfortunately, SainSmart doesn’t provide schematics or even pinouts. Here comes my multimeter !

Display module GPIO Raspberry Pi GPIO
LCD_RS GPIO 22 (pin 15)
LCD_CS SPI_CE0 (pin 24)
RST GPIO 27 (pin 13)
TP_IRQ GPIO 17 (pin 11)
TP_CS SPI_CE1 (pin 26)
KEY1 GPIO 18 (pin 12)
KEY2 GPIO 23 (pin 16)
KEY3 GPIO 24 (pin 18)

So, it appears it is either a real WaveShare32 display, or a perfect clone… 😎

4- Display setup

Sainsmart doesn’t provide any sources or usefull information, but the module is very easy to use.

First, install the display module on the Raspberry Pi board, and power it.

Now, install fbtft kernel with SPI DMA support.

sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update

Download waveshare overlays and copy them in /boot/overlays/.

cd /tmp
git clone https://github.com/swkim01/waveshare-dtoverlays.git
sudo cp waveshare-dtoverlays/*.dtb /boot/overlays/

Specify this overlay file in your /boot/config.txt along with activating SPI.

sudo nano /boot/config.txt

Add these 2 lines at the end of the file :


Enable console on the display

Edit /boot/cmdline.txt

sudo nano /boot/cmdline.txt

At the end of the line, add this :


This is also where you could rotate the console display, with fbcon=rotate:n where n is a different orientation (0,1,2,3)

Enable X window on the display

Edit xorg config file and change default framebuffer device (fb0) to our new framebuffer (fb1)

sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf

Change this line to fb1 :

Option          "fbdev" "/dev/fb1"

Now, reboot your Pi. Your console should show on the display.


5- Console touch calibration

Edit, 2016.02.14 : A bug in the Debian 8 « Jessie » libsdl component prevents the touchpanel to work reliably in Pygame, from the console. For a workaround, please read this blog article if you are using Debian Jessie.

Input devices get a device name which depends on the order of detection (/dev/input/eventX).

These udev rules will create a symlink /dev/input/touchscreen pointing to the touch controller device. Reloading the driver or rebooting is necessary for the change to take effect.


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


SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

Now, reboot.

In order to use the touch panel with python, X, and to calibrate it, a few packages need loading :

sudo apt-get install -y libts-bin evtest xinput python-dev python-pip
sudo pip install evdev

# install ts_test with Quit button
sudo wget -O /usr/bin/ts_test http://tronnes.org/downloads/ts_test
sudo chmod +x /usr/bin/ts_test

To calibrate the touchscreen :

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate

6- X windows touch calibration

xinput-calibrator provides a way to calibrate the touchpanel for X windows use. Install

cd /tmp
wget http://tronnes.org/downloads/xinput-calibrator_0.7.5-1_armhf.deb
sudo dpkg -i -B xinput-calibrator_0.7.5-1_armhf.deb
rm xinput-calibrator_0.7.5-1_armhf.deb

Configure xinput-calibrator to autostart with X windows.

sudo wget -O /etc/X11/Xsession.d/xinput_calibrator_pointercal https://raw.github.com/tias/xinput_calibrator/master/scripts/xinput_calibrator_pointercal.sh
echo "sudo /bin/sh /etc/X11/Xsession.d/xinput_calibrator_pointercal" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart

On first start of X windows a calibration window will be displayed.


Delete /etc/pointercal.xinput and restart X to recalibrate.


Touch panel rotation

xinput-calibrator doesn’t handle touchpanels with X/Y swapped.
If your calibration results in swapped axis, add these config files.


Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "SwapAxes"      "1"


Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "stmpe-ts"
        Option  "SwapAxes"      "1"

7- Disable screen blanking

Edit /boot/cmdline.txt and add consoleblank parameter

sudo nano /boot/cmdline.txt

add this to the end of the line :


Edit /etc/kbd/config and edit display blanking parameters

sudo nano /etc/kbd/config

Find these lines and replace the values with 0 (zero) :


8- Use the buttons

The 3 buttons are very easy to use, once pinout is found.

Here is a very simple python example :

import RPi.GPIO as GPIO


GPIO.setup(12, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)

while True:
	if(GPIO.input(12) == 0):
	print(“Button 1 pressed”)
	if(GPIO.input(16) == 0):
	print(“Button 2 pressed”)
	if(GPIO.input(18) == 0):
	print(“Button 3 pressed”)


Save it to /home/pi/buttons.py (for an example) and execute it with

python /home/pi/buttons.py

Once your are happy with your script, execute it at boot.

sudo nano /etc/rc.local

Add your script before the exit line, with a « & » to make it non-blocking :

python /home/pi/buttons.py &

You could find easily adaptable and more advanced scripts on my previous articles here and here.

9- Conclusion

This is nice little display with good view angles, a good brightness and 3 usefull buttons. It is also easy to set up, which is nice.

Sources :

A propos Captain Stouf

Spécialiste en systèmes informatiques, Développeur matériel et logiciel, Inventeur, Maker : électronique, Systems on Chip, micro-controlleurs, Internet of Things, Modélisation / Scan / Impression 3D, Imagerie...

2 réflexions au sujet de « [Review / Guide] WaveShare / SainSmart 3.2 inch RPi LCD »

Laisser un commentaire

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.