Smart door lock security system based on ESP32
Security is something that we need to consider in our daily life and digital locks have become an essential part of these security systems. The fingerprint sensor based system is one of the most secure door lock systems as it has the ability to identify and differentiate each person without making mistakes. Fingerprint based security systems can be used in many places such as industries, offices, and schools and even in our homes.
This project is a perfect combination of biometrics and embedded system technology. We have seen password based security systems and RFID based security systems which are insecure and can be accessed by anyone. The main feature of fingerprint is that it is unique. It provides a higher level of security than other security systems.
So in this article, we will learn how to make a door lock security system based on ESP32 and fingerprint sensor. We will connect the R305 fingerprint sensor module to the ESP32 development board, use the solenoid valve to lock/unlock the door, and use the 0.96-inch SSD1306 OLED display to display the matching/unmatching fingerprint and the locked and unlocked status of the door.
Required Components
● ESP32 development board
● R305 / R307 fingerprint sensor
● 0.96-inch OLED display
● 12V electromagnetic lock
● 5V relay
● Buzzer
● BC547 NPN transistor
● 12V power adapter
R305 Fingerprint Sensor Module
The R305 fingerprint sensor has a high-performance DSP chip inside that can do image rendering, calculations, feature finding, and searching. Use TTL serial to connect to any microcontroller or system and packet sends to take pictures, detect prints, hash, and search . You can also register new fingerprints directly – up to 162 fingerprints can be stored in the onboard flash memory. There is a red LED indicator in the lens that lights up during shooting so that you know it is working.
Fingerprint processing consists of two parts: fingerprint registration and fingerprint matching (matching can be 1:1 or 1:N). When registering, the user needs to enter the finger twice. The system will process the finger image twice, generate a finger template based on the processing result and store the template. When matching, the user enters the finger through the optical sensor, and the system will generate a template of the finger and compare it with the template of the finger library. For 1:1 matching, the system will compare the test finger with the specific template specified in the module; for 1:N matching or searching, the system will search for matching fingers in the entire finger library. In both cases, the system will return a matching result (success or failure).
0.96-inch OLED display
The following is a 0.96 inch blue OLED display module. The display module can be interfaced with any microcontroller using SPI/IIC protocol. The resolution is 128×64. The package includes the display circuit board, the display, and a 4-pin male connector pre-soldered to the board.
OLED (Organic Light Emitting Diode) is a self-luminous technology consisting of multiple layers of organic thin films placed between an anode and a cathode. Compared to LCD technology, OLED does not require a backlight. OLED has high application potential in almost all types of displays and is considered the ultimate technology for the next generation of flat panel displays.
Electromagnetic lock
The 12V electromagnetic lock has a tab with an angled cutout and a mounting bracket. It is actually an electronic lock designed for cabinets, safes, or door locks. When 9-12VDC is applied, the locking pin pulls in and the door can be opened . It does not use any power at this time. For an automatic door lock system, installation is very easy.
Circuit connection of door lock security system
Below is the circuit schematic of the biometric door lock security system based on ESP32 and R305 fingerprint sensor. ESP32 is the master of the circuit and can control all other components, including fingerprint sensor, electromagnetic lock, OLED display, buzzer, etc. This schematic was designed in EasyEDA.
It is very difficult to assemble so many components on a breadboard. Therefore, we made a PCB and soldered it to make it easy to assemble. The final assembled circuit is as follows.
Source code: Register fingerprint
Before using this door lock security system, you need to register your fingerprint. The registered fingerprint can be used to open the door. Unregistered users will not be able to get any access. Given below is the code link for registering fingerprint . Download this code at github and upload it to the ESP32 development board.
But before that, add the following libraries:
After uploading the code, you can open the serial monitor and set the baud rate to 57600. You can then follow the instructions in the serial monitor interface to enroll your fingerprint.
When registering, the user needs to enter the fingerprint twice. The system will process the fingerprint image twice, generate a fingerprint template based on the processing results and store the template. When matching fingerprints, the user enters the fingerprint through the optical sensor, and the system will generate a template of the fingerprint and compare it with the template of the fingerprint library.
Door lock security system source code
Once the fingerprint is registered, you can upload the complete code to the ESP32 development board. The code is able to lock and unlock the door based on the match and mismatch conditions. The complete code link is Door Lock.ino located on github .
System operation and operation results
After uploading the code, the OLED will display the fingerprint icon and the fingerprint sensor will start blinking and give instructions for placing your fingerprint.
If you put an unregistered fingerprint on the sensor, the OLED will display ” Invalid Finger, Try again “. At this time, the relay does not turn on the electromagnetic lock, so the door will not open.
If you put the registered fingerprint on the sensor, the OLED will display ” Door Unlocked, Welcome “. At this time, the relay turns on the electromagnetic lock and the door lock will open.
https://www.mediafire.com/file/uz77b3i06ob8e90/Finger_Enroll.rar/file
https://www.mediafire.com/file/llb1czbzoy962i5/Fingerprint_Door_Lock.rar/file