
Components Required
- Arduino Uno
- Adafruit Fingerprint Sensor
- 16×2 LCD Display (Optional)
- Relay Module
- Connecting Wires
Code Setup
The code uses Adafruit_Fingerprint.h
to interface with the fingerprint sensor, set up the serial communication, and handle fingerprint enrollment and identification.
Step-by-Step Guide
1. Circuit Connection
- Connect TX of Fingerprint Sensor to Pin 2 of Arduino.
- Connect RX of Fingerprint Sensor to Pin 3 of Arduino.
- Connect Relay Module to Pin 4 of Arduino.
- Ensure 5V and GND connections are securely made to power the sensor and relay.
2. Code Walkthrough
- Include Required Libraries
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
2. Initialize Components
SoftwareSerial mySerial(2, 3); // Fingerprint sensor on pins 2 (RX) and 3 (TX)
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
#define RELAY_PIN 4
#define ACCESS_DELAY 3000
3. Setup Function
- Start the serial communication at
9600
baud for debugging. - Initialize the fingerprint sensor at
57600
baud. - Check for sensor detection and readiness.
- Set
RELAY_PIN
as an output and turn it off initially.
void setup() {
Serial.begin(9600);
finger.begin(57600);
if (!finger.verifyPassword()) {
Serial.println("Fingerprint sensor not found!");
while (1) { delay(1); }
}
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); // Switch off relay initially
}
3. Fingerprint Enrollment and Verification
- Fingerprint Enrollment:
- The user can assign a unique ID to each fingerprint for storage.
- Follow the on-screen instructions for enrolling and verifying a fingerprint.
- Fingerprint Verification:
- The system verifies fingerprints using
getFingerprintEnroll()
andgetFingerPrint()
. - If verified, the system triggers the relay to unlock the connected device for
3 seconds
(ACCESS_DELAY).
- The system verifies fingerprints using
4. Testing the System
- Upload the code to the Arduino and open the Serial Monitor to follow the enrollment process.
- Once fingerprints are stored, place a finger on the sensor to verify if it grants access by unlocking the relay for the set duration.
Daigram

FingerPrint_Lock_System Cod
#include <Adafruit_Fingerprint.h>
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
#define RELAY_PIN 4
#define ACCESS_DELAY 3000 // Keep lock unlocked for 3 seconds
void setup()
{
// set the data rate for the sensor serial port
finger.begin(57600);
delay(5);
if (finger.verifyPassword())
{
}
else
{
while (1) { delay(1); }
}
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); //Switch off relay initially. Relay is LOW level triggered relay so we need to write HIGH.
}
void loop()
{
if ( getFingerPrint() != -1)
{
digitalWrite(RELAY_PIN, LOW);
delay(ACCESS_DELAY);
digitalWrite(RELAY_PIN, HIGH);
}
delay(50); //Add some delay before next scan.
}
// returns -1 if failed, otherwise returns ID #
int getFingerPrint()
{
int 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;
// found a match!
return finger.fingerID;
}
FingerPrint_Enroll Cod
#include <Adafruit_Fingerprint.h>
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
uint8_t id;
void setup()
{
Serial.begin(9600);
while (!Serial);
delay(100);
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword())
{
Serial.println("Found fingerprint sensor!");
}
else
{
Serial.println("Did not find fingerprint sensor :(");
while (1) { delay(1); }
}
Serial.println(F("Reading sensor parameters"));
finger.getParameters();
finger.getTemplateCount();
Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX);
Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX);
Serial.print(F("Capacity: ")); Serial.println(finger.capacity);
Serial.print(F("Security level: ")); Serial.println(finger.security_level);
Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX);
Serial.print(F("Packet len: ")); Serial.println(finger.packet_len);
Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate);
Serial.print(F("Total finger prints stored: ")); Serial.println(finger.templateCount);
}
uint8_t readnumber(void)
{
uint8_t num = 0;
while (num == 0)
{
while (! Serial.available());
num = Serial.parseInt();
}
return num;
}
void loop()
{
Serial.println("\n\nReady to enroll a fingerprint!");
Serial.println("Please type in -1 to delete all the stored finger prints...");
Serial.println("Please type in the ID # (from 1 to 127) you want to save the finger as...");
id = readnumber();
if (id == 0) // ID #0 not allowed, try again!
{
return;
}
if (id == uint8_t(-1))
{
Serial.print("Cleared all finger prints from database");
finger.emptyDatabase();
return;
}
Serial.print("Enrolling ID #");
Serial.println(id);
while (! getFingerprintEnroll() );
}
uint8_t getFingerprintEnroll()
{
int p = -1;
Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
while (p != FINGERPRINT_OK)
{
p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(1);
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
Serial.println("Remove finger");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER)
{
p = finger.getImage();
}
Serial.print("ID "); Serial.println(id);
p = -1;
Serial.println("Place same finger again");
while (p != FINGERPRINT_OK)
{
p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(2);
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK converted!
Serial.print("Creating model for #"); Serial.println(id);
p = finger.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("Prints matched!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("Fingerprints did not match");
return p;
} else {
Serial.println("Unknown error");
return p;
}
Serial.print("ID "); Serial.println(id);
p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Stored!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("Could not store in that location");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error writing to flash");
return p;
} else {
Serial.println("Unknown error");
return p;
}
return true;
}
Pretty! This has been an incredibly wonderful post.
Thank you for supplying this information.
This design is spectacular! You most certainly know
how to keep a reader entertained. Between your wit and your
videos, I was almost moved to start my own blog (well, almost…HaHa!) Great
job. I really enjoyed what you had to say, and more than that,
how you presented it. Too cool!
Excellent blog here! Also your site rather a lot up very fast!
What host are you the usage of? Can I am getting your associate link to your
host? I want my web site loaded up as quickly as yours lol
Greetings! Very useful advice in this particular post! It’s the little changes that will make the greatest changes.
Thanks a lot for sharing!
Great article. I will be experiencing a few of these issues as well..
My partner and I stumbled over here by a different web address and thought I may as well check things out.
I like what I see so now i am following you.
Look forward to checking out your web page yet
again.
Hi, I log on to your new stuff regularly. Your humoristic style is awesome, keep doing what you’re doing!
What you posted made a lot of sense. But, think on this, suppose you added a
little content? I mean, I don’t want to tell you
how to run your website, however suppose you added a post
title that grabbed a person’s attention? I mean Arduino Fingerprint Door
Lock Robotics lab is a little plain. You ought to look at Yahoo’s front page and note
how they create news headlines to get people
to open the links. You might add a video or a related pic or two to grab readers interested about everything’ve got to say.
Just my opinion, it might make your website a little livelier.
It’s fantastic that you are getting ideas from this article as well as from our argument made
at this place.
Hi this is somewhat of off topic but I was wanting to know if
blogs use WYSIWYG editors or if you have to
manually code with HTML. I’m starting a blog soon but have no coding expertise so
I wanted to get guidance from someone with experience. Any help would be greatly appreciated!
This is my first time go to see at here and i am genuinely impressed to read everthing at alone place.
ラブドール 無 修正the stump-dotted trail was supplanted by quite an excellent road ofgravel,and down this we spun for thirty miles with nothing to interruptour progress.
Your mode of describing the whole thing in this piece of writing is truly nice,
every one be capable of easily understand it, Thanks
a lot https://www.alphafertilisation.ca/
I think the admin of this web page is really
working hard in favor of his web site, for the reason that here
every stuff is quality based material.
Your method of telling everything in this paragraph is
really good, all be able to without difficulty know it, Thanks a lot https://www.pretheure.com/
Your mode of describing the whole thing in this paragraph is
actually nice, all can simply be aware of it, Thanks a lot https://www.attraitsbeaute.com/maquillage-permanent-sourcils/
Your mode of telling all in this paragraph is actually good, all be capable of without
difficulty be aware of it, Thanks a lot https://www.intermezzomontreal.com/fr/
ラブドール と はmay have realized only after he compared the company’s restructuring to “breaking in a new Maserati.The first thousand miles you are not going to step on the gas too hard”Konig et al.
These are in fact enormous ideas in on the topic of blogging.
You have touched some good factors here. Any way keep up wrinting.
Your method of describing all in this piece of
writing is in fact nice, every one be able to effortlessly understand it, Thanks a lot https://www.tremblaycie.com/les-solutions/proposition-de-consommateur/
Your way of telling everything in this piece of writing is actually pleasant, every one can simply understand it, Thanks a lot https://www.echevalier.ca/generatrice-portative-et-fixe-residentielle-repentigny/
good sir
I’ve been exploring for a little for any high quality articles or weblog posts in this kind of area .
Exploring in Yahoo I finally stumbled upon this web site.
Studying this information So i am glad to exhibit that I’ve
a very good uncanny feeling I came upon just what
I needed. I most certainly will make sure to don?t forget this website and provides it a
glance on a continuing basis.
Your method of explaining everything in this
article is actually good, all can without difficulty understand it, Thanks a lot https://myfloridafurniture.com/
Hello excellent blog! Does running a blog similar to this require a lot of work?
I have very little understanding of computer programming however I
had been hoping to start my own blog in the near future.
Anyway, should you have any recommendations
or tips for new blog owners please share. I
understand this is off subject but I simply wanted to
ask. Appreciate it!
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
I’ve been looking for a plug-in like this for quite some time and was hoping
maybe you would have some experience with something like this.
Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to your new updates.
What a material of un-ambiguity and preserveness of
precious knowledge regarding unexpected emotions.
Great beat ! I would like to apprentice while you amend your site, how could i subscribe for
a blog website? The account helped me a acceptable
deal. I had been a little bit acquainted of
this your broadcast provided bright clear idea
Useful info. Fortunate me I found your website by chance, and I’m surprised why this accident didn’t came about in advance!
I bookmarked it.
Your way of telling the whole thing in this paragraph is genuinely nice, all
be able to effortlessly understand it, Thanks a lot https://coiffstore.fr/shu-uemura-175
Your way of explaining all in this paragraph is in fact pleasant, every one be capable of effortlessly know
it, Thanks a lot https://lepetitdep.ca/en/products/cafe-pista-melange-a-espresso-le-petit-dep
Your mode of explaining all in this post is truly good, all be able to without
difficulty understand it, Thanks a lot https://missgriffintown.com/contact/
This is my first time visit at here and i am genuinely happy to read all at single place.
Hi to every body, it’s my first pay a visit of this web site; this website includes remarkable and in fact fine material designed for
visitors.
I’ve been surfing on-line more than 3 hours lately, but I by
no means discovered any fascinating article like yours.
It’s lovely worth enough for me. Personally, if all webmasters and bloggers made good content material
as you did, the net will likely be much more helpful than ever
before.
Hi there, just wanted to mention, I enjoyed this blog post.
It was funny. Keep on posting!
Your method of telling the whole thing in this article is genuinely pleasant, all can simply understand it, Thanks a lot
Have you ever thought about publishing an ebook or guest authoring
on other websites? I have a blog centered on the same ideas you discuss and would really like to have you share some stories/information. I know my visitors would enjoy your work.
If you are even remotely interested, feel free to shoot me an e mail.
The email address you provided is incorrect.
Your method of describing all in this post is actually fastidious, all
be capable of effortlessly know it, Thanks a lot https://www.esthetiqueroselyne.com/
Wow, superb blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your site
is magnificent, as well as the content!
bookmarked!!, I like your website!
Very nice article. I certainly love this site. Keep writing!
Your means of describing the whole thing in this post is really good, every
one be able to without difficulty understand it, Thanks a lot https://www.lescaledetente.com/pourquoi-faire-un-drainage-lymphatique/
Your way of telling all in this article is in fact nice,
every one be capable of effortlessly be aware of it, Thanks a
lot https://www.minientrepotssaintcalixte.ca/mini-entrepot-la-plaine/
Hello to all, how is all, I think every one is getting more from this web page, and your
views are pleasant for new people.