Setting up raspberry pi & touchscreen display

This is a step by step guide to build a raspberry pi with the touchscreen display. Before we get started, this is the final result of the setup at my work table.

Step 1

Install Raspberry OS. The easiest way to do this from a Mac is to use a Raspberry Pi Imager. Installing Raspberry Pi Imager and installing the OS in the SD card took less than 15 minutes and most of the time I was simply watching the progress bar move ahead. There is nothing much to do here after the installation is started. Probably a good time to make some coffee.

Step 2

During the first boot, the system might recommend for updating all software and packages. If this happens, I strongly recommend updating all the packages. In case, if this doesn’t happen, run the following three commands in your terminal

sudo apt-get update
sudo apt-get upgrade
sudo reboot
Step 3

At this point, it is very obvious to note that the screen is rotated. To change the screen rotation, add the line “display_rotate=2” to /boot/config.txt

sudo sh -c 'echo display_rotate=2 >> /boot/config.txt'
sudo reboot
Step 4

While the screen rotation is fixed, the touch (click) is still messed up. Touching (clicking) on the top right still triggers a click on the bottom left. Here is the article which explains both the display and touchscreen rotation issues.

sudo vim /usr/share/X11/xorg.conf.d/40-libinput.conf

Add Option “TransformationMatrix” “-1 0 1 0 -1 1 0 0 1” to be added to the section with touchscreen. The whole section should be as follows

Section "InputClass"
    Identifier "libinput touchscreen catchall"
    MatchIsTouchScreen "on"
    MacthDevicePath "/dev/input/event*"
    Driver "libinput"
    Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
Step 5

At this point, it is better to enable ssh to enable remote access to the raspberry pi. It makes life so much easier.

sudo systemctl enable ssh
Step 6

The only step remaining is to run a script every time the raspberry pi boots.

sudo sh -c 'echo @bash /home/pi/ >> /etc/xdg/lxsession/LXDE-pi/autostart'
sudo reboot
Step 7

For the last step, create a file called (the same name as we used in the previous step) in the /home/pi folder with the following contents

chromium-browser --noerrdialogs --disable-infobars --kiosk

This is all we need to build kiosk from a raspberry pi.

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.