Pi. As a small buzzer may not be particularly
deterring to a would-be room invader, we’ve
chosen a 120 dB siren that requires more current
that our Raspberry Pi can safely handle. So, we
will give the siren its own power supply and
safely control it using one of the Automation
HAT’s relays.
02
Prepare your Raspberry Pi
It’s up to you what model of Raspberry
Pi you use for this project. A Raspberry Pi Zero
W is more than capable of running the code and
we originally prototyped our guard using one. If
you’re thinking of getting clever, though, such
as adding facial recognition using a camera, you
might want to go for the horsepower of a Raspberry
Pi 4. Either way, start by attaching the Automation
HAT carefully to the GPIO header, and secure
with the provided standoff posts on the opposite
side to ensure the HAT doesn’t wiggle about and
come loose.
03
Set up the software
We’re going to use Raspbian Buster Lite as
the operating system as there’s no need for a user
interface, just a basic command-line operating
system. That said, there’s no harm in installing
the full version if you’re more comfortable with
that. Download the image from magpi.cc/raspbian
and flash to a microSD card. Now, as ever, it’s
time to log in and update everything with sudo apt
update && sudo apt upgrade. Once finished, run
sudo raspi-config and set up networking (if using
WiFi). Now, install the Automation HAT software
by running the following command:
Protect your stuff from nosey parents, annoying siblings, or
your nemesis with this easy-to-build motion-detection alarm
I
f you’re just getting into making with
Raspberry Pi, this tutorial is a great example
of using our favourite little computer for
physical computing, reacting to inputs, and
doing something useful with the results. It also
demonstrates some of the challenges you may
face when handling different types of voltage and
current. Here you’ll learn how to make a simple
motion detector that triggers a siren and sends
an alert to your smartphone when it’s triggered.
You can then make the project your own through
experimenting and adding more features.
01
Why an Automation HAT?
Many Raspberry Pi physical computing
projects directly use the GPIO to connect things
like sensors, buzzers, and LEDs. In this case,
we’re going use the incredibly versatile Pimoroni
Automation HAT. This ‘input expander’ allows
us to control devices that would normally either
be incompatible or even damage your Raspberry
PJ
Evans
A writer, developer,
tinkerer, and Milton
Keynes Raspberry
Jam wrangler. His
cat keeps setting the
siren off.
@mrpjevans
MAKER
Build an internet-
connected room guard
You’ll Need
> 12 V indoor siren
and PSU
magpi.cc/siren
> HC-SR501 PIR
sensor
magpi.cc/pir
> Automation HAT
magpi.cc/
automationhat
> Camera Module
(optional)
magpi.cc/camera Figure 1 The PIR sensor’s potentiometers (orange). Adjust
carefully with a small screwdriver, as they can be fragile
Warning!
Loud noise!
The siren used in this
tutorial is very loud
(120 dB). Always use ear
protection when testing.
TUTORIAL
42 magpi.cc Build an internet-connected room guard