2.8inch RPi LCD (A)

From Waveshare Wiki
Jump to: navigation, search
2.8inch RPi LCD (A)
2.8inch-RPi-LCD-A

Resistive Touch Screen TFT LCD for RPi, 320 × 240, RPi I/Os
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Features

  • 320 x 240 hardware resolution
  • Resistive touch control
  • Compatible with any version of Raspberry Pi and plugged directly into it
  • Provides drivers (supporting Raspberry Pi OS\Ubuntu\Kali and Retropie systems)
  • Supports FBCP software driver, can set software resolution and dual-screen display
  • Same size as your Raspberry Pi 3 / 4 / 5
  • Immersion gold process, finely crafted

Version Description

  • Since the LCD used in the original 2.8inch RPi LCD (A) has been discontinued, we have replaced it with a driver solution that has similar display effect.
  • In terms of appearance design, there is no difference in LCD size, but the software needs to be updated. Rev2.1 version adds backlight PWM control function. (Please download the new driver if you have the new version).
  • You can recognize new and old versions by the silk screen printing on the backside. The new version has screen printing Rev2.0.

600px-Rev2.1.png

Hardware Connection

It connects via the GPIO interface; the Raspberry Pi has 40 GPIO pins, while the screen has 26 pins. Pay attention to the corresponding screen pins and Raspberry Pi pins when connecting.

Pinout Definition

The pins labeled "NC" below mean that the LCD is not using these pins, and the user can use them for other applications.

PIN NO. SYMBOL DESCRIPTION
1 3.3V Power positive (3.3V power input)
2 5V Power positive (5V power input)
3 NC NC
4 5V Power positive (5V power input)
5 NC NC
6 GND Ground
7 KEY1 Key1
8 NC NC
9 GND Ground
10 NC NC
11 TP_IRQ Touch panel interrupt, detected low level when the touch panel is pressed
12 PWM Backlight control
13 RST Reset
14 GND Ground
15 LCD_RS LCD command control, command / data register selection
16 KEY2 Key2
17 3.3V Power positive (3.3V power input)
18 KEY3 Key3
19 LCD_SI / TP_SI LCD display / SPI data input of touch panel
20 GND Ground
21 TP_SCL SPI data output of touch panel
22 KEY4 Key4
23 LCD_SCK / TP_SCK LCD display / SPI clock signal of touch panel
24 LCD_CS LCD chip select signal, low level selects LCD
25 GND Ground
26 TP_CS Touch panel chip selection signal, the low level selects the touch panel


Software Settings

Working with Trixie and Bookworm

For Raspberry Pi 4 & Pi 5

1. Configure driver
Open the Raspberry Pi terminal and execute:

sudo apt-get install unzip -y
sudo apt-get install cmake -y
wget https://files.waveshare.com/wiki/common/Waveshare28a-v2.zip
unzip ./Waveshare28a-v2.zip
sudo cp waveshare28a-v2.dtbo /boot/overlays/

Edit config.txt file

sudo nano /boot/firmware/config.txt

Block the statements in the figure below
FBCP CLOSE.jpg
Add the following code at the end of the config.txt

dtparam=spi=on
dtoverlay=waveshare28a-v2
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=50000,keep_vref_on=1,pmax=255,xohms=60
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2
display_rotate=0

2. Set auto-start on boot

  • Open .bash_profile file and create one yourself if you don't have a .bash_profile file
sudo nano ~/.bash_profile

Add the following code to the bottom of the .bash_profile file

export FRAMEBUFFER=/dev/fb1
startx  2> /tmp/xorg_errors
  • Open the 99-fbturbo.~ file, if the file already exists, you need to confirm that fb is fb0
sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.~

Add the following to the 99-fbturbo.~ configuration file

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"

        Option          "SwapbuffersWait" "true"
EndSection

3. Set CLI auto-login

sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_wayland W1
sudo reboot

Note1: Make sure that the username of the Raspberry Pi is pi, otherwise it will not be able to log in automatically
Note2: After setting all the configurations above, the system takes longer to restart each time, and SSH also requires a moment to enter

4. Configure touch

  • Install calibrator software
sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator
  • Edit the 99-calibration.conf file
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Add the following to the 99-calibration.conf file

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "198 3679 292 3800"
        Option  "SwapAxes"      "1"
        Option "EmulateThirdButton" "1"
        Option "EmulateThirdButtonTimeout" "1000"
        Option "EmulateThirdButtonMoveThreshold" "300"
EndSection

Reboot to take effect

sudo reboot

5. Configure camera

  • Edit config.txt file
sudo nano /boot/firmware/config.txt

Add the following code at the end of the config.txt

dtoverlay=vc4-kms-v3d
max_framebuffers=2
  • Edit the 98-spi-screen.conf configuration file
sudo nano /etc/X11/xorg.conf.d/98-spi-screen.conf

Add the following to the 98-spi-screen.conf configuration file And add:

Section "Device"
Identifier "SPI Screen" 
Driver "fbdev"
Option          "fbdev" "/dev/fb0"
EndSection

Reboot to take effect

sudo reboot
  • Turn on the camera:
libcamera-hello --qt-preview

For All Raspberry Pi Versions

Note: The following operations must be based on the Raspberry Pi OS Lite version

You can use any of the following Lite system images (choose 64-bit or 32-bit as needed):

1. Download necessary software

  • Update the system
sudo apt update && sudo apt upgrade && sudo apt full-upgrade -y
  • Install the Xorg service
sudo apt-get install --no-install-recommends xserver-xorg -y
sudo apt-get install --no-install-recommends xinit -y
  • Install desktop manager
sudo apt install lightdm -y
  • Install official Raspberry Pi GUI
sudo apt install raspberrypi-ui-mods -y  
  • Install a browser (optional)
sudo apt install chromium-browser -y

2. Configure driver
Open the Raspberry Pi terminal and execute:

sudo apt-get install unzip -y
sudo apt-get install cmake -y
sudo wget https://files.waveshare.com/wiki/common/Waveshare28a-v2.zip
sudo unzip ./Waveshare28a-v2.zip
sudo cp waveshare28a-v2.dtbo /boot/overlays/

Edit config.txt file

sudo nano /boot/firmware/config.txt

Block the statements in the figure below
FBCP CLOSE.jpg
Add the following code at the end of the config.txt

dtparam=spi=on
dtoverlay=waveshare28a-v2
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=50000,keep_vref_on=1,pmax=255,xohms=60
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 640 480 60 6 0 0 0
hdmi_drive=2
display_rotate=0

3. Set auto-start startx

  • Open .bash_profile file and create one yourself if you don't have a .bash_profile file
sudo nano ~/.bash_profile

Add the following code to the bottom of the .bash_profile file

export FRAMEBUFFER=/dev/fb1
startx  2> /tmp/xorg_errors
  • Open the 99-fbturbo.~ file, if the file already exists, you need to confirm that fb is fb0
sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.~

Add the following code to the 99-fbturbo.~ file

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"

        Option          "SwapbuffersWait" "true"
EndSection

4. Set CLI auto-login

sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_wayland W1
sudo reboot

Note1: Make sure that the username of the Raspberry Pi is pi, otherwise it will not be able to log in automatically
Note2: After setting all the configurations above, the system takes longer to restart each time, and SSH also requires a moment to enter

5. Configure touch

  • Install calibrator software
sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator
  • Edit the 99-calibration.conf file
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Add the following to the 99-calibration.conf file

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "198 3679 292 3800"
        Option  "SwapAxes"      "1"
        Option "EmulateThirdButton" "1"
        Option "EmulateThirdButtonTimeout" "1000"
        Option "EmulateThirdButtonMoveThreshold" "300"
EndSection

Reboot to take effect

sudo reboot

Working with Bullseye 64-bit System

Please download the 64-bit bullseye version image from the Raspberry Pi official website.
1. Configure driver
Open the config.txt file under the boot directory, comment out dtoverlay=vc4-kms-v3d, and add the following at the end of [all]

dtparam=spi=on
dtoverlay=waveshare28a-v2
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=50000,keep_vref_on=1,pmax=255,xohms=60
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2
display_rotate=0

2. Configure touch
Run the following statements on the terminal:

sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Add the following statements in the 99-calibration.conf file:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "198 3679 292 3800"
        Option  "SwapAxes"      "1"
        Option "EmulateThirdButton" "1"
        Option "EmulateThirdButtonTimeout" "1000"
        Option "EmulateThirdButtonMoveThreshold" "300"
EndSection

3. Run FBCP porting
This process requires networking

sudo apt-get install cmake
wget https://files.waveshare.com/wiki/common/Rpi-fbcp.zip
unzip Rpi-fbcp.zip
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp

4. Set auto-start on boot

sudo nano /etc/rc.local

Add the following statement before exit 0 at the end:

sleep 7
fbcp &

3.5A 1.png

After a restart, the screen will display normally

sudo reboot


For Bullseye 32-bit and Buster Systems

Method 1: Install Driver

Please download the latest version of the image (Raspbian/Ubuntu Mate/Kali or Retropie) at Raspberry Pi official website. For convenience, Raspbian images are provided here:

1) Download the image file to the PC, and extract it as .img file.

2) Connect the TF card to the computer, open the Win32DiskImager.exe software, select the .img file prepared in step 1, and click Write to flash the system image. After the image flashing is complete, safely eject the TF card.

3) Connect the TF card to the Raspberry Pi, start the Raspberry Pi, and log in to the terminal of the Raspberry Pi (you can connect the Raspberry Pi to the HDMI display or use ssh to log in remotely).

4) First download the relevant driver code through the network, then execute the corresponding installation command, ensuring you have a stable Internet connection throughout the process.

git clone https://github.com/waveshare/LCD-show.git
cd LCD-show/
If it is an old version, use the following code:
sudo ./LCD28-show
If it is a new version, use the following code:
sudo ./LCD28-show-V2

It can be used after restarting (for convenience, the screen orientation can be adjusted, see #Set Screen Orientation).

Note 1: Executing apt get upgrade will cause the LCD to malfunction. At this point, you need to edit the config.txt file in the TF card and delete this line: dtoverlay=ads7846.

Note 2: Under Raspbian-lite, you need to run the sudo ./LCD28-show lite or sudo ./LCD28-show-V2 lite commands to install the driver.

Method 2: Use Pre-installed Driver Image

Here is a pre-installed driver image, extract it and write it to the TF card (Open the Win32DiskImager.exe software, select the .img file, and click Write to flash the system image). Then insert the card into the Raspberry Pi to use it. If it is an old version, flash the following image:

Set Screen Orientation

Once the touch driver is installed, you can modify the screen rotation direction by running the following commands.

cd LCD-show/
#X can be 0, 90, 180, and 270. They respectively represent LCD rotation of 0 degrees, 90 degrees, 180 degrees, and 270 degrees.
#If it is an old version, run the following code:
sudo ./LCD28-show X 
#If it is a new version, run the following code:
sudo ./LCD28-show-V2 X

The rotation command under Raspbian-lite is as follows:

cd LCD-show/
#X can be 0, 90, 180, and 270. They respectively represent LCD rotation of 0 degrees, 90 degrees, 180 degrees, and 270 degrees.
#If it is an old version, run the following code:
sudo ./LCD28-show lite X 
#If it is a new version, run the following code:
sudo ./LCD28-show-V2 lite X

Install Calibration Software for Calibration

  • This LCD can be calibrated using the xinput-calibrator program.
  • Run the following command to install:
sudo apt-get install xinput-calibrator
  • Click the Menu key on the taskbar, select Preferences -> Calibrate Touchscreen.
  • Follow the displayed prompts to perform touch calibration.
  • If you want to save these touch values, you need to create a 99-calibration.conf file in the following path (if it already exists, you don't need to create it)
   /etc/X11/xorg.conf.d/99-calibration.conf
  • Save the touch parameters (data may vary for different LCDs, as shown in the figure below) to 99-calibration.conf

5inch HDMI LCD FAQ1.jpg

Install Virtual Keyboard

1. Run the following command to install the relevant software

sudo apt-get update
sudo apt-get install matchbox-keyboard
sudo nano /usr/bin/toggle-matchbox-keyboard.sh

2. Copy the following content to toggle-matchbox-keyboard.sh, save and exit

#!/bin/bash
#This script toggle the virtual keyboard
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard
else
matchbox-keyboard &
fi

3. Run the following commands

sudo chmod +x /usr/bin/toggle-matchbox-keyboard.sh
sudo mkdir /usr/local/share/applications
sudo nano /usr/local/share/applications/toggle-matchbox-keyboard.desktop

4. Copy the following content to toggle-matchbox-keyboard.desktop, save and exit

[Desktop Entry]
Name=Toggle Matchbox Keyboard
Comment=Toggle Matchbox Keyboard`
Exec=toggle-matchbox-keyboard.sh
Type=Application
Icon=matchbox-keyboard.png
Categories=Panel;Utility;MB
X-MB-INPUT-MECHANSIM=True

5. Execute the following command, noting that this step must be performed by the "pi" user; if using an administrator account, the file will not be found

sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel

6. Find commands similar to the following (icons may vary slightly between versions)

Plugin {
type = launchbar
Config {
Button {
id=lxde-screenlock.desktop
}
Button {
id=lxde-logout.desktop
}
}

7. Add the following code to add a Button item, as shown in the figure

Button {
id=/usr/local/share/applications/toggle-matchbox-keyboard.desktop
}

RPILCD-INSTALL-KEYBOARD01.png

8. Execute the following command to restart the system, and you can see an additional virtual keyboard icon in the upper left corner

sudo reboot

PWM Backlight Adjustment Function

Note: Only available for 2.8inch RPi LCD (A) - Rev2.1 version

If you use Pi4, you need to update wiringPi version first. The operation method is as follows (for 3B+ and earlier versions, there is no need to update):

wget https://files.waveshare.com/wiki/common/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear. If it does not appear, there is an installation error

After the wiringPi is successfully updated, you can control the backlight brightness by the following commands.

gpio -g mode 18 pwm             #Configure the PIN as PWM mode
gpio pwmc 100   
gpio -g pwm 18 0         	#Darkest
gpio -g pwm 18 1023      	#Brightest
gpio -g mode 18 out             #Clear the PIN to output mode

Resources

Development Resources

Raspberry Pi Image

If it is an old version, flash the following image:


Software

Raspberry Pi Related Tutorials

LCD Panel Dimension

FAQ

 Answer:
  • This LCD must have drivers installed in order to function properly. For details, please refer to the user manual.


 Answer:
  • Since Raspberry Pi images and versions are frequently updated, if you encounter issues with normal LCD usage, please download the latest image provided by us or download the latest image from the Raspberry Pi official website and install the latest driver we provide for use.
  • Ensure that the hardware is connected correctly and in good contact.
  • Ensure the TF card can be written normally.
    When the Raspberry Pi starts up normally, the PWR light is always on, and the ACT light blinks. If both lights are always on, it may be that the TF card image flashing was unsuccessful or the TF card is in poor contact with the Raspberry Pi.

It is recommended to use a 5V 2.5A power adapter to power the Raspberry Pi. If you use the USB port of your PC to power the Raspberry Pi, the Raspberry Pi may not start properly due to insufficient power supply.


 Answer:
The normal operating current is about 80mA.




Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)