4D Systems 4DPi-24-HAT

4D Systems 4DPi-24-HAT

The 4D Systems 4DPi-24-HAT is a 2.4″ display HAT for the Raspberry Pi. It features a 2.4″ TFT screen with integrated resistive touch panel, and supports up to 240 x 320 resolution.

It is compatible with Raspberry Pi models A+, B+, Pi2, Pi3, Zero and Zero W.

The HAT also features 5 push buttons, and a backlight. This backlight can be configured as either On/Off or PWM controlled, selectable by an on board jumper.

4DPi-24-HAT Front View

4DPi-24-HAT Back View

Setting it Up

Setting up the 4DPi-24-HAT is reasonably straight forward, though it does require the installation of a custom kernel. However, this kernel installation requires only a couple of simple terminal commands, and for a basic setup requires no editing of configuration files.

The first step, as with most Raspberry Pi HATs, is to get the Raspberry Pi up and running first. As always, this involves preparing an SD card. However, whilst we’d normally recommend using the latest version of Raspbian, in this case we had to use a specific version of Raspbian. The reason for this is that the first time we attempted this setup, the custom kernel was found to be incompatible with the latest Raspbian release. More on this later.

For the version of the custom kernel that we had available at the time of writing, we had to use release 2017-03-02 of Raspbian. Luckily, we just happened to have this older version available to us. However, if you don’t have easy access to older versions of Raspbian, these can be found at the Raspberry Pi downloads archive. If you don’t know how to set up your Raspberry Pi, details can be found at the Raspberry Pi Foundation’s help pages.

Attaching the 4DPi-24-HAT

The instructions for setting up the 4DPi-24-HAT state that the software installation should be completed before attaching the HAT. As mentioned previously, this means completing the basic Raspberry Pi setup, then installing the custom kernel for the 4DPi-24-HAT. Also, as previously mentioned, we found that for the version of kernel available to us we needed to use Raspian version 2017-03-02.

Having completed the basic Raspberry Pi setup, installation of the custom kernel is done using the following terminal commands.

wget http://www.4dsystems.com.au/downloads/4DPi/All/4d-hats_4-4-50_v1.0.tar.gz
sudo tar -xzvf 4d-hats_4-4-50_v1.0.tar.gz -C /

We also altered the configuration of our Raspberry Pi so that the Pi would boot to command line, rather than the GUI. This would allow us to boot the Pi to command line on the 4DPi-24-HAT display, and then choose to start the GUI on either the HAT or on an HDMI display.

Having done this initial setup and configuration, the Raspberry Pi was shutdown and powered off. We then connected the 4DPi-24-HAT to the Raspberry Pi. This is done by connecting the 40 pin socket on the underside of the HAT to the 40 pin GPIO header on the Pi. To make the HAT secure, we also used 2 M2.5 11mm standoffs between the Pi and the HAT secured using 4 M2.5 machine screws.

Once the HAT was attached to the Pi, the Pi was rebooted.

Further Setup

When the Raspberry Pi was rebooted, the initial boot process was displayed on the attached HDMI monitor. However, once booted, the command line prompt was displayed on the 4DPi-24-HAT. This gave us the option to then either start the desktop GUI on the HAT or on the attached HDMI monitor. To start the desktop GUI on the HAT, the following command needs to be entered:-

startx -- -layout TFT

To start the desktop GUI on the HDMI monitor, the following command is used:-

startx -- -layout HDMI

Because of the way we wanted to use our HAT touchscreen, we needed to have the display rotated by 90°, to give a portrait orientation. This is easily achieved by modifying the cmdline.txt configuration file using the command:-

sudo nano /boot/cmdline.txt

and adding the parameter:-


The values for rotation angle can be either 0, 90, 180 or 270 degrees.

Command Line Display

Testing It Out

To give the 4DPi-24-HAT a proper test, we wrote a simple Python application that would display a welcome screen. By pressing the button on the touchscreen, the application would take a photo using the attached Pi camera, and briefly display the picture on the screen.


Clearly, trying to write Python scripts using a 2.4″ touch screen is not a practical proposition, so the ability to easily swap between the HAT display and an HDMI display is a really useful feature. However, during the development process we still found that there were situations where we could not get back to the command line, or access icons in the desktop GUI.

In these situations, we also found it really useful to have the SSH service available to us. This allowed us also to remotely access the Raspberry Pi and carry out a clean shutdown and restart of the Pi.

Update On Custom Kernel

Since publishing this article, we’ve done some further investigation into version compatibility of the custom kernel. When we first started looking at this HAT, the instructions on the web site (dated March 2017) referred to version 4.4.50 of the custom kernel for the HAT. However, we found that this version of the kernel did not work with the latest version of Raspbian (version 2017-07-05) at the time of writing. Consequently we had to revert to using an older version of Raspbian (version 2017-03-02).

However, the very helpful support people at 4D Systems provided us with a more up to date version of the kernel (version 4.9.35), which is compatible with version 2017-07-05 of Raspbian. In order for this version of the kernel to work, however, it was necessary to swap the backlight jumper on the reverse side of the HAT from the ‘PWM’ position to the ‘ON/OFF’ position.Backlight Jumper