Smart Face Recognition Door Lock System
by dmcits in Circuits > Microcontrollers
7 Views, 1 Favorites, 0 Comments
Smart Face Recognition Door Lock System

A Raspberry Pi + Arduino project that uses facial recognition to unlock a door (servo motor) with visual and sound feedback! Based on: Core Electronics Guide
Supplies
Raspberry Pi 4 or 5 recommended
PiCamera or USB webcam
Arduino Uno
Servo motor - SG90
Common cathode RGB LED
Piezo buzzer
Jumper wires
Resistors: 220Ω
Breadboard
USB cable (to connect Pi ↔ Arduino)
Install Raspberry Pi OS
Using Raspberry Pi Imager, install the latest Bookworm OS on your Pi
Set Up Your Raspberry Pi for Face Recognition
Based on: Core Electronics Guide
1. Create a Virtual Environment
💡 You’ll see (face_rec) in your terminal prompt—this means it’s active.
2. Install Dependencies
Train Your Face Recognition Model
1. Capture Training Images
Create a dataset/ folder with subfolders named after each person (e.g., john, alice). Capture photos using:
📂 Save each person’s photos in their respective folder. (Take multiple photos so the its more accurate recognizing faces)
2. Encode Faces
Generate the face encodings:
This creates a encodings.pickle file used for recognition.
Build the Arduino Circuit
.png)

Servo Motor - D2
RGB LED - Red → D3 Green → D5 Blue → D6
Piezo Buzzer - D7
Downloads
Run Real-Time Face Detection
Use this modified script: facial_recognition_hardware.py
Key Customization:
- Sends "pass\n" or "fail\n" to the Arduino over serial (/dev/ttyACM0)
- Compares faces against authorized names list
- Draws bounding boxes and labels on live camera feed
I modified facial_recognition_hardware.py so that the Raspberry Pi communicates to the Arduino
To run:
Make sure the authorized_names array has the names people from your dataset
Test the System:
- Connect the Pi to the Arduino
- Watch the Arduino react:
- Green LED + Servo turns → ✅ Authorized face
- Red LED + Buzz → ❌ Unknown face