![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg1.png)
Pi Hole Ad Blocker with Pi Zero W
Created by lady ada
Last updated on 2020-12-21 12:02:53 PM EST
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg2.png)
2
3
5
5
6
7
7
8
9
9
9
10
11
13
13
15
15
18
19
23
25
25
27
27
30
Guide Contents
Guide Contents
Overview
Project Parts
Pi Zero W base parts
Pi OLED Display Addition
Other things you may need...
Using a Pi 3 Instead of Pi Zero W
Prepare the Pi
Install Pi Hole
Pre-Check
Change Hostname
Run Pi Hole Installer
Configuration
Test Admin Page
Test Blocking
Install PiOLED
Install 2x20 Header
Install CircuitPython Libraries
Update stats.py program
Test & Stats at Startup
Install Mini PiTFT
Install 2x20 Header
Python Setup
Update the stats.py program
Test & Stats at Startup
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 2 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg3.png)
Overview
A long time ago we made a Pi into a WiFi gateway that also blocked ads but the Pi Hole project does a
way
better job!
This project will make your Pi Zero W act as a DNS ( Domain Name Server) The kind of device that tells
you that adafruit.com is known as IP address 104.20.38.240.
Except Pi Hole DNS will do a special trick, when it is asked for the IP address of ads.adserver.com (for
example) it will return nothing! So you will never even connect to the ad server and get the ad. Your
connection will be faster, less data, and no intrusive ads. It works great on computers, tablets, phones, etc.
Even if you cannot run an ad-blocker plugin on your phone or tablet, this will work and ad-blockerdetectors can't tell you're running it.
Unlike our WiFi gateway demo, you do not have to set up the Pi as your access point, you will only use it
as a DNS ad blocker so it will not act as a bottleneck
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 3 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg4.png)
We upgraded our Pi Zero Pi Hole with a little display, that makes setting up clients easy and also gives you
some nifty stats!
Follow along with this guide to DIY your own
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 4 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg5.png)
Project Parts
This project can be done with any Raspberry Pi, but for the most adorably compact version we're using a
Pi Zero W - this has enough power to do what we want, and has built in WiFi too!
Pi Zero W base parts
Its easiest if you pick up a Pi Zero W budget pack as it contains most everything you need
Raspberry Pi Zero W Budget Pack - Includes Pi Zero W
Remember those cereal commercials that would always say, "part of a complete breakfast"? Well the Pi
Zero's a lot like that bowl of cereal - while it's...
Out of Stock
But you can also just DIY with the minimum requirements:
1 x Pi Zero W
the type of low cost game-changing product Raspberry Pi's known for - the super light, super lean
microcomputer we've come to know and low, but now with built-in WiFi.
1 x 4G or larger SD Card
You will be burning this card with Raspbian Jessie Lite so its ok if its blank or pre-burned
1 x Adafruit Pi Zero Enclosure
Adafruit's classic, sturdy plastic enclosure. Keeps your Pi Zero safe and sleek.
Out of
Stock
Add to Cart
Out of
Stock
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 5 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg6.png)
1 x 5V 1A USB wall adapter
This one is plenty good and you can use any Micro USB cable with it
1 x 5V 2.4A USB wall adapter
Super powerful for any uses, and comes with a built in MicroUSB cable
Pi OLED Display Addition
If you want to add an OLED display (which is suggested!) you'll also need:
Adafruit PiOLED - 128x32 Monochrome OLED Add-on for Raspberry Pi
If you're looking for the most compact li'l display for a Raspberry Pi (most likely a
$14.95
In Stock
If you are using a Pi Zero W you'll need to add 2x20 headers too
1 x 2x20 Male Header
Solder this in to plug in Pi HATs, GPIO cables, etc as you would into a normal Pi. Requires soldering
or
1 x 2x20 No-Solder Hammer Headers
If your soldering isn't quite up to scratch, or you just don't own a soldering iron yet, then these nifty
Add to Cart
Add to Cart
Add to Cart
Add to Cart
Out of
Stock
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 6 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg7.png)
hammer headers from Pimoroni might be just what you need.
Other things you may need...
You also need a way to burn that SD card!
USB MicroSD Card Reader/Writer - microSD / microSDHC / microSDXC
This is the cutest little microSD card reader/writer - but don't be fooled by its adorableness! It's wicked fast
and supports up to 64 GB SDXC cards! Simply slide the card into...
Out of Stock
Using a Pi 3 Instead of Pi Zero W
Instead of a Pi Zero W you can directly substitute in a Pi 3 which also has built in WiFi, you won't need the
2x20 header in that case
1 x Raspberry Pi 3
Raspberry Pi 3 with WiFi built in!
Add to Cart
Out of
Stock
Add to Cart
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 7 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg8.png)
Prepare the Pi
The Pi Zero W is a very minimal computer, so it requires a little work to get it up and running.
We have a guide on how to set up your Pi Zero W 'headless' which is how we recommend you get started.
Check out the guide for how to do that!
https://adafru.it/yuC
Here's the quick-start for people with some experience:
1. Download the latest 'Lite' Raspbian (https://adafru.it/fQi) to your computer
2. Burn the Lite Raspbian to your micro SD card (https://adafru.it/dDL) using your computer
3. Re-plug the SD card into your computer (don't use your Pi yet!) and set up your wifi connection by
editing supplicant.conf (https://adafru.it/yuD)
4. Activate SSH support (https://adafru.it/yuD)
5. Plug the SD card into the Pi Zero W
6. If you have an HDMI monitor we recommend connecting it up via the mini HDMI adapter we provide
in the budget pack - so you can see that it's booting OK
7. Plug in power to the Pi Zero W - you will see the green LED flicker a little. The Pi Zero will reboot
while it sets up so wait a good 10 minutes
8. If you are running Windows on your computer, install Bonjour support so you can use .local names,
you'll need to reboot Windows after installation (https://adafru.it/lPE)
9. You can then ssh into raspberrypi.local (https://adafru.it/jvB)
https://adafru.it/yuC
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 8 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bg9.png)
Install Pi Hole
Use the following instructions to install Pi Hole:
https://github.com/pi-hole/pi-hole/#one-step-automated-install (https://adafru.it/PqC)
Pre-Check
OK once you have set your Pi up and the WiFi is connecting to your home or office network, and your can
ssh into it, continue with these easy steps! If you cannot connect via ssh yet, go back and read some of
our guides until you are able to log into your Pi.
Change Hostname
I like to do this first so I dont get confused between all the different Pi's in the house
Edit the hostname with sudo nano /etc/hostname and put something else on that first line, like pi-hole
Also change it in the hosts file with sudo nano /etc/hosts to match the same name. It's probably the last
line:
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 9 of 33
![](/html/d9/d914/d914d0c5645641812d0c270749ef1164d38fdf48aa1d68b9dd7cfe57ee7bd756/bga.png)
Reboot and when you ssh in again, use pi-hole.local
Now's also a good time to change the Pi's password with passwd
Run Pi Hole Installer
There's more information on how installation at https://pi-hole.net/ (https://adafru.it/yuE) - as of the writing
of this guide, its easier to just run:
curl -sSL https://install.pi-hole.net | bash
It will take quite a while to install, and may seem to 'hang' at points. Just let it do its thing for about 20
minutes!
© Adafruit Industries https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w Page 10 of 33