Testing, installing and configuring a 7" LCD touchscreen on a Raspberry Pi


January 15, 2019 • 1 • 4.1

A Raspberry Pi is a micro-computer and, well, still a computer. You can quite easily turn this board into a more conventional computer with a keyboard, mouse, and—most importantly—a screen! Depending on your use case, a touchscreen can be very handy and connects easily to the Raspberry Pi. In this tutorial, I'll show you how to connect it, configure it, and enjoy it.

7

Prerequisites

To follow along, here's what you'll need (you probably already have most of it).

Once you have everything, we can move on to wiring.

Unboxing & wiring

Haven't received your screen yet? Here's what the box looks like and what's inside:

7-inch LCD screen box 7-inch LCD screen box contents

Box contents

To use the screen with the Raspberry Pi, the CD isn't necessary. (Thankfully!) First, I recommend installing the 4 screws with the nuts, as shown below (no screwdriver needed). They protect the components on the back of the screen, avoiding contact with metal surfaces, for example.

Screw and nut on 7-inch screen

Once the screws are in place, connect the screen to the Raspberry Pi (preferably powered off). Simply plug the HDMI cable between both ports, then the micro-USB cable to one of the two connectors on the screen and the other end to a USB port on the Raspberry Pi.


7-inch screen connection - Raspberry Pi
7-inch screen connection - Raspberry Pi


Question

Why are there two micro-USB ports on the screen?

Sometimes you'll need a separate power supply for the screen. When the Raspberry Pi is under load, it draws more current, and there may not be enough left to power the screen. In that case, a small yellow lightning bolt appears at the top right. The fix is to connect an additional power supply to the second port. Note: You can't power only the screen without connecting it to the Raspberry Pi—otherwise the touchscreen data wouldn't be processed by the Pi.

Adjusting the resolution

Poor display quality? Black bars on the sides? That's normal—we need to tweak a few settings on the Raspberry Pi. First, open a terminal and type:

sudo nano raspi-config

Go to Advanced Options -> Resolution. For a 7-inch screen, I use DMT Mode 4 640x480 60Hz 4:3. It's not necessarily the most appropriate resolution for the screen, but I prefer it since the text is fairly large. With resolutions like 1280x720 or 1920x1080, text can be hard to read. Feel free to try different resolutions to find what works best for you.

Issue

Thick borders around the screen?

The sudo raspi-config tool lets you change display resolution easily, but it doesn't expose all configuration parameters. To access everything, edit /boot/config.txt, for example by running:

sudo nano /boot/config.txt

If you have overly wide borders, just uncomment the following line (remove the leading #):

disable_overscan=1

To apply changes, save (Ctrl+X -> Y (or O) -> Enter) and reboot the Raspberry Pi.
Reminder: reboot with the following command:

sudo reboot

Mouse cursor unusually slow?

If you use the screen with a wireless mouse, you may notice a slow, laggy cursor. Fortunately, there's a fix!
First run:

sudo nano /boot/cmdline.txt

You'll see a single-line file with many parameters. To fix the cursor issue, append this at the end of the line: "usbhid.mousepoll=0". Save the change (Ctrl+X -> Y (or O) -> Enter) and reboot the Raspberry Pi.
Next boot, the mouse should move normally!

Read next

Article image

Essential accessories to get started with Raspberry Pi 4


Article image

Choose and use a camera on Raspberry Pi






Ce tutoriel vous a plu ?

starstarstarstarstar

4.1/5 | 9 votes




Commentaires

1 commentaire publié.

Anonyme, le 22/06/2021 à 14h42


Commenter
Votre adresse mail ne sera pas visible sur le site.

Les commentaires sous soumis à vérification avant publication.