3.2inch RPi LCD (B)
3.2 inch Resistive Touch Screen TFT LCD Designed for Raspberry Pi, Raspbian IMG Provided |
Contents
Overview
Introduction
3.2 inch Resistive Touch Screen TFT LCD is designed for Raspberry Pi, and provides Raspbian IMG.
Features
- The hardware resolution is 320 × 240.
- Resistive touch control.
- It is compatible and can be directly inserted into any version of Raspberry Pi.
- Drivers provided (works with your own Raspbian/Ubuntu/Kali and Retropie system directly).
- Support FBCP software driver, can set the software resolution and dual-screen display.
- Gold sinking process, fine carving.
Getting Started
Hardware Connection
- There are 40 pins on Raspberry Pi, but there are 26 pins on the LCD, so you should pay attention to connecting the pins to your Pi accordingly.
Install the touch driver
The RPi LCD can be driven in two ways: Method 1. install driver to your Raspbian OS. Method 2. use the Ready-to-use image file of which LCD driver was pre-installed.
Method 1. Driver installation
Please download the latest version of the image on the Raspberry Pi official website. (Raspbian/Ubuntu Mate/Kali or Retropie)
1) Download the compressed image file to the PC, and unzip it to get the .img file.
2) Connect the TF card to the PC, open the Win32DiskImager software, select the system image downloaded in step 1 and click‘Write’ to write the system image. ( How to write an image to a micro SD card for your Pi? See RPi Image Installation Guides for more details)
3) Connect the TF card to the Raspberry Pi, start the Raspberry Pi. The LCD will display after booting up, and then log in to the Raspberry Pi terminal,(You may need to connect a keyboard and HDMI LCD to Pi for driver installing, or log in remotely with SSH)
4) Then open the terminal of Raspberry Pi to install the touch driver.
Note: The Raspberry Pi must be connected to the network, or else the touch driver won’t be successfully installed.
The touch function will work after restart. For ease of use, you can set the screen orientation, see: #Screen orientation settings.
- 1. Executing apt-get upgrade will cause the LCD to fail to work properly. In this case, you need to edit the config.txt file in the SD card and delete this sentence: dtoverlay=ads7846.
- 2. Using with Raspbian-lite, the command of the touch driver installation should be:
Method 2. Using Ready-to-use image
The image file with pre-installed driver is located in the IMAGE directory of the CD, or you can download it from #Image. Extract the .7z file and you will get an .img file. Write the image to your micro SD card (How to write an image to a micro SD card for your Pi? See RPi Image Installation Guides for more details). Then insert the card to your Pi, power up and enjoy it.
Screen orientation settings
After installing the touch driver, you can modify the screen rotation direction by running the following commands.
The rotation command under Raspbian-lite is as follows:
Touch screen calibration
This LCD can be calibrated through the xinput-calibrator program. Note: The Raspberry Pi must be connected to the network, or else the program won’t be successfully installed.
- Run the following command to install:
- Click the «Menu» button on the taskbar, choose «Preference» -> «Calibrate Touchscreen».
- Finish the touch calibration following the prompts. Maybe rebooting is required to make calibration active.
- You can create a 99-calibration.conf file to save the touch parameters (not necessary if file exists).
- Save the touch parameters (may differ depending on LCD) to 99-calibration.conf, as shown in the picture:
Install Virtual Keyboard
1. Install matchbox-keyboard
2. Copy the statements below to toggle-matchbox-keyboard.sh and save.
3. Execute the commands:
4. Copy the statements to toggle-matchbox-keyboard.desktop and save.
5. Execute commands as below. Note that you need to use «Pi » user permission instead of root to execute this command
6. Find the statement which is similar to below: (It maybe different in different version)
7. Append these statements to add an button option:
8. Reboot your Raspberry Pi. If the virtual keyboard is installed correctly, you can find that there is a keyboard icon on the left of the bar
Interface
PIN NO. | SYMBOL | DESCRIPTION |
---|---|---|
1, 17 | 3.3V | Power positive (3.3V power input) |
2, 4 | 5V | Power positive (5V power input) |
3, 5, 7, 8, 10, 22 | NC | NC |
6, 9, 14, 20, 25 | GND | Ground |
11 | TP_IRQ | Touch Panel interrupt, low level while the Touch Panel detects touching |
12 | KEY1 | button |
13 | RST | Reset |
15 | LCD_RS | Command/data register selection,low level select command, high level select data. |
16 | KEY2 | button |
18 | KEY3 | button |
19 | LCD_SI / TP_SI | LCD display/SPI data input of Touch Panel |
21 | TP_SO | SPI data output of Touch Panel |
23 | LCD_SCK / TP_SCK | LCD display/SPI clock of Touch Panel |
24 | LCD_CS | LCD chip selection, low active |
26 | TP_CS | Touch Panel chip selection, low active |
Resource
User Manual
Image
Description: if you felt hard to install driver, try the image with driver pre-installed.
Adafruit PiTFT 3.5″ Touch Screen for Raspberry Pi
Resistive Touchscreen Manual Install & Calibrate
New Subscription
Please sign in to subscribe to this guide.
You will be redirected back to this guide once you sign in, and can then subscribe to this guide.
Now that the screen is working nicely, we’ll take care of the touchscreen. There’s just a bit of calibration to do, but it isn’t hard at all.
Before we start, we’ll make a udev rule for the touchscreen. That’s because the eventX name of the device will change a lot and its annoying to figure out what its called depending on whether you have a keyboard or other mouse installed.
to create a new udev file and copy & paste the following line in:
Remove and re-install the touchscreen with
sudo rmmod stmpe_ts; sudo modprobe stmpe_ts
Then type ls -l /dev/input/touchscreen
It should point to eventX where X is some number, that number will be different on different setups since other keyboards/mice/USB devices will take up an event slot
There are some tools we can use to calibrate & debug the touchscreen. Install the «event test» and «touchscreen library» packages with
sudo apt-get install evtest tslib libts-bin
Now you can use some tools such as
which will let you see touchscreen events in real time, press on the touchscreen to see the reports.
If you rotate the display you need to recalibrate the touchscreen to work with the new screen orientation. You can manually run the calibration processes in the next section, or you can re-run the installer script and select a new rotation:
If the «automagic» calibration technique isn’t working for you, or you have some other setup where you need to carefully calibrate you can do it ‘manually’
You will want to calibrate the screen once but shouldn’t have to do it more than that. We’ll begin by calibrating on the command line by running
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
follow the directions on the screen, touching each point. Using a stylus is suggested so you get a precise touch. Don’t use something metal, plastic only!
Next you can run
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_test
which will let you draw-test the touch screen. Go back and re-calibrate if you feel the screen isn’t precise enough!
You can also calibrate the X input system but you have to use a different program called xtcal (xinput_calibrator no longer works)
You can do this if the calibration on the screen isn’t to your liking or any time you change the rotate=XX module settings for the screen. Since the screen and touch driver are completely separated, the touchscreen doesn’t auto-rotate
Download and compile it with the following:
You must be running PIXEL (the GUI) while calibrating.
Before you start the calibrator you will need to ‘reset’ the old calibration data so run
DISPLAY=:0.0 xinput set-prop «stmpe-ts» ‘Coordinate Transformation Matrix’ 1 0 0 0 1 0 0 0 1
Now you’ll have to run the calibrator while also running X. You can do this by opening up the terminal program and running the the xtcal command (which is challenging to do on such a small screen) OR you can do what we do which is create an SSH/Terminal shell and then run the calibrator from the same shell, which requires the following command:
DISPLAY=:0.0 xtcal/xtcal -geometry 640×480
Note that the geometry may vary!
If you are using a 2.4″/2.8″/3.2″ 320×240 display with landscape orientation, use 640×480. If you’re in portrait, use 480×640.
If you are using a 3.5″ display with landscape, use 720×480, portrait is 480×720
Follow the directions on screen
Run sudo nano /usr/share/X11/xorg.conf.d/20-calibration.conf and copy the 9 numbers into the TransformationMatrix option so it looks like:
or whatever you got, into there.
You will want to reboot your Pi to verify you’re done
Your touchscreen is now super calibrated, hurrah!
This guide was first published on Sep 17, 2014. It was last updated on Sep 17, 2014.
This page (Resistive Touchscreen Manual Install & Calibrate) was last updated on Oct 06, 2022.