Skip to content

IoT-based smart door lock using ESP32‑CAM with real‑time face recognition and remote access control.

Notifications You must be signed in to change notification settings

vendotha/facial-detection-security

Repository files navigation

🔒 IoT Face Recognition Door Lock System

ESP32-CAM IoT Status License

A smart home security system that leverages the power of ESP32-CAM microcontroller to perform real-time facial recognition and automatically control a 12V electronic door lock. This project demonstrates the integration of computer vision, embedded systems, and IoT technologies to create a secure, contactless access control solution.

🚧 Project Status: Fully functional prototype - suitable for learning and demonstration purposes. Consider additional security measures for production use.


🎯 Project Overview

This system eliminates the need for physical keys or cards by using facial recognition technology. When a registered face is detected, the system automatically unlocks the door, providing seamless and secure access control. The entire system runs on an ESP32-CAM module, making it cost-effective and easy to deploy.

🔍 How It Works

  1. Face Detection: ESP32-CAM continuously monitors for faces in its field of view
  2. Recognition: Detected faces are compared against enrolled user profiles
  3. Access Control: Authorized faces trigger the door lock mechanism
  4. Remote Monitoring: Web interface allows real-time monitoring and user management

✨ Key Features

🎥 Computer Vision

  • Real-time face detection using ESP32-CAM's onboard processing
  • Multiple user enrollment with persistent storage
  • Confidence-based recognition to minimize false positives

🌐 IoT Connectivity

  • Wi-Fi enabled for remote monitoring and control
  • Web-based interface for live video streaming
  • User management through browser interface
  • Real-time status updates and notifications

🔧 Hardware Integration

  • 12V electronic door lock control
  • Transistor-based switching for safe voltage isolation
  • Status LED indicators for visual feedback
  • Low-power operation suitable for continuous use

🛡️ Security Features

  • Encrypted face data storage
  • Configurable recognition threshold
  • Access logging (expandable feature)
  • Fail-safe operation in case of system errors

🛠️ Hardware Components

Component Purpose Specifications
ESP32-CAM Main controller & camera AI-Thinker ESP32-CAM module
Electronic Door Lock Access control mechanism 12V solenoid or electromagnetic lock
TIP122 Transistor High-current switching NPN Darlington transistor
7805 Voltage Regulator Power supply regulation 5V output, 1A capacity
FTDI232 Adapter Programming interface USB-to-TTL converter
Resistors & Capacitors Circuit protection Various values for driver circuit

📋 Circuit Diagram (Text Representation)

┌─────────────┐    ┌──────────────┐    ┌─────────────┐
│   ESP32-CAM │    │   TIP122     │    │  12V Door   │
│             │    │   Driver     │    │    Lock     │
│     GPIO12  ├────┤   Circuit    ├────┤             │
│             │    │              │    │             │
│   Wi-Fi     │    │   7805 Reg   │    │   Status    │
│  Interface  │    │   Circuit    │    │    LED      │
└─────────────┘    └──────────────┘    └─────────────┘
       │                   │
       │                   │
   ┌───▼───┐          ┌────▼────┐
   │  Web  │          │  Power  │
   │ User  │          │ Supply  │
   │   UI  │          │  12V    │
   └───────┘          └─────────┘

🚀 Quick Start Guide

📋 Prerequisites

Software Requirements:

  • Arduino IDE 1.8.x or newer
  • ESP32 board package installed
  • Basic knowledge of Arduino programming

Hardware Setup:

  • Assembled circuit as per connection diagram
  • Stable 12V power supply
  • Wi-Fi network credentials

🔧 Installation Steps

1. Arduino IDE Configuration

# Add ESP32 board manager URL
File → Preferences → Additional Boards Manager URLs:
https://dl.espressif.com/dl/package_esp32_index.json

# Install ESP32 board package
Tools → Board → Board Manager → Search "ESP32" → Install

2. Hardware Connections

ESP32-CAM Pin FTDI232 Pin Purpose
U0T TX Serial transmission
U0R RX Serial reception
GND GND Ground connection
5V 5V Power supply
GPIO0 GND Programming mode (remove after flashing)

3. Code Upload Process

  1. Connect GPIO0 to GND (programming mode)
  2. Select Board: "ESP32 Wrover Module"
  3. Choose correct COM Port
  4. Upload Code_FaceRecognitionDoorLock_ESP32CAM_01.ino
  5. Disconnect GPIO0 from GND
  6. Press RESET button
  7. Open Serial Monitor (115200 baud)
  8. Note the displayed IP address

4. System Configuration

  1. Open web browser
  2. Navigate to http://<ESP32-IP-ADDRESS>
  3. Use the interface to enroll authorized faces
  4. Test the recognition system
  5. Configure unlock duration and sensitivity

📁 Project Structure

iot-face-recognition-door-lock/
├── 📄 Code_FaceRecognitionDoorLock_ESP32CAM_01.ino  # Main Arduino sketch
├── 📄 app_httpd.cpp                                 # Web server implementation
├── 📄 camera_index.h                                # HTML interface definitions
├── 📄 camera_pins.h                                 # Pin configuration
├── 📄 README.md                                     # This documentation
├── 📄 LICENSE                                       # MIT License
└── 📁 docs/                                         # Additional documentation
    ├── 📄 HARDWARE_SETUP.md                         # Detailed hardware guide
    ├── 📄 TROUBLESHOOTING.md                        # Common issues & solutions
    └── 📄 SECURITY_CONSIDERATIONS.md                # Security best practices

🖥️ Web Interface Features

📱 Control Panel

  • Live Video Stream: Real-time camera feed
  • Face Enrollment: Add new authorized users
  • User Management: View and delete enrolled faces
  • System Status: Monitor lock status and connectivity
  • Configuration: Adjust recognition sensitivity

🎛️ Settings Panel

  • Recognition Threshold: Fine-tune detection accuracy
  • Unlock Duration: Set how long door remains unlocked
  • Auto-lock Timer: Configure automatic re-locking
  • Network Configuration: Update Wi-Fi credentials

🔒 Security Considerations

⚠️ Important Notes

  • Prototype Status: This is a learning project - additional security measures recommended for production
  • Physical Security: Ensure ESP32-CAM is mounted securely and protected from tampering
  • Network Security: Use WPA3 encryption on your Wi-Fi network
  • Regular Updates: Keep firmware updated with latest security patches

🛡️ Recommended Enhancements

  • Implement HTTPS for web interface
  • Add backup authentication method (PIN/RFID)
  • Implement access logging and monitoring
  • Add intrusion detection capabilities
  • Use encrypted storage for face data

🐛 Troubleshooting

Common Issues & Solutions

🔴 ESP32-CAM won't connect to Wi-Fi

Symptoms: Serial monitor shows connection timeouts Solutions:

  • Verify Wi-Fi credentials in code
  • Check signal strength at installation location
  • Ensure 2.4GHz network (ESP32 doesn't support 5GHz)
  • Try different power supply (minimum 1A recommended)
🔴 Face recognition accuracy issues

Symptoms: False positives or failed recognition Solutions:

  • Improve lighting conditions
  • Re-enroll faces with better image quality
  • Adjust recognition threshold in settings
  • Clean camera lens
  • Ensure faces are well-centered during enrollment
🔴 Door lock not activating

Symptoms: Recognition works but lock doesn't trigger Solutions:

  • Check power supply to lock mechanism
  • Verify transistor circuit connections
  • Test lock manually with direct 12V
  • Check GPIO pin configuration

🔮 Future Enhancements

🚀 Planned Features

  • Mobile App: Dedicated smartphone application
  • Cloud Integration: Remote monitoring via cloud platform
  • Multiple Camera Support: Cover multiple entry points
  • Voice Notifications: Audio feedback for recognition events
  • Temporal Access Control: Time-based access restrictions
  • Integration APIs: Connect with home automation systems

💡 Community Contributions Welcome

  • Additional security features
  • UI/UX improvements
  • Hardware compatibility extensions
  • Documentation translations
  • Performance optimizations

📚 Learning Resources

📖 Related Topics

  • Computer Vision: Face detection algorithms and implementation
  • Embedded Systems: ESP32 programming and peripheral control
  • IoT Security: Best practices for connected devices
  • Web Development: Creating responsive embedded interfaces

🎓 Recommended Reading


🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

🔄 Development Process

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

📋 Contribution Areas

  • Bug fixes and improvements
  • Documentation updates
  • Hardware compatibility
  • Security enhancements
  • Feature additions

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🎁 Attribution

If you use this project in your work, please provide attribution:

IoT Face Recognition Door Lock System by [Your Name]
https://github.com/yourusername/iot-face-recognition-door-lock

📞 Support & Community

💬 Get Help

  • Issues: Report bugs and request features via GitHub Issues
  • Discussions: Join community discussions for questions and ideas
  • Wiki: Check the project wiki for additional documentation

🌟 Show Your Support

If this project helped you, please consider:

  • Starring the repository
  • 🍴 Forking for your own modifications
  • 📢 Sharing with others who might find it useful
  • 💡 Contributing improvements back to the community

🏷️ Tags

esp32-cam face-recognition iot smart-home embedded-systems computer-vision arduino door-lock security wifi web-interface diy maker electronics automation


⚡ Ready to build your own smart security system? Star this repo and get started!

About

IoT-based smart door lock using ESP32‑CAM with real‑time face recognition and remote access control.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published