There’s a Raspberry Pi Zero 2 W tucked behind a picture in my hallway. It’s not powering a sensor dashboard, a security camera, or anything remotely useful. Instead, it plays a deliberately annoying sound clip every time someone walks by. It’s absurd, petty, and probably my favorite project on the whole network.

What started as a quick experiment with leftover parts has turned into something far more entertaining. Every motion trigger sets off a perfectly timed audio file, whether it’s a dramatic scream or a painfully cheesy sound effect. It gets a reaction every single time, usually a groan or a startled laugh. And the best part is, I never have to explain myself, because the Pi does all the talking for me.

👁 I built a wireless Android Auto dongle with just a Raspberry Pi Zero 2 W-1
I built a wireless Android Auto dongle with just a Raspberry Pi Zero 2 W

Forget spending a small fortune giving your car stereo wireless Android Auto capability, you can do it with a tiny SBC and a GitHub repository

By  Jeff Butts

Why I turned my hallway into a trap

Sometimes a prank is the perfect project

Like a lot of Raspberry Pi users, I’ve accumulated a stash of random parts that didn’t quite make it into serious builds. One day, I found a PIR motion sensor, a spare Zero 2W, and some leftover pieces from a Pi Jukebox project in the same drawer. Instead of turning them into a basic smart home sensor or security device, I decided to go in the complete opposite direction. That’s when the hallway prank was born.

At first, I wasn’t sure how well it would work. I figured maybe the audio would be too delayed or too quiet to get a reaction. But once I heard that first startled yelp from across the room, I knew I was onto something. It didn’t need a fancy display or deep integration, just a loud, well-timed noise and a little mischief.

The Pi’s tiny form factor made it easy to hide, and since it runs headless with no display, I could tuck it behind a picture frame or stick it on a high shelf. I didn’t even need a Wi-Fi connection. It just boots, listens for movement, and reacts with delightful annoyance. That’s more than enough to justify its place on my network.

How the prank setup actually works

Simple parts, Python, and audio playback

The core components of this setup are minimal, but they work surprisingly well together. The Pi Zero 2 W runs Raspberry Pi OS Lite, with no desktop environment to weigh it down. I added a 3W stereo speaker bonnet to the Pi Zero, along with a small speaker plugged into the bonnet. A wall adapter powers everything.

I wired the PIR motion sensor to GPIO 17 using three female-to-female jumper wires, and for now, I’ve got everything secured using adhesive putty squares.

The Python script utilizes the gpiozero library to detect motion and then executes a shell command to play a sound file. I experimented with a few playback tools, but mpg123 ended up being the fastest and most reliable on this low-powered board.

A two-minute cooldown is built in to prevent it from looping endlessly while someone walks back and forth. That timing alone helps keep the audio surprising, not just repetitive. When the Pi reboots, a cron job runs a small shell script to invoke the Python program.

It’s all local, too. No cloud, no webhooks, and no dependency on any smart home hub. This device boots up in under 30 seconds and runs in the background with minimal power draw. It’s lightweight, responsive, and ridiculously entertaining for how little effort it took to build.

Why I keep making it worse

And why nobody can convince me to stop

Every time someone complains about it, I make it just a little more irritating. One week, it was the Wilhelm scream. The next was a distorted version of a clown horn. For a while, it was a robotic voice saying “intruder detected” in a tone that sounded ominous enough to confuse visitors. I’ve also had one play Rick Astley’s “Never Gonna Give You Up” whenever someone got close enough.

Some of my friends have begged me to switch to a more polite chime or at least lower the volume. But that completely misses the point. This Pi doesn’t exist to be helpful or pleasant. It exists to disrupt the calm of a hallway with maximum audio mischief, and I wouldn’t have it any other way.

Even when I’m home alone, I catch myself walking past it just to hear the sound go off. It’s a tiny burst of amusement in the middle of an ordinary day. As far as I’m concerned, that makes it more valuable than half the other smart devices I’ve set up. Sometimes, fun is reason enough.

How to build your own version

Quick build with minimal components required

To recreate this project, you will need only a few inexpensive parts and approximately an hour of your time. You don’t need a soldering iron or a custom PCB. Everything is connected with jumper wires, and the code runs directly from the terminal. Just be prepared for people to love it or hate it—there’s not much in between.

Below is the materials list, a simple wiring guide, and the Python script I used. You can swap out the audio file for anything you like, whether it’s a meme sound, dramatic music, or something wildly inappropriate for a hallway. That flexibility is what makes this project so much fun to tweak.

Once you’ve got it set up, test it a few times to get the cooldown timing just right. If you make it too short, it’ll trigger constantly and lose its charm. Make it too long and you’ll miss those golden moments when someone walks by twice in quick succession. Find that sweet spot, and the rest takes care of itself.

Materials list

  • Raspberry Pi Zero 2W (with Raspberry Pi OS Lite installed)
  • PIR motion sensor (HC-SR501 or similar)
  • A stereo speaker bonnet, such as the Adafruit I2S 3W Speaker Bonnet for Raspberry Pi
  • A speaker (or two) small enough to hide away and plug into the bonnet.
  • Male-to-female jumper wires (3 total)
  • 5V 2.5A power supply with USB cable
  • MicroSD card (8GB or more)
  • Audio clip in MP3 or WAV format
  • Access to terminal (via SSH or USB gadget serial)

Wiring diagram (described)

  • PIR VCC pin to a 5V through-hole on the stereo bonnet
  • PIR GND pin to a GND through-hole on the stereo bonnet
  • PIR OUT pin to through-hole 17 on the bonnet, which is attached to the Pi’s GPIO pin 17

Position the PIR sensor so it points into the area you want to monitor. It has a reasonably wide detection angle, so placing it in a corner often works best.

Python script

from gpiozero import MotionSensor
from time import sleep
import os

pir = MotionSensor(17) $ PIR is on GPIO17
cooldown = 120 # 2 minutes, so it doesn't trigger too frequently

def play_sound():
 os.system("mpg123 -q /home/pi/prank.mp3")

while True:
 # Wait for the PIR to detect motion
 pir.wait_for_motion()

 # Get 'em!
 play_sound()

 # Now we wait a bit before targeting our next victim
 sleep(cooldown)

Make sure to install mpg123 with sudo apt install mpg123, and place your sound file at /home/pi/prank.mp3 or change the path in the script accordingly. Enable the script to run on boot if you want it to be fully headless.

A prank project with staying power

This might be the simplest Raspberry Pi project I’ve built, but it’s the one that gets talked about the most. It’s inexpensive, easy to build, and gets strong reactions from visitors. Whether it makes them laugh, wince, or jump, the result is always worth it. If you’ve got a few spare parts lying around, give it a try. Just don’t be surprised if you end up loving it as much as I do.