Installing Pi-hole with an LCD screen
Tags: raspberrypi, beginners, tutorial, pihole
Published: 2022-06-29 13:30:03

I had already made an article on Pi-hole a few years ago, this one adds the fact that there is an LCD screen.

{% embed https://dev.to/thomasbnt/setup-pi-hole-3gkd %}


> In this article, we will discover how to install Pi-hole with an LCD screen. 
> The reference of the screen is **XPT2046 Touch 3.5" RPI Display 480x320 16bit**.

___

## Introduction

We will install [Pi-hole](https://pi-hole.net/) on a Raspberry Pi 3B. 

{% embed https://pi-hole.net/ %}

Pi-hole is used to block unwanted requests and URLs that you don't want to load on the network. 
It protects you from trackers and optimizes your network traffic.

___

## Installation

### 1. Prepare Raspbian

First, flash your SD drive from [Etcher](https://www.balena.io/etcher/) or another application.

![Etcher, a software to flash your SD cards and USB sticks to make a bootable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y73z96lwt1jnv0oqv9cj.png)

Wait a few minutes until the disk is ready.

![The end of the installation on the Etcher software](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j7u0gnjak4tx0i100797.png)


### 2. Update the dependencies

Connect to your Raspberry Pi and update the dependencies.

```bash
sudo apt-get update -y && sudo apt-get upgrade -y
```

Wait a good few minutes... in the meantime, drink a good cappuccino. ☕

Install **curl** and **git** if this is not available on your small machine: 

```bash
sudo apt-get install curl -y && sudo apt-get install git -y
```

### 3. Install Pi-hole

Then, when everything is good, you can start installing Pi-hole.

You can clone from [the Pi-hole repository](https://github.com/pi-hole/pi-hole) or directly curl with this command:

```bash
curl -sSL https://install.pi-hole.net | bash
```

When asked if you want to install on your Raspberry and put in static IP, check yes, and remember the IP.

![Installing Pi-hole](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjf60qv8rscfb3w93e3r.png)


Then choose your **preferred DNS**. You can put more than one if you want. This is editable after installation.

![Installing Pi-hole and its DNS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdl7eyxxbns93sb2kxzj.png)

You can select block lists:

![Installation of Pi-hole and its DNS part. 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ryw2z5qntv8bwk146cg.png)

> ✨ I actually have a **huge list with over 1,000,000 blocked domains/IPs**. [The repository of this list on GitHub](https://github.com/thomasbnt/raspihostblock). Feel free to add your own domains/IPs.

It will also ask you if you want a **web panel**.
I strongly recommend that you leave it enabled so that you can connect to the Raspberry Pi with a password and **manage your DNS/blacklist** and **view your statistics**.

### 4. Configuring the web panel

As soon as you have finished installing **Pi-hole**, it will give you the local host address and the generated password.

To change the password :

```bash
sudo pihole -a -p
```
This is a preview of the panel when you are logged in 🎉

![Web panel preview on Pi-hole](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3boe469zoumpdxdw1m0m.png)

___

## Setting up the LCD screen

The most complicated part is here!
There may be some things I've written that don't work for you, or that aren't essential to do.

### 1. Install the LCD screen on the Raspberry Pi

Simple part to do, just put the Display on the branches of the RPI. 
I found [a YouTube video that shows you how to position it](https://youtu.be/Z1N2t5zVP88?t=141).

### 2. Install PADD

> **[PADD](https://github.com/pi-hole/PADD)** is a software that allows you to see the data transmitted by Pi-hole on your screen.

The project has been taken over by Pi-hole, and even if there are some errors, it is still usable.

To install it and make it executable :

```bash
cd ~
wget -N https://raw.githubusercontent.com/pi-hole/PADD/master/padd.sh
sudo chmod +x padd.sh
```

Make PADD run when the RPI is launched:

```bash
# Run PADD
# If we're on the PiTFT screen (ssh is xterm)
if [ "$TERM" == "linux" ] ; then
  while :
  do
    ./padd.sh
    sleep 1
  done
fi
```

If you wish, you can test the script and view it from your terminal:

```bash
./padd.sh
```

This gives: 

![PADD preview on a terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1wnz7ikwj819gozijdg.png)

After you have done everything, you need to **reboot your machine**.

### 3. Make the screen turn off at night.

[On the PADD wiki](https://github.com/pi-hole/PADD/wiki/Setup#optional-put-the-display-to-sleep-at-night), they show you how to make the screen turn off at night. The script works with **cron**, to modify it, do `sudo crontab -e` :

```bash
# PiTFT+ SLEEPY TIME
# Turn off the PiTFT+ at midnight
00 00 * * * sh -c 'echo "0" > /sys/class/backlight/soc\:backlight/brightness'
# Turn on the PiTFT+ at 8:00 am
00 08 * * * sh -c 'echo "1" > /sys/class/backlight/soc\:backlight/brightness'
```

___ 

## Possible mistakes

During my installation, I had a few errors, including one where the screen would not turn on.
So I forced him to do it with **[Adafruit](https://github.com/adafruit/Raspberry-Pi-Installer-Scripts)**.

### A. Installation of Adafruit

Let's already install the prerequisites:

```bash
sudo apt-get install python3-pip -y
```

Then Adafruit [from the GitHub repository](https://github.com/adafruit/Raspberry-Pi-Installer-Scripts) :

```bash
cd ~
git clone https://github.com/adafruit/Raspberry-Pi-Installer-Scripts.git
```

And finally, we will install Adafruit :

```bash
cd Raspberry-Pi-Installer-Scripts
sudo python3 adafruit-pitft.py --display=35r --rotation=90 --install-type=console
```

This script will modify **/boot/config.txt** to make **adafruit-pitft** run when the RPI is launched.

{% details See how to do it manually %} 
```bash
sudo nano /boot/config.txt
```
Insert at the end:

```bash
[all]
hdmi_force_hotplug=0
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft35-resistive,rotate=90,speed=20000000,fps=20
dtoverlay=piscreen,speed=16000000,rotate=90
```
{% enddetails %}


### B. Invalid number" errors

If you get this kind of error on your screen:

```bash
/home/pi/padd.sh: line 900: printf: 0,3: invalid number
/home/pi/padd.sh: line 244: printf: 42,236: invalid number
/home/pi/padd.sh: line 873: printf: 9,1: invalid number
/home/pi/padd.sh: line 900: printf: 0,91: invalid number
```

Leave the **local** of the Raspberry Pi on `en_GB.UTF-8`, 
an issue is in progress and therefore displays errors on the Display. ([View issue on GitHub](https://github.com/pi-hole/PADD/issues/178))


___
Sources:
- [Wiki to configure PADD](https://github.com/pi-hole/PADD/wiki/Setup#setup-padd)
- [3.5 Inch RPI Display Touch - XPT2046 (480x320) - Install](https://forums.raspberrypi.com/viewtopic.php?t=178443)
- [GitHub issue : PADD displays error message about "invalid number"](https://github.com/pi-hole/PADD/issues/178)

___
|☕|Check my [Twitter account](https://twitter.com/thomasbnt_). You can see many projects and updates. You can also [support me on Buy Me a Coffee, Stripe or GitHub Sponsors](https://thomasbnt.dev/donate). Thanks for read my post ! 🤩|
|---|---|