Translate

Arduino Fingerprint Based Door Lock System

 1. Introduction

Solenoid Lock

Security systems are essential in homes, offices, and laboratories. Traditional locks can be duplicated or broken, but biometric systems provide a higher level of protection.

In this project, we design a Fingerprint Based Door Lock System using Arduino, where only authorized users can unlock the door using their fingerprint.


2. Components

  • Arduino Nano / Uno
  • Fingerprint Sensor (R307 / R305)
  • Relay Module
  • Solenoid Door Lock
  • Jumper Wires
  • Power Supply

3. Circuit and Connections

Pinout Diagram of Arduino Uno R3
Pinout Diagram R307 Fingerprint Sensor

Pinout Diagram of Single Channel Relay Module
Typical Solenoid Lock
  • Fingerprint Sensor TX → Arduino D2
  • Fingerprint Sensor RX → Arduino D3
  • Relay Input → Arduino D8
  • VCC → 5V
  • GND → GND
  • Relay Normally Closed → 12V Power Supply Positive ( choose Power Supply to the ampere of Solenoid Lock)
  • Relay Common  → Solenoid Lock Positive
  • Solenoid Lock Negative → 12V Power Supply Ground

4. Circuit Working

The fingerprint sensor scans the user's finger and converts it into a digital template.

  • If fingerprint matches stored data → Arduino activates relay → Door unlocks
  • If fingerprint does not match → Access denied
  • After a few seconds → Door locks automatically

5. Code

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

int relayPin = 8;

void setup() {
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW);

Serial.begin(9600);
finger.begin(57600);

if (finger.verifyPassword()) {
Serial.println("Sensor found");
} else {
Serial.println("Sensor not found");
while (1);
}
}

void loop() {
int id = getFingerprintID();

if (id > 0) {
digitalWrite(relayPin, HIGH);
delay(5000);
digitalWrite(relayPin, LOW);
}
}

int getFingerprintID() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return -1;

p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;

p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return -1;

return finger.fingerID;
}

6. Code Working

  • Arduino communicates with fingerprint sensor using serial communication
  • Sensor checks for fingerprint input
  • If match is found → returns ID
  • Arduino activates relay → Unlocks door
  • After delay → Relay OFF → Door locks

7. Tips

  • Enroll fingerprints before running system
  • Use external power for solenoid lock
  • Ensure TX and RX are correctly connected
  • Keep sensor clean for accurate detection

8. Uses

  • Home security systems
  • Office access control
  • Biometric attendance
  • Secure lockers

9. Conclusion

This Arduino Fingerprint Door Lock System is a reliable and secure solution for access control. It is easy to build and highly useful in real-world applications.


10. Arduino Fingerprint Enrollment Code (R307)


Step 1: Install Required Library

Open Arduino IDE:

  • Go to Sketch → Include Library → Manage Libraries
  • Search and install: Adafruit Fingerprint Sensor Library

💻 Enrollment Code

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

int id;

void setup() {
Serial.begin(9600);
while (!Serial);

Serial.println("Fingerprint Enrollment");

finger.begin(57600);

if (finger.verifyPassword()) {
Serial.println("Sensor detected!");
} else {
Serial.println("Sensor not found");
while (1);
}
}

void loop() {
Serial.println("Enter ID (1 to 127): ");
while (Serial.available() == 0);
id = Serial.parseInt();

if (id == 0) {
Serial.println("Invalid ID");
return;
}

Serial.print("Enrolling ID #");
Serial.println(id);

enrollFingerprint(id);
}

void enrollFingerprint(int id) {
int p = -1;

Serial.println("Place finger on sensor");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
}

p = finger.image2Tz(1);
if (p != FINGERPRINT_OK) {
Serial.println("Error converting image");
return;
}

Serial.println("Remove finger");
delay(2000);
while (finger.getImage() != FINGERPRINT_NOFINGER);

Serial.println("Place same finger again");
p = -1;
while (p != FINGERPRINT_OK) {
p = finger.getImage();
}

p = finger.image2Tz(2);
if (p != FINGERPRINT_OK) {
Serial.println("Error converting image");
return;
}

p = finger.createModel();
if (p != FINGERPRINT_OK) {
Serial.println("Error creating model");
return;
}

p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Fingerprint Stored Successfully!");
} else {
Serial.println("Error storing fingerprint");
}
}

▶️ How to Use

Step 1. Upload code
Step 2. Open Serial Monitor (set 9600 baud)
Step 3. You will see message like:

             Ready to enroll a fingerprint!
            
Step 4. Enter ID (like 1, 2, 3, 4, …127)

           Type a number (example: 1) and press Enter

    This ID is used to identify the person later.

  1. Follow instructions:

    1. Place finger on sensor
    2. Remove finger
    3. Place same finger again

    You will see:

    Image taken
    Image converted
    Stored!
   Step 5. Done
             Now your fingerprint is stored in sensor memory 

🔍 Important Tips

  • Use same finger twice properly
  • Keep finger clean
  • Don’t move finger while scanning
  • You can store multiple users (ID 1, 2, 3,…127)
  • Don’t use ID 0
  • Max IDs ≈ 127 fingerprints
  • If error → clean sensor & retry
  • Use stable power (very important ⚠️)

Now you can load the original code and the stored finger will unlock the solenoid valve or servo motor


തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.