Skip navigation


Available for the Raspberry PI at the actual date the market offers a number of touch screen displays; the recent launched Raspberry PI 7" LCD touch screen displayRaspberry PI 7" LCD touch screen display and the 2.4" HAT display2.4" HAT display are the top accessories in their range. These devices can be used as primary display including the touch screen they can replace the standard HDMI display, USB keyboard and mouse.


It is almost obvious that the 2.4 inches screens are less useful than larger screen (i.e. 15 inches or more): but represent a great solution for a large number of projects and applications.

A common UI design is difficult to manage and more difficult to interact with when the user should manage a 2.4 inches (or less) small screen or trying to use complex interactive interfaces also on a 7 inches screen.


Take a look to the following video.

If you like this kind of interface you are in the right place. Full colour graphics, multi-touch management, easy and visible interaction widgets also on small screen sizes, reasonably fast and responsive interfaces and more. The features shown in the video above are only some of what can be achieved with the Kivy python framework.

Note: the frame assembly of the Raspberry PI LCD Touch Screen display shown in the images of this post is available on the Drobott site. Don't forget to apply the Element14 discount code W0E49MYQ (10% off) reserved to the community users!


The framework

The adoption of this framework for the User Interface with the Raspberry PI is the better solution when the touch screen is the main tool to interact with the application. For the developers this framework is simple to manage, entirely developed in Python and very well documented with plenty of examples.


Wikipedia reports the definition of the Kivy framework as

Kivy is an open source Python library for developing mobile apps and other multitouch application software with a natural user interface (NUI). It can run on Android, iOS, Linux, OS X, and Windows. Distributed under the terms of the MIT license, Kivy is free and open source software.

but the term library is reductive; kivy is a set of libraries integrating features of many different environments. The recent porting available for the Raspberry PI Raspbian makes kivy one of the best solution for the UI design on touch screens and small displays.


The X desktop (the Raspbian desktop is an example) has never been though to be controlled by a touch-screen or an on-screen keyboard. In fact the kivy framework works perfectly just in these cases, so it's time to move on the Raspberry PI terminal and start the installation.


Installing Kivy on Raspberry PI

The main reference site is On the site - not reported in the documentation index - there is a short page with a tutorial on Installing kivy on Raspberry PI. Unfortunately this is the only page I have found and is a bit outdated. The actual available version of the framework runs perfectly on all the Raspberry PI models including the PI 2, despite that the documentation report as untested.


Installation options

Two installation options are possible: the manual installation under Raspbian and the Kivy distribution image for the Raspberry PI.

I have tested both. The special PI distribution (derived by Raspbian) can be downloaded from the site KivyPie - Kivy on RaspberryPI but seems not well working so we will exclude this option and take in consideration just the manual installation.


Manual installation

The first thing to do is adding the repository to the list. From the terminal launch the editor


$>sudo nano /etc/apt/sources.list


and add the following line: deb . main

The resulting file will show like in the image below.

Screen Shot 2015-10-01 at 23.09.03.png

Save the file then launch the next commands:


$>sudo apt-get update
$>sudo apt-get upgrade


Before installing the framework you should install the dependencies of the packages:


sudo apt-get update
sudo apt-get install pkg-config libgl1-mesa-dev libgles2-mesa-dev \
  python-pygame python-setuptools libgstreamer1.0-dev git-core \
  gstreamer1.0-plugins-{bad,base,good,ugly} \
  gstreamer1.0-{omx,alsa} python-dev


Note: you will receive a warning for some uncertified packages. Ignore this message and confirm when required to proceed.


The next step needs to install pip from the sources. Pip, aka Pipi is the Python Package Index; It is a specific python packages repository working in a similar way of the apt-get (the aptitude Debian package manager). A full detailed list of the available packages in pip is available on the pipi-python site.


sudo python


Installing and compiling the pip package manager on the Raspberry PI may require 10 minutes or more. Don't worry and wait ... During the installation you will get some error messages due the wheel command is not found; don't stop the process and ignore these messages. Wheel is a package image builder not intended for use in our case. The error message you get is shown in the image below.

Screen Shot 2015-10-01 at 14.21.33.png

Cython is the c-extension for python and is used by some components of kivy. For a detailed description see the cython wiky.

At the end of the process described above cython should be installed in your system. We use the pip repository to acquire the last updated version, avoiding the eventually outdated version available in the Debian packages.


sudo pip install cython


At this point, we are are ready to clone kivy from GitHub and compile it locally


git clone
cd kivy


Fine! We have completed the most boring part. The kivy sources now are in the user home directory, for example the user pi. It is also possible to install kivy only in the user folder but this way creates many issues when developing applications that will rung accessing other folders so we install the framework globally.


python build
sudo python install


The two commands above should be launched from inside the kivy directory in the user folders. You should already be there when the step ends. This operation requires 5-15 minutes or more, depending on the hardware model and processor speed of your Raspberry PI board.

A couple of other steps and our newly installed framework is ready for the first run.


Post-install settings

There are some features of the kivy framework requiring some external components to be installed afte the framework installation is complete.


sudo pip install pyglet docutils
sudo pip install pygments


The last operation is to edit the user kivy configuration file to set the raspberry PI touch screen replacing the mouse. Edit the kivy configuration file with the command


nano ~/.kivy/config.ini


and add the following lines in the [input] section (other similar lines should be replaced)


mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput


Save the file and reboot the system. Now you are ready to launch your application or run the examples in the folders you find in ~/kivy/examples



There is a considerable number of places on the Internet, including the Element14 site, showing useful information on the installation and settings of this brand new device; in the meantime a number of doubts and questions has raised about the touch screen settings, the on-screen keyboard installation and more. The goal of these notes is to depict a setup scenario as much complete as possible. The Raspberry PI 7" LCD Touch Screen displayRaspberry PI 7" LCD Touch Screen display is the perfect replacement of a dedicated screen, with the plus of the optional on-screen keyboard.


To use this device in a Raspberry PIRaspberry PI project requiring User Interaction it sounds almost difficult in applications like robotics, machines control, informative point, web access, sensors gauges etc.

A reliable solution exists and its name is Kivy: open source, not too difficult to install and is based on Python.


Note: the frame assembly of the Raspberry PI LCD Touch Screen display shown in the images of this post is available on the Drobott site. Don't forget to apply the Element14 discount code W0E49MYQ (10% off) reserved to the community users!


What raspbian release?


The first thing to do it to decide what raspbian image should be installed on the PI. If you have already a Raspberry PI with an existing raspbian version on it, you should install the hardware then power on the system and proceed with the software.


If you should start from scratch instead, I suggest to download the last raspbian updated image (2015-05-05-raspbian-wheezy.img at the date) from the site to create a bootable microSD card; you  can choose between two different flavours: raspbian based on Debian wheezy or Debian jessie; this choice is up to you. At the actual date it seems that the Raspberry PI porting of the Jessie distribution has again some issues.


In both cases, the next step is an update/upgrade of the system.


$sudo apt-get update
$sudo apt-get upgrade


You should have noted that the system, also on first-boot will recognise the new display device without any special setting or display drivers to be installed.


Showing full HD videos on the screen

If you plan to use the screen to show full HD videos (1080x1920 pix) the better performances can be obtained reserving 128 Mb of shared memory to the video card. The amount of shared memory (64 Mb by default) can be changed with the raspi-config command and selecting the menu options shown below.

Screen Shot 2015-08-29 at 16.34.05.png

Select Advanced Options from the main menu.

Screen Shot 2015-08-29 at 16.34.19.png

Select Memory Split from the next screen.

Screen Shot 2015-08-29 at 16.34.32.png

Then, write 128 instead of 64 (the default settings). Confirm and exit, reboot.


On-Screen keyboard

Installing the on-screen keyboard is not the solution to develop software or write long text documents on the Raspberry PI, but it is a must-to-have to make complete the user interaction options. Installing the keyboard is a very simple operation that can be done with a single command from the terminal:


sudo apt-get install matchbox-keyboard


just as it is explained in the product document page on Element14. The documentation says that the keyboard (after installation and reboot) is accessible on-screen from the Menu->Accessories->Keyboard. Doing several installations I have verified that the keyboard is not always listed as a new menu option; one of the reasons depends on the previous presence of a physical keyboard connected to the Raspberry or not. To be sure that the on-screen keyboard is added to the desktop menu after installation the better choice is to manage the Raspberry PI from remote via SSH.


The on-screen keyboard can be shown by your applications or bash scripts with the command




Enabling the touch-screen

Depending on the current status of the linux settings, maybe you don't see the mouse pointer on the screen and the touch screen is unresponsive; the touch screen uses SPI to communicate with the Raspberry PI so it should be enabled, while by default the SPI kernel modules are not loaded.


From the terminal launch the command


sudo raspi-config


then from the character graphic menu follow the steps shown below.


Select Advanced Options from the main menu.


Select the SPI menu option.


Confirm to enable the SPI module and the next screen to load the SPI kernel modules on boot by default. Then, exit and reboot the system.



Now your system is ready to use the full features of the 7 inches LCD display and touch screen.