How to Set Up and Use the 3.5 Inch LCD Display on Raspberry Pi 3B+

How to Set Up and Use the 3.5 Inch LCD Display on Raspberry Pi 3B+

This guide will walk you through the steps to set up and use the 3.5 inch LCD display on a Raspberry Pi 3B+ using the LCD-show repository.

 

Prerequisites

- A Raspberry Pi 3B+
- A 3.5 inch LCD display designed for the Raspberry Pi 
- MicroSD card with Raspberry Pi OS installed
- Internet connection

Steps

1. Prepare Your Raspberry Pi

1. Insert the MicroSD card into your Raspberry Pi 3B+.
2. Connect the 3.5 inch LCD display to the GPIO pins on the Raspberry Pi.
3. Power on your Raspberry Pi and ensure it is connected to the internet.

2. Download the LCD-show Repository

Clone the LCD-show repository from GitHub:

git clone https://github.com/goodtft/LCD-show.git

3. Change to the LCD-show Directory

Navigate to the LCD-show directory:

cd LCD-show/

4. Install the LCD Driver

Run the script corresponding to your LCD model. For the 3.5 inch LCD, use:

sudo ./LCD35-show

5. Create a Kill-fbcp Service

To ensure fbcp does not interfere with lightdm, create a service to kill fbcp after lightdm starts:

1. Create the service file:

sudo nano /etc/systemd/system/kill-fbcp.service

2. Add the following content:

[Unit]
Description=Kill fbcp after lightdm starts
After=lightdm.service

[Service]
ExecStart=/usr/bin/pkill -f fbcp

[Install]
WantedBy=multi-user.target

3. Save and close the file, then enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable kill-fbcp.service
sudo systemctl start kill-fbcp.service

6. Check Framebuffer Devices

To ensure the framebuffer devices are correctly set up, check for fb0 and fb1:

ls /dev/fb*

You should see output similar to:

/dev/fb0
/dev/fb1

7. Add Xorg Configuration

To ensure the display works correctly, add a configuration file to /etc/X11/xorg.conf.d/:

1. Create the configuration file:

sudo nano /etc/X11/xorg.conf.d/99-fbdev.conf

2. Add the following content:

Section "Device"
    Identifier "LCD"
    Driver "fbdev"
    Option "fbdev" "/dev/fb1"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "LCD"
    DefaultDepth 16
EndSection

3. Save and close the file.

8. Reboot Your Raspberry Pi

After the installation is complete, reboot your Raspberry Pi to apply the changes:

sudo reboot

9. Verify the Display

After rebooting, your Raspberry Pi 3B+ should output to the 3.5 inch LCD display. You should see the Raspberry Pi desktop environment on the screen.

 

10. Troubleshooting

If you encounter any issues, you can try the following steps:

- Ensure the LCD is properly connected to the GPIO pins.
- Re-run the installation script.
- Check the LCD-show GitHub repository for any updates or additional instructions.
- Reconfigure lightdm to ensure it is active:

sudo dpkg-reconfigure lightdm

- Use raspi-config to ensure lightdm is set as the default display manager:

sudo raspi-config

Navigate to Boot Options > Desktop / CLI > Desktop GUI, automatically logged in as 'pi' user.

- Check for errors in the Xorg log file:

cat /var/log/Xorg.0.log | grep EE

Example error "Screen 0 deleted because of no matching config section" (Solution see 7. Add Xorg Configuration)

[ 1740.345] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[ 1740.345] (II) Module fbdevhw: vendor="X.Org Foundation"
[ 1740.345] compiled for 1.21.1.7, module version = 0.0.2
[ 1740.345] ABI class: X.Org Video Driver, version 25.2
[ 1740.346] (II) FBDEV(0): using /dev/fb1
[ 1740.346] (EE) Screen 0 deleted because of no matching config section.
[ 1740.346] (II) UnloadModule: "fbdev"
[ 1740.346] (II) UnloadSubModule: "fbdevhw"
[ 1740.346] (EE) Device(s) detected, but none match those in the config file.
[ 1740.346] (EE)
Fatal server error:
[ 1740.346] (EE) no screens found(EE)
[ 1740.346] (EE)
Please consult the The X.Org Foundation support
at http://wiki.x.org

11. Uninstall the LCD Driver

If you need to uninstall the LCD driver and revert to the HDMI output, run the following script:

cd LCD-show/
sudo ./LCD-hdmi

Reboot your Raspberry Pi after running the script:

sudo reboot

Conclusion

You've successfully set up and configured the 3.5 inch LCD display on your Raspberry Pi 3B+. You can now use the display for various projects and applications. For more information and advanced configurations, refer to the LCD-show GitHub repository.