Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-CAM and Arduino UNO Based Face Recognition Door Lock System with 12V Solenoid Lock

View and Edit Project In Cirkit DesignerImage of ESP32-CAM and Arduino UNO Based Face Recognition Door Lock System with 12V Solenoid Lock

Circuit Documentation

Summary

This circuit is a door lock system using face recognition. It consists of an ESP32-CAM module for face recognition, an Arduino UNO, a 12V solenoid lock, a 1-channel relay module, and a 12V power supply. When a recognized face is detected by the ESP32-CAM, the relay activates the solenoid lock to unlock the door.

Component List

12V Solenoid Lock

ESP32-CAM

Arduino UNO

USB Plug

1 Channel Relay 5V

12V Power Supply

Comment

Wiring Details

12V Solenoid Lock

ESP32-CAM

Arduino UNO

USB Plug

1 Channel Relay 5V

12V Power Supply

Documented Code

Arduino UNO Code

/*
 * This Arduino Sketch is part of a door lock system using face recognition.
 * The microcontroller with instance ID fc6e7b11-07d8-4752-9288-9e7c96f60b35
 * is connected to a 12V Solenoid Lock and a 1-Channel Relay module. The relay
 * is controlled by an ESP32-CAM module, which performs face recognition. When
 * a recognized face is detected, the relay activates the solenoid lock to
 * unlock the door.
 */

const int relayPin = 4; // Relay signal pin connected to ESP32-CAM IO4

void setup() {
  pinMode(relayPin, OUTPUT); // Set relay pin as output
  digitalWrite(relayPin, LOW); // Ensure relay is off initially
}

void loop() {
  // Placeholder for face recognition logic
  // This should be replaced with actual communication from ESP32-CAM
  bool faceRecognized = true; // Simulated face recognition result

  if (faceRecognized) {
    digitalWrite(relayPin, HIGH); // Activate relay to unlock door
    delay(5000); // Keep the door unlocked for 5 seconds
    digitalWrite(relayPin, LOW); // Deactivate relay to lock door
  }

  delay(100); // Short delay to avoid rapid toggling
}

ESP32-CAM Code

#include <WiFi.h>

// Configuration du relais
#define RELAY_PIN 12

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Assurez-vous que le relais est désactivé au démarrage

  // Configuration Wi-Fi ou reconnaissance faciale (ajoutez vos propres paramètres ici)
  Serial.begin(115200);
  Serial.println("ESP32-CAM ready!");
}

void loop() {
  // Simule la reconnaissance faciale (remplacez par votre code)
  bool faceRecognized = true; // Exemple : Remplacez par une condition réelle

  if (faceRecognized) {
    digitalWrite(RELAY_PIN, HIGH); // Active le relais
    Serial.println("Face recognized! Door unlocked.");
    delay(5000); // Maintient la serrure ouverte pendant 5 secondes
    digitalWrite(RELAY_PIN, LOW);  // Désactive le relais
    Serial.println("Door locked.");
  }

  delay(1000); // Pause pour éviter des boucles rapides
}

Additional Arduino UNO Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and documented code for the microcontrollers involved.