Who can it be now? How to Build a Raspberry Pi Doorbell that Recognizes Friends

Facial-Recognition Doorbell with a Raspberry Pi
(Image credit: Tom's Hardware)

I want to buy a smart doorbell, but the cost of them is a little outside of my budget. Instead, I’m using a Raspberry Pi, a speaker system, and a camera to build a smart doorbell system for a fraction of the cost.

In our last project, we created a doorbell system which rang when a person was at the door. This time we’ll expand on the code to allow the project to identify when people we know are at the door, and announce it accordingly. This will let us choose to either run to the door, or hide upstairs when our friends or inlaws drop by unexpectedly. 

What You’ll Need For This Project

How to Turn a Raspberry Pi into a Facial Recognition Doorbell System 

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.

cd ~/
git clone https://github.com/rydercalmdown/facial_recognition_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. This should take about 10-15 minutes on a Raspberry Pi 4.

cd ~/facial_recognition_doorbell/
make install

(Image credit: Tom's Hardware)

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. 

sudo raspi-config
# Navigate to System Options -> Audio -> Headphones 1

(Image credit: Tom's Hardware)

5. Plug your speakers into your Raspberry Pi using a 3.5mm cable. 

(Image credit: Tom's Hardware)

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. 

mpg321 /home/pi/facial_recognition_doorbell/src/audio/doorbell.mp3

(Image credit: Tom's Hardware)

7. Test text to speech on your pi by running the following command. You should hear the text spoken out loud through your speakers.

say ‘hello there’
# Press Ctrl + C to exit if stuck

8. 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.

9. 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.

cd ~/facial_recognition_doorbell/
nano Makefile
# STREAM_URI=rtsp://your_username:your_password@camera_ip_address/live

10. Install your camera facing outwards from your front door. Keep in mind the Wyze V2 is not weather proof, so I’m keeping mine in a covered area. Ideally the camera should be mounted above the door pointing directly towards any person who would approach. This allows the facial recognition to work best. 

(Image credit: Tom's Hardware)

11. Download photos of known people and save them with their file names. Any .jpeg, .jpg or .png photo with someone’s face will work. There should be only one face per photo, and it’s not necessary to use more than one photo for each person. I have one for each one of my friends that comes by my house.

ryder.jpeg

(Image credit: Tom's Hardware)

12. Copy the photos of known people into the src/faces directory. 

mv ryder.jpeg /home/pi/facial_recognition_doorbell/src/faces/

13. Run the “make run” command on the pi to start the doorbell system. The system will first look for the detection of a person. When a person is detected, the doorbell will ring, and the system will start identifying any known faces from the faces directory. If a face is found, the system will announce the person at the door using text to speech. 

(Image credit: Tom's Hardware)

We now have a system that will ring whenever a person is at the door, and announce their name if we have their photo on file. 

Ryder Damen
Freelance Writer

Ryder Damer is a Freelance Writer for Tom's Hardware US covering Raspberry Pi projects and tutorials.

  • velocityg4
    More importantly. The system needs to recognize if your friend has beer with them. 🍺
    Reply
  • King_V
    Well, I don't want just a text-to-speech "hello there" . . I would totally need it to be a scary, metallic voice saying "HALT AND IDENTIFY" to whomever shows up at the door.

    Because... uh... reasons!
    Reply
  • USAFRet
    King_V said:
    Well, I don't want just a text-to-speech "hello there" . . I would totally need it to be a scary, metallic voice saying "HALT AND IDENTIFY" to whomever shows up at the door.

    Because... uh... reasons!
    For that, you just need motion detection.

    "HALT! Enter your passcode on the keypad, or turn around and leave. You have 10 seconds to comply."

    Of course, the sensor needs to be very robust and focused.
    Any passing cat or rabbit might trigger it.
    Reply
  • Mikeunif
    Whish if I can use a telegram bot to open the door if anyone in the photos come near the camera
    Reply
  • SkRThatOneDude
    You may wish to add a disclaimer that some states (such as Illinois) have biometric privacy laws that would make collecting the data for this system without the subject first opting in illegal.

    This is why Nest does not have this feature enabled for users in some states.
    Reply
  • USAFRet
    SkRThatOneDude said:
    You may wish to add a disclaimer that some states (such as Illinois) have biometric privacy laws that would make collecting the data for this system without the subject first opting in illegal.

    This is why Nest does not have this feature enabled for users in some states.
    Not disputing your comment, but what specific law or regulation speaks to this?
    Reply
  • SkRThatOneDude
    USAFRet said:
    Not disputing your comment, but what specific law or regulation speaks to this?
    For Illinois specifically, the Biometric Information Privacy Act of 2008 is the law preventing the collection of facial recognition data. I'm not sure of any specific criminal damages relating to small operations, but I personally got a sizeable settlement from when I worked at Walmart and wasn't given an opt out from biometric login on the cash recycler machines.
    Reply
  • USAFRet
    SkRThatOneDude said:
    For Illinois specifically, the Biometric Information Privacy Act of 2008 is the law preventing the collection of facial recognition data. I'm not sure of any specific criminal damages relating to small operations, but I personally got a sizeable settlement from when I worked at Walmart and wasn't given an opt out from biometric login on the cash recycler machines.
    https://www.ilga.gov/legislation/ilcs/ilcs3.asp?ActID=3004&ChapterID=57
    Doesn't seem to 'prevent the collection'.

    The subject must be notified and agree.

    So in this context, these are your 'friends'.
    "Hey, Fred, sign this and my my door will automaticaly see and know you, and open upon seeing your face."

    Anyone "Not Fred" is not recognized or saved. As such, presumably not afoul of the regulation.
    Reply
  • dimar
    Is it possible for voice to sound like ED-209 from Robocop?
    Reply
  • Andi7032
    can you share a short video ?
    Reply