Home Buddy: Network Ad Blocker & Weather Station




Introduction: Home Buddy: Network Ad Blocker & Weather Station

About: Hi folks ! Here's another random guy who decided to build some fuzzy stuff and share it with you. For the record, I'm quite new to programming and electronics but I've been seduced by Raspberry's.

Hi Folks!

Aren't you fed up with web tracking and "personalized" ads ? Well... I am, so a few months ago, I decided to act. Fortunately, some people (who probably felt the same as me), hard coded a brilliant software to eradicate ads (thumbs up to Pi-hole). I won't go into details regarding Pi-hole ins and outs as the subject has already been thoroughly documented by others. Nonetheless I will provide you with the links I used to set it up.

As it felt really cool to have an add blocker running on my home network, I decided to build a proper casing for the Pi and add a few extra features using push buttons and an E-Paper display. The first button connects to the Pi-hole API and sends server stats to the monitor. The second button connects to the OpenWeatherMap API and displays forecasts of user-specified locations. If your wondering "Why bother !", well please give me credit for an easy to use tool that summarizes relevant information at the push of a button. The third and last button is used for a rather convenient feature, a power on / off switch (saving the need to SSH into the Pi via another device). When plugged in, the Pi will boot up by itself but will shutdown when the button is pressed. Pushing the button once again will power up the Pi. Please also note that the system will refresh itself periodically and display the network status.

Enough talking lets get cracking !


For this project you will need the following parts :

  • 1 Raspberry Pi board. I used the Pi Zero WH for convenience.
  • 1 micro-USB power lead.
  • 1 E-Paper 1.54 inch black and white display. I got mine here.
  • 3 normally open push buttons. I got some here.
  • A set of M2.5 brass standoffs. I purchased a kit on Amazon here.
  • 1 transparent acrylic plexiglass (2 mm thick) to protect the E-Paper display.
  • 1 black acrylic sheet (5 mm thick) for the Pi Box lid.
  • 1 plywood sheet of 5 mm thick.
  • 6 female to female jumper wires. I bought some on Adafruit website.

Step 1: Building the PiBox

Instead of building a brand new box from scratch, I repurposed a vintage drawer that was lying around in my garage. Its shape and color was to my liking and I had no other use for it at that point. With precaution, I took it apart, shortened the side and bottom panels and reassembled them together using wood glue. As you may not have the same drawer at your disposal (rather understandably), let me give you the dimensions.

PiBox outer dimensions : 120x120x90 mm (L,W,H) and corner radiuses of 15 mm

On the front panel I drilled 3 equally spaced M10 holes for the push buttons and cut a rectangular opening for the E-Paper display. The holes are spaced every 25 mm and the opening dimensions are 34x49 mm (W,H). I must mention that the front panel was too thick for the push buttons thus I made an adapter (a 4 mm long, 10 mm (OD), 7 mm (ID) rubber tube glued in each hole).

Having sorted out the buttons issue, I cut out a groove of 15x25 mm (L,W) on the front panel for the E-Paper connector. A final cut was made to the bottom plate top left corner for the power lead.

For the Pi Zero, I cut a 60x35 mm (L,W) rectangle out of a 5 mm plywood sheet, drilled M3 holes at each corner and fitted 4 brass standoffs (the Pi Zero mounting holes are on a 58 x 53 mm rectangle). I then drilled two M3 holes along the rectangle center-line and screwed the lot inside the PiBox.

For the E-Paper display, I cut two 60x20 mm rectangles out of a 5 mm plywood, drilled two M3 holes along the edges and screwed them on each side of the E-Paper opening. I then pre-positioned the monitor in the opening, marked the exact position of the mounting holes, drilled M3 holes at each marking and screw on brass standoffs.

After completing the box, I sanded it down and applied a dye to give it back its original color.

Step 2: Wiring It Up

If you purchase the same buttons as I did, you'll first need to do some soldering. To simplify the wiring, I took some female to female jumper wires, cut them in half and soldered the naked wires to the buttons pins (using heat-shrink tubing). I then fitted the buttons in the M10 holes (through the rubber tubes) and tightened the nuts. By tightening them, the rubber tubes expand and lock the buttons in place.

With the buttons in place, I connected the wires to the Pi Zero GPIO pins as follows:

  • Button 1 : pin 5 (GPIO 3) & 6 (GND)
  • Button 2 : pin 33 (GPIO 13) & 34 (GND)
  • Button 3 : pin 39 (GND) & 40 (GPIO 21)

The numbers in bold correspond to the Pi physical board numbering (more information can be found on this website).

For the E-Paper display, 8 wires had to be connected. After a few google queries, I found instructions on this website which by the way, deserved a good old thumbs up. Then, I connected the wires to the following GPIO pins:

  • VCC (3.3V/5V power) : pin 17 (3.3V pin)
  • GND (Ground) : pin 20 (Ground pin)
  • DIN (Data in) : pin 19 (GPIO 10 / MOSI)
  • CLK (Clock) : pin 23 (GPIO 11 / SCLK)
  • CS (Chip selection) : pin 24 (GPIO 8 / CE0)
  • DC (Data/Command selection) : pin 22 (GPIO 25)
  • RST (Reset) : pin 11 (GPIO 17)
  • BUSY : pin 18 (GPIO24)

With the Pi nicely wired up, I screwed the Pi Zero and the display boards onto they respective supports.

For the sake of protection, I cut a 34x49 mm (W,H) rectangle out of a 2 mm transparent acrylic plexiglass, drilled M3 holes in each corner, and screwed it ontop of the monitor.

Step 3: Software Setup

Building this project with a Pi Zero, it felt natural to install the Raspberry Pi OS Lite version. The GUI version would have been of no use and slowed the Pi down. To install the OS and access it remotely, you'll need to download a few software and create/edit some files. I'll spare you the long and boring explanations and share with you the video I've been following here.

Once the OS setup completed, I logged into the Pi Zero via SSH and installed pi-hole using the following command:

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

This is the one-step automated installation method. There are other methods proposed on pi-hole website, so feel free to use the one you like best.

With the installation completed, I saved the Pi-hole web interface password (I recommend you doing the same) and installed ufw (which stands for Uncomplicated Firewall). As the Pi will be connecting to the web for may hours/days, a firewall was a wise feature to add. To do so, I typed in the following command:

sudo apt install ufw

Then, I opened the communication ports for pi-hole (as explained in the official documentation here)

sudo ufw allow 80/tcp
sudo ufw allow 53/tcp
sudo ufw allow 53/udp
sudo ufw allow 67/tcp
sudo ufw allow 67/udp
sudo ufw allow 546:547/udp

Allowed SSH

sudo ufw allow ssh

And finally, enabled the auto startup option. This will make sure the firewall is properly loaded after each boot. If you need more information, feel free to visit the ufw website here.

sudo ufw enable

With pi-hole up and running, I began programming the PiBox extra functionalities. To interact with the E-Paper display, push buttons and web APIs, I had to install a few python libraries and enable the Pi SPI interface. To do so, I typed in the following command:

sudo raspi-config

On the displayed menu I choose Interfacing Options > SPI > Yes. Then, I rebooted the Pi with:

sudo reboot

Once rebooted, I installed the following libraries:

sudo apt-get install python-pip
sudo apt-get install python-pil
sudo apt-get install python-numpy
sudo pip install RPi.GPIO
sudo pip install spidev
sudo pip install requests
sudo pip install schedule

From this point on, I went on the E-Paper display github repository, downloaded the demonstration codes, edited some of them for testing purposes, screwed a few up (inevitably) but helped me work my way up in writing a not-too-ugly script. The zipped project files (PiBox_project.tar.gz) are available for download at the end of this section.

Once downloaded, unzipped and copied to your Pi (e.g. in the /home/pi directory), you'll find:

  • The main.py file which is the executable.
  • The pic folder which contains the project icons (BMP files).
  • The lib folder which contains the E-Paper display and PiBox libraries (Class files).
  • The service folder which contains the auto startup at boot script.

Note that you'll need to edit a few lines of the main.py file for it to run properly.

Line 30 : Type the IP adress you set for pihole. E.g. ""

pihole_address = ""

Line 31 : Type in your OpenWeatherMap API key. You can get one by creating a free account on their website.

API_key = "Your API key here"

Line 32 : Enter the names and GPS coordinates (latitude and longitude) of the cities you wish to get weather forecasts for. For the sake of examples, I've pre-registered 3 cities in the script (Berlin,London and Paris) but you can add as many as you want.

cities_info = {'Berlin':[52.52437, 13.41053],'London':[51.50853, -0.12574],'Paris':[48.85341,2.3488]}

That's it, you're all set to run the script and enjoy the PiBox features. Navigate to the PiBox_project folder and run the following command:

sudo python main.py

If you wish to automate the script execution at boot, you'll need to create a service. Navigate to the service folder (PiBox_project/service), open the pibox.service file, go to line 7 and edit the path of the PiBox_project folder. Mine was in /home/pi/PiBox_project.


Once edited, save the file and copy it to the etc/systemd/system directory using this command:

sudo cp pibox.service /etc/systemd/system

You can now start and enable the service by typing:

sudo systemctl start pibox.service
sudo systemctl enable pibox.service

The script will now automatically startup each time you boot the Pi. Enjoy !

Step 4: The Final Touch

Filled with the excitement of a fully operational system, I almost forgot a few details: to build a lid and root the power lead out properly. To do so, I drew the contours of the PiBox on a 5 mm thick black acrylic sheet and used a jigsaw to cut it out. I then drilled 4 countersunk M3 holes in each corner, and screwed the lid onto the PiBox. For the power lead, I cut a small groove (using a DREMEL) near one edge so that the PiBox would lie flat on its base.

A few last words:

If you wish to add extra features to your PiBox, simply go to the pibox class file (/PiBox_project/lib/pibox.py) and start programming new methods. For consistency purposes, make sure they return an image object (the one to be displayed). Also, If you plan to use new buttons, don't forget to declare the GPIO pin numbers (line 24) and the event detection callbacks in the init method (line 50). Then, in the executable file (/PiBox_project/main.py), add new else-if (elif) statements for each new method you wish to call.

Last but not least, you can use the E-Paper partial update method to display information more dynamically (without the need of a full screen refresh). This feature is included in the E-Paper library (PiBox_project/lib/waveshare_epd/epd1in54_V2.py) so feel free to use it. You can find examples on the E-Paper github repository.

Please beware that an excessive use of the partial update method can create ghosting and damage the display. A full refresh every so often is highly recommended (c.f. E-Paper FAQ page).

That's all for now folks. I'll let you get on with it !

First Time Author Contest

Participated in the
First Time Author Contest

Be the First to Share


    • Barbecue Speed Challenge

      Barbecue Speed Challenge
    • Make it Real Student Design Challenge #3

      Make it Real Student Design Challenge #3
    • Arduino Contest

      Arduino Contest



    2 months ago

    So, I installed Pi-Hole on my Zero W. It seems to work and block some stuff. But...
    I quickly came to a disappointment. The #1 (and almost only reason) I botherd to install Pi-Hole was to block Youtube ads on mobile Youtube apps and on SmartTV, where you can't block them by any other means. But turns out you can't actually block Youtube ads with Pi-Hole... Because ads URLs are constantly changing and are indistinguishable from legit videos URLs.

    Well that's a almost negats any usefulness of Pi-Hole, because you can easily install ad-blocking extensions to mobile browsers and even some SmartTV apps can do that. I also tried to go to some random Russian online-cinema site and there was like 50 unblocked banners all around page. Only thing left is to delete this useless thing. Much time wasted, wow.


    Reply 2 months ago


    You are kindly invited to complain to Pi-hole community. Developers will happily
    address your concerns.

    Such comments, here, are irrelevant.


    Reply 2 months ago

    I think it could be usefull for people that are looking forward to block youtube ads, so it is relevant.


    4 months ago

    As @Pi-rouette, I like the idea of combining but for my side it's :
    usefull but not to be shown: pi-home
    usefull and to be shown: weather forecast.
    Congrats !
    But as the pi zero is only wifi capable and with low computing power, have you noticed any latency during websurfing.

    Thanks and nice (big ;o) enclosure


    Reply 4 months ago

    Hi Urbatecte,
    Thanks for your interest !
    Indeed, you could use the buttons for other tasks. As you may have seen, I added a description at the end of the instructable on how to do so. Just add new methods to the pibox class and you'll be all set.

    Now regarding the latency, I've been using the cloudflare DNS server which, here in Europe, is working fine. I compared with and without pi-hole on and did not find noticeable differences (Ping tests around 5-9 ms). You can try to use other DNS servers to find the best one for your region.

    Cheers !


    Reply 4 months ago

    Ok regarding your external DNS, but I think the pi-hole principle is to be use as your primary DNS (in order to be able to block the ad's quaries).
    Based on that, all your web queries go through the pi-hole and in your case through wifi and low power pi, that's why I was interested by your performance.

    Cheers !


    4 months ago

    Hi there ! Really cool project, congratulations !! you combine a usefull tool for everyday life to a handsome enclosure, it looks professional and easy to handle, and above all... Nice author style :)


    4 months ago

    Nice project. I like the enclosure.