Home / Tutorials / Raspberry Pi Tutorial / Adding a LCD Touchscreen Display to Raspberry Pi
Raspberry Pi LCD Hat Tutorial

Adding a LCD Touchscreen Display to Raspberry Pi

In this tutorial, I will show you how to add an LCD hat to your Raspberry Pi. This is an alternative to connecting an LCD display to your Pi through its HDMI port. 

I will feature 4D Systems 4DPi-32 LCD hat in this tutorial. The 4DPi-32 is the 3.2" version of their 4DPi line of products which also include sizes 3.5" and 2.4".  It's a resistive touchscreen, which means you need to have a stylus for it. You can buy the 4DPi-32 here.

Raspberry Pi OS Requirement

My Raspberry Pi is running Raspbian Stretch (November 2017 release) so make sure you have the same version before you proceed with this tutorial. You can download the Raspbian Stretch from the official site.

Software Needed

You don't need to mount the LCD hat just yet. Log-in to your Pi as root. This means you need to run sudo su after a normal login.

This is important because you need to extract the next files inside the home/pi folder.

Installing 4DPi's LCD Overlay

Next, download 4DPi's package using wget:

When the package has been downloaded, open it via tar:

Next, edit config.txt so that we will be using the overlay for the 4DPi-32 and not the other sizes:

Locate the line where this is located:

Remove the # to uncomment it and enable the overlay. If you are using other screen sizes then uncomment the appropiate line.

Adjusting Screen Resolution

Next, we need to adjust the console size of the Pi to fit into the 3.2" screen. Since the 4DPi-32 has a screen resolution of 320 x 240 pixels, we need to adjust the framebuffer to this size. In the same config.txt file, locate the following lines:

This is the console size. Above it you can see these lines:

To fit the contents of the console to the screen, we must change the framebuffer width and height to (width = 2 * overscan). For example, for a 320 pixel width, the framebuffer width should be 320 - 32 = 288. In short, uncomment the framebuffer lines and replace the values with these:

Save the changes to config.txt and then turn off the Raspberry Pi.

raspberry pi lcd display

While the Pi is still off, mount the LCD hat. Then turn on the Raspberry Pi. If everything's done right, you should now see the Pi's desktop environment on the LCD screen.

Calibrating the Touch Screen

The 4DPi-32 is a resistive touchscreen which means it would not respond to your fingers. You can use a stylus or any pointy (not too sharp) object that is non-conductive (plastic) to navigate through the screen. But first, you need to calibrate the touchscreen. To do that, install the following packages:

After the installation, run the following command:

Instructions will then appear on the screen. Follow it to calibrate.

That's it! Enjoy your new LCD screen with your Raspberry Pi.

raspberry pi lcd display 2


Check Also

Uploading Camera Images from Raspberry Pi to Website

For those who are looking to work with images on their projects, the Raspberry Pi …


  1. can you tell me what power supply would be good to power pi 3 + this LCD screen

  2. anyone else having a issue with no /dev/input/event0
    aka it is not a touch device

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.