IoT Project Report
IoT Project Report
ENGINEERING
COLLEGE OF E&ME, NUST, RAWALPINDI
Subject Name
Introduction to IoTs
PROJECT REPORT
SUBMITTED TO:
Dr Ali Hassan
Ma’am Malyka
SUBMITTED BY:
Students Name
1. Muhammad Mussa Kazim -404047
2. Mueed Rauf -
3. Wahaaj Nasir -
Working Principle:
Introduction: Facial Detection Lock System using an ESP32 Cam is a cutting-edge security
solution. By utilizing facial recognition technology, this system enhances access control, allowing
only authorized individuals to unlock doors. The ESP32 analyzes captured facial images, and upon
positive identification, triggers the relay to activate the solenoid lock, ensuring secure and easy
access. This technology finds applications in home security, offices, and various facilities where a
reliable and user-friendly access control system is important. A few key points regarding our
project are given below:
1. Facial Detection: The ESP32 Cam captures images using its integrated camera. It then processes
these images to perform facial detection. There are pre-trained machine learning models for facial
detection that can be used with the ESP32.
2. Decision Making: The ESP32 analyzes the detected faces and decides whether the recognized
face matches an authorized face stored in its database. If there's a match, it sends a signal to unlock
the door.
3. Control Signal: The ESP32, upon deciding to unlock the door, sends a control signal to the
relay. The relay acts as a switch, allowing a higher-voltage circuit (solenoid lock) to be controlled
by the lower-voltage ESP32.
4. Solenoid Activation: When the relay is triggered, it powers the solenoid lock. The solenoid
extends or retracts its plunger, depending on its design, to physically unlock or lock the door.
5. Power Regulation: The regulator IC ensures a stable power supply to all components,
preventing voltage fluctuations that could affect the proper functioning of the system.
In summary, the ESP32 Cam captures and processes facial images, determines if the face is
authorized, and triggers the unlocking mechanism if it is. The relay and solenoid lock physically
control the door lock based on the decision made by the ESP32. The regulator IC ensures a
consistent power supply for reliable operation.
Schematic Diagrams:
ESP-32 Cam Module:
Circuit Diagram:
Circuit Explanation:
Once we uploaded the code to the ESP-32 Cam, the above given circuit was implemented in order
to achieve our goal of a Facial Detection Lock System. We have used a 12V Battery because the
Solenoid Lock needs a 12V supply in order to Work Properly. We convert this 12 Volts to 5 Volts
using the Voltage Regulator IC because our ESP and Relay needs a 5V Supply. The Relay acts like
a Switch in our Circuit. Whenever the ESP 32 Cam detects a recognizable face, it sends a signal to
the Relay to close the switch inside it. This allows a 12V supply to the Solenoid Lock and it closes
for a Delay of 5 Seconds(because we have added a 5s delay in our code). We also ended up using a
BJT to send the signal from ESP to Relay Module to control the Voltage and Current levels as the
Solenoid Lock was attracting too much power towards it and this was becoming problematic during
the working of our project.
#include "esp_camera.h"
#include <WiFi.h>
#define CAMERA_MODEL_AI_THINKER
#define Relay 2
#define Red 13
#define Green 12
#include "camera_pins.h"
const char* ssid = ""; //Wifi Name SSID
const char* password = ""; //WIFI Password
void startCameraServer();
void setup() {
pinMode(Relay,OUTPUT);
pinMode(Red,OUTPUT);
pinMode(Green,OUTPUT);
digitalWrite(Relay,LOW);
digitalWrite(Red,HIGH);
digitalWrite(Green,LOW);
Serial.begin(115200);
Serial.setDebugOutput(true);
Serial.println();
// Other code for defining inbuilt pin configuration for Face Detection Algorithm
WiFi.begin(ssid, password);
startCameraServer();
void loop() {
if(matchFace==true && activateRelay==false)
{
activateRelay=true;
digitalWrite(Relay,HIGH);
digitalWrite(Green,HIGH);
digitalWrite(Red,LOW);
digitalWrite(33, HIGH);
prevMillis=millis(); //the millis() function returns the number of milliseconds since the Arduino started running.
}
if (activateRelay == true && millis()-prevMillis > interval)
{
activateRelay=false;
matchFace=false;
digitalWrite(Relay,LOW);
digitalWrite(Green,LOW);
digitalWrite(Red,HIGH);
}
}
// Note that the above code includes only the important and relevant part of our code which is enough to
understand the project requirements.
HARDWARE IMPLEMENTATION
Conclusion:
To sum it up, our project with the ESP32-CAM Module for Facial Detection Lock System is pretty
cool. It's like having a smart lock that recognizes faces! We connected a special programmer to
easily load the face-recognizing code onto the ESP32-CAM. This means our lock system can learn
and identify faces, making it a smart and secure way to control access. It's a neat example of how
these little modules can do big things, making security more high-tech and user-friendly.