I don’t have a doorbell, and while I could go out and buy a wireless one - I never pass up an opportunity to over-complicate something for the sake of learning to do something new. Today we’re dipping our toes into home security by building an automatic person-detecting doorbell system using a security camera and a Raspberry Pi.
While we’re using a doorbell sound effect in today’s project, this technology can be easily adapted to monitor other areas of your home, alerting you with a sound effect if someone’s in your garage, backyard, or anywhere else you can put a camera.
Here’s how to use a Raspberry Pi, a security camera, and a bit of machine learning to detect if someone’s at your door and play a doorbell sound effect.
What You’ll Need For This Project
- Raspberry Pi 4 or Raspberry Pi 3 with power adapter
- Desktop speakers or a megaphone with a 3.5mm input and 3.5mm cable
- Wyze Cam V2 (Wyze Cam V3 is not yet compatible)
- 2x8 GB (or larger) microSD cards, one for Raspberry Pi, another for the camera.
- Monitor with HDMI and power cables. (Optional)
How to Turn a Raspberry Pi into a Person-Detecting Doorbell
Before you get started, get your Raspberry Pi set up. If you haven’t done this before, see our article on how to set up a Raspberry Pi for the first time or how to do a headless Raspberry Pi install (without the keyboard and screen). For this project, we recommend a headless Raspberry Pi install.
1. Install git. We’ll need it to download the code from GitHub.
sudo apt-get update
sudo apt-get -y install git
2. Clone the repository to your home directory. This will ensure we have all the code and audio files we need to run the project.
git clone https://github.com/rydercalmdown/person_detecting_doorbell.git
3. Run the “make install” command to install all project dependencies. This script will take care of installing lower level dependencies, as well as the Python libraries you need for the project to run. The machine learning library we’re using to detect people is packaged within one of the Python libraries, so it may take a few minutes to install.
4. Set the 3.5mm audio output to be the default audio output in raspi-config. You do this by launching raspi-config (entering sudo raspi-config at the command prompt) and navigating to System Options -> Audio -> Headphones 1. The pi allows for audio to be outputted to either the 3.5mm analog output, or over the HDMI port. If you do not have a monitor attached, Headphones may be the only option.
# Navigate to System Options -> Audio -> Headphones 1
5. Plug your speakers into your Raspberry Pi using a 3.5mm cable.
6. Test your speakers by playing the doorbell audio file. You should hear a doorbell sound from your speakers. In my case I’m using a megaphone, but feel free to use whatever speakers you have available.
7. Flash the custom RTSP firmware to your Wyze camera using this tutorial. Installing RTSP support allows us to connect to the camera and grab frames directly with Python. You will need a Wyze V2 camera and a microSD card.
8. Get the RTSP URL value from your Wyze application, and edit the RTSP_URI variable in the Makefile to point the Raspberry Pi to your camera. You can find the RTSP URL in the “Advanced Settings” section of your Wyze application on your phone.
9. Install your camera facing your front door. You can place it anywhere you like, but I have mine mounted outside. Keep in mind the Wyze V2 is not weather proof, so I’m keeping mine in a covered area.
10. Run the “make run” command on the pi to start the doorbell system. When a person is detected in the frame, the doorbell will ring continuously with a 5 second delay in between rings until the person leaves the frame.
You can adjust the delay between rings in app.py, and modify the doorbell sound effect by replacing the .mp3 file within the repository. Now all that’s left to do is wait for people to arrive.
Pro tip: use a sound effect of barking dogs instead of a doorbell to make this more of a security system than a doorbell.
Stay on the Cutting Edge
Join the experts who read Tom's Hardware for the inside track on enthusiast PC tech news — and have for over 25 years. We'll send breaking news and in-depth reviews of CPUs, GPUs, AI, maker hardware and more straight to your inbox.
Ryder Damer is a Freelance Writer for Tom's Hardware US covering Raspberry Pi projects and tutorials.
or for 1/50th of the cost, you could use an arduino with a PIR and an audio ampReply
The legality of installed cameras is complex where I live. It might not even be legal depending on available spots to place the camera. An ugly sign would be needed to notify visitors of the camera. Then I'd have to destroy parts on the RPi so that it couldn't be turned into a recording device. Last, the camera would need to be put in a rigid housing from where it can't be vandalised or stolen.Reply
I think a much better solution would be to use a proximity sensor of some kind, avoiding all of the above issues.