TUTORIAL
Upgrade your humble letterbox with push notifications
Use a magnetic switch to find out when your postie’s been
Upgrade your humble
letterbox with push
notifications
ave you ever been eagerly waiting
for an item to arrive in the post,
and wished you could tell straight
away if it has finally arrived?
Maybe you’re out at work when the
postman comes, or your letterbox
is at the end of a really long driveway? Well, this is
the project for you – we’ll show you how to rig up a
tiny Raspberry Pi Zero, and a sensor switch, to send
a push notification to your phone every time the
letterbox flap is opened.
Before we get started, I’m going to assume that
you already have your Raspberry Pi Zero all set up,
with the latest version of Raspbian installed and up
to date, and the date and time correctly set. You’ll
also need a mini HDMI cable and a USB hub with a
micro USB connector, in order to plug in a keyboard
and mouse for the initial setup.
With that all ready, start by connecting up the
magnetic switch to the numbered GPIO pin 18 and
a ground pin – see the wiring diagram overleaf for
details. If you strip a short length from the ends of
your bell wire, this should easily slot into the female
DuPont cables, for easy connection to the GPIO
pins. The other end is wired into the sensor switch.
Wiring-wise, that’s it – it’s a very simple setup.
Connect the Pi to your home network, either
via WiFi or with a network cable, then enable SSH
access (Pi menu > Preferences > Raspberry Pi
configuration > Interfaces > SSH), so you can access
the Pi from another computer on your network
later. Determine the Pi’s IP address on your home
network by opening a Terminal and typing the
following command:
hostname -I
Now that’s all set up, you can start configuring the
vital services required to make things work and talk to
each other. This project works by adding a new row to
a Google spreadsheet each time the magnetic switch
is activated (i.e. the letterbox is opened), along with
the date and times that it was opened and closed.
Another service then monitors this sheet and sends
the alert to your phone whenever it sees that a new
row has been added.
Create a new Google Sheet and call it Letterbox
Activations. Set up three columns as headings, then
delete all other cells so that your sheet looks like the
image below. This is important, as the Python
H
Paul
Freeman-Powell
@paulfp
Paul is a technology
enthusiast, geek, video
producer, drummer,
cyclist, husband,
father to three children,
including twins, and host
of the award-winning
Switched On Network
YouTube channel. You
can find his website at
switchedonnetwork.com
Below
The blank Google Sheet, awaiting the first logs.
It’s important to remove all other rows, as I have done here