Configuring a 5″ Raspberry Pi Display

I received a 5″ 800×480 Raspberry Pi screen recently, and needed to get the screen and touch input working correctly. After some digging around I got everything working, here’s how I did it.

The screen is marked as “5inch HDMI Display, 800×480 Pixel, XPT2048 Touch Controller”, and doesn’t need any drivers to get it working, despite coming with a driver CD.

Insert the SD card from your Pi into your computer, and open the config.txt file, we’ll be making a couple of changes here.

Resolution and touch input

The Pi can’t auto-detect the screen resolution, so we’ll need to let it know how many pixels we have. Add the following lines to set the resolution.

hdmi_cvt=800 480 60 6 0 0 0

Now we need to tell the Pi that we have a touch screen connected, in the same file add the following lines


Save the file, and put the SD card back into the Pi. You’ll find the whole screen being used and the touch screen working… but the touch screen input is off by a bit, which we’re going to fix next.


We can install a calibrator by running this in the terminal

sudo apt-get install xinput-calibrator

Then you can run it by typing


It’ll get you to touch on four calibration points, after which your touch screen should work much more accurately.

To make this change permanent you’ll need to copy the output from the above command into a config file. It’ll look something like this:

Section "InputClass"
        Identifier "calibration"
        MatchProduct "ADS7846 Touchscreen"
        Option "Calibration" "159 3903 139 4046"
        Option "SwapAxes" "0"

Edit your config file with:

sudo nano /etc/X11/xorg.conf.d/99-calibration.conf

Paste the output into that file, save, and you’re done.


For some reason the above changes will modify some permissions, which means you will get a non working login screen at boot. To fix this press Ctr-Alt-F5 at the login screen to get the command line.

Login there with your username and password (default is pi and raspberry) then run the following command to fix the permissions.

chown pi:pi .Xauthority

Reboot, your next login should work as normal

ESP8266 + temp sensor fail!

I’ve designed a few sensor boards that collect temperature, humidity, light, sound etc… and send them over wifi, or a local radio network. Recently I switched to the ESP8266, and had my first fail.

The temp sensor was mounted next to the ESP8266, which is fine until you turn everything on, and realise that the ESP gets warm and completely compromises the readings on the temp sensor.


Version 1

I designed a second version of the board, with some physical separation between the ESP and the temp sensor, making cuts into the board to stop the heat traveling through to the sensor area.

Version 2

Even with this change we still get heat transfer between the ESP and the temp sensor. Within 10 minutes of power up we have a 4°C rise in temperature readings.


At this point I have a few options

1. Re-design the board, giving even more physical separation between the ESP and the sensors
2. Add a heatsink to the ESP to try and dissipate the heat
3. Modify the software to put the ESP into sleep mode between sensor readings, to reduce heat output

I’ll try a combination of the second two, although ultimately a new board might be the better solution.

ESP8266 as Arduino

You can program the ESP8266-12E as an Arduino, using the board manager plugin in the Arduino IDE. It’s great for deploying simple code with access to wifi, and at less than $2 (including shipping) it’s really affordable.

Because it’s made by multiple sources in China, and because they don’t seem to talk to each other, you get some inconsistencies between the seemingly identical boards.


Pins 4 and 5 are swapped on some of them, which means you have to account for this in your PCB designs. I2C runs on these pins, and so it’s important you have them the right way around.

The operation of the reset button is also different on different boards. Usually you need to press the reset button on power up to be able to program, but on some boards you need to keep that button pressed until the upload has started.

This makes the ESP8266 a potentially tricky board to use at first, if you don’t know the quirks.