Interfacing Fingerprint Sensor with Arduino for Biometric Security System

Interfacing Fingerprint Sensor with Arduino for Biometric Security System (Last Updated On: December 1, 2018)

Introduction

In this project we will be Interfacing Fingerprint Sensor with Arduino for Biometric Security System. The type of finger print module we are using is R305 Fingerprint Scanner Module. Security is a major concern in our day to day life, and digital locks have become an important part of these security systems. Fingerprint sensor based is one of the safest door locking system as it has the ability to identify and distinguish every person individually without making any error. Also the module is very small that it can be kept anywhere and with the portability feature and less power consumption you can carry it to any place as well.



While biometrics and fingerprint identification has been existing for well over 100 years in some basic form, it is the growth of maker community that made R305 Fingerprint Module so popular. R305 is common modules used fingerprint scanners, with the aid of a powerful DSP in its core. We can communicate with it using a packet of hex codes in a specific format. So lets interface R305 Fingerprint Sensor with Arduino, LCD & Servo Motor. Lets get started.


R305 Fingerprint Scanner Sensor Module

Introduction

This is a finger print sensor module with TTL UART interface for direct connections to microcontroller UART or to PC through MAX232 / USB-Serial adapter. The user can store the finger print data in the module and can configure it in 1:1 or 1: N mode for identifying the person.

Interfacing Fingerprint Sensor with Arduino for Biometric Security System
The Fingerprint module can be directly interfaced with any microcontroller as well as Arduino Board. This optical biometric fingerprint reader with great features and can be embedded into a variety of end products like access control system, attendance system, safety deposit box, car door locking system.

Features

1. Integrated image collecting and algorithm chip together, ALL-in-One
2. Fingerprint reader can conduct secondary development, can be embedded into a variety of end products
3. Low power consumption, low cost, small size, excellent performance
4. Professional optical technology, precise module manufacturing techniques
5. Good image processing capabilities, can successfully capture image up to resolution 500 dpi

Specifications

1. Fingerprint sensor type: Optical
2. Sensor Life: 100 million times
3. Static indicators: 15KVBacklight: bright green
4. Interface: USB1.1/UART(TTL logical level)
5. RS232 communication baud rate: 4800BPS~115200BPS changeable
6. Dimension: 55*32*21.5mm
7. Image Capture Surface 15—18(mm)
8. Verification Speed: 0.3 sec
9. Scanning Speed: 0.5 sec
10. Character file size: 256 bytes
11. Template size: 512 bytes
12. Storage capacity: 250
13. Security level: 5 (1,2,3,4,5(highest))
14. False Acceptance Rate (FAR) :0.0001%
15. False Rejection Rate (FRR): 0.1%
16. Resolution 500 DPI
17. Voltage :3.6-6.0 VDC
18. Working current: Typical 90 mA, Peak 150mA
19. Matching Method: 1: N
20. Operating Environment Temperature: -20 to 45° centigrades

Interfacing Fingerprint Sensor with Arduino for Biometric Security System

Components Required

1. Arduino Uno Board
2. R305 Finger Print Module -(Buy Online from Amazon)
3. Push Button -4
4. LEDs -2
5. 330E Resistor -2
6. 5V Power Supply
7. Connecting wires
8. Servo Motor -1
9. 16x2 LCD -1
10. Bread Board -1

Circuit Diagram:

Interfacing Fingerprint Sensor with Arduino for Biometric Security System



Working Explanation

The working of the Fingerprint Sensor based Biometric Security System is easy. In this project we have used a Servo motor SG90 which acts as a rotatary access to door unlocking. We have used 2 LEDs, one as green LED and other the red LED which acts as access granted and access denied indicator. We have interfaced 16*2 LCD which displays everything whenever the finger is placed or removed, or gate is opened or gate is closed or finger is matched or not.

We have used 4 push buttons which are used to control the entire system. The functions of each buttons are:
1. Enroll/Back Button – Used for enrolling new finger print as well as reversing the back process or going back
2. DEL/OK Button – This Button is used for deleting the earlier stored finger print system as well as granting access as OK selection.
3. UP/Match – Used for moving forward while selecting the memory location for storing or deleting fingerprint.
4. DOWN/Match Button – Used for moving backward while selecting memory location for storing or deleting fingerprint.

Enrolling New Fingerprint

To enroll New Fingerprint Click on Enroll Button. Then select the memory location where you want to store your fingerprint using UP/DOWN button. Then click on OK. Put your finger and remove your finger as the LCD instructs. Put your finger again. So finally your fingerprint get stored.


Deleting Stored Fingerprint

To delete the fingerprint which is already click on DEL Button. Then select the memory location where your fingerprint was stored earlier using UP/DOWN button. Then click on OK. So finally your fingerprint is deleted.

Checking the working with the help of different fingers

Simply click on MATCH button. Put your fingers over the scanner. If your fingerprint is matched the door will be opened and if not match you will see LCD indicating Please! Try Again.


Video Demonstration

If you are facing problem with the above explanation the you can simply follow this video guide that will help you to understand easily. Here we have explained all about Interfacing Fingerprint Sensor with Arduino for Biometric Security System.


Arduino Source Code

Simply copy this code and upload it to your arduino UNO Board using Arduino IDE. There are some library files you need to add to arduino library before making it work. Else the code won’t compile. Similarly the code doesn’t compile with earlier old version of Arduino IDE as older Arduino IDE has some array issue. So use latest version of Arduino IDE for compiling the code. So you will be simply Interfacing Fingerprint Sensor with Arduino for Biometric Security System


  #include<LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
#include <SoftwareSerial.h>
SoftwareSerial fingerPrint(2, 3);
#include<Servo.h>

Servo myServo;

#include <Adafruit_Fingerprint.h>
uint8_t id;
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerPrint);

#define enroll 14
#define del 15
#define up 16
#define down 17
#define openLight 6
#define closeLight 7
#define servoPin 5

void setup()
{
delay(1000);
myServo.attach(servoPin);
myServo.write(180);
pinMode(enroll, INPUT_PULLUP);
pinMode(up, INPUT_PULLUP);
pinMode(down, INPUT_PULLUP);
pinMode(del, INPUT_PULLUP);
pinMode(openLight, OUTPUT);
pinMode(closeLight, OUTPUT);
lcd.begin(16,2);
lcd.print(" Biometric ");
lcd.setCursor(0,1);
lcd.print("Security System");
delay(2000);
lcd.clear();
finger.begin(57600);
Serial.begin(9600);
lcd.clear();
lcd.print(" Finding Module ");
lcd.setCursor(0,1);
delay(2000);
if (finger.verifyPassword())
{
Serial.println("Found fingerprint sensor!");
lcd.clear();
lcd.print(" Module Found ");
delay(2000);
}
else
{
Serial.println("Did not find fingerprint sensor :(");
lcd.clear();
lcd.print("Module Not Found");
lcd.setCursor(0,1);
lcd.print("Check Connections");
while (1);
}
}

void loop()
{
lcd.setCursor(0,0);
lcd.print(" Press Match ");
lcd.setCursor(0,1);
lcd.print("To Start System");
digitalWrite(closeLight, HIGH);
if(digitalRead(up)==0 || digitalRead(down)==0)
{
for(int i=0;i<5;i++)
{
lcd.clear();
lcd.print("Place Finger");
delay(2000);
int result=getFingerprintIDez();
if(result>=0)
{
digitalWrite(openLight, HIGH);
digitalWrite(closeLight, LOW);
lcd.clear();
lcd.print(" Allowed ");
lcd.setCursor(0,1);
lcd.print(" Gate Opened ");
myServo.write(0);
delay(5000);
myServo.write(180);
digitalWrite(closeLight, HIGH);
digitalWrite(openLight, LOW);
lcd.setCursor(0,1);
lcd.print(" Gate Closed ");
return;
}
}
}
checkKeys();
delay(2000);
}

void checkKeys()
{
if(digitalRead(enroll) == 0)
{
lcd.clear();
lcd.print("Please Wait");
delay(2000);
while(digitalRead(enroll) == 0);
Enroll();
}

else if(digitalRead(del) == 0)
{
lcd.clear();
lcd.print("Please Wait");
delay(2000);
delet();
}
}

void Enroll()
{
int count=0;
lcd.clear();
lcd.print("Enroll Finger ");
lcd.setCursor(0,1);
lcd.print("Location:");
while(1)
{
lcd.setCursor(9,1);
lcd.print(count);
if(digitalRead(up) == 0)
{
count++;
if(count>25)
count=0;
delay(500);
}

else if(digitalRead(down) == 0)
{
count--;
if(count<0)
count=25;
delay(500);
}
else if(digitalRead(del) == 0)
{
id=count;
getFingerprintEnroll();
return;
}

else if(digitalRead(enroll) == 0)
{
return;
}
}
}

void delet()
{
int count=0;
lcd.clear();
lcd.print("Delete Finger ");
lcd.setCursor(0,1);
lcd.print("Location:");
while(1)
{
lcd.setCursor(9,1);
lcd.print(count);
if(digitalRead(up) == 0)
{
count++;
if(count>25)
count=0;
delay(500);
}

else if(digitalRead(down) == 0)
{
count--;
if(count<0)
count=25;
delay(500);
}
else if(digitalRead(del) == 0)
{
id=count;
deleteFingerprint(id);
return;
}

else if(digitalRead(enroll) == 0)
{
return;
}
}
}

uint8_t getFingerprintEnroll()
{
int p = -1;
lcd.clear();
lcd.print("Finger ID:");
lcd.print(id);
lcd.setCursor(0,1);
lcd.print("Place Finger");
delay(2000);
while (p != FINGERPRINT_OK)
{
p = finger.getImage();
switch (p)
{
case FINGERPRINT_OK:
Serial.println("Image taken");
lcd.clear();
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No Finger");
lcd.clear();
lcd.print("No Finger");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
lcd.clear();
lcd.print("Comm Error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
lcd.clear();
lcd.print("Imaging Error");
break;
default:
Serial.println("Unknown error");
lcd.clear();
lcd.print("Unknown Error");
break;
}
}

// OK success!

p = finger.image2Tz(1);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
lcd.clear();
lcd.print("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
lcd.clear();
lcd.print("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
lcd.clear();
lcd.print("Comm Error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
lcd.clear();
lcd.print("Feature Not Found");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
lcd.clear();
lcd.print("Feature Not Found");
return p;
default:
Serial.println("Unknown error");
lcd.clear();
lcd.print("Unknown Error");
return p;
}

Serial.println("Remove finger");
lcd.clear();
lcd.print(" 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");
lcd.clear();
lcd.print(" Place Finger ");
lcd.setCursor(0,1);
lcd.print(" Again ");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
return;
}
}

// 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!");
lcd.clear();
lcd.print("Stored!");
delay(2000);
} 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;
}
}

int getFingerprintIDez()
{
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)
{
lcd.clear();
lcd.print("Finger Not Found");
lcd.setCursor(0,1);
lcd.print("Try Later");
delay(2000);
return -1;
}
// found a match!
Serial.print("Found ID #");
Serial.print(finger.fingerID);
return finger.fingerID;
}

uint8_t deleteFingerprint(uint8_t id)
{
uint8_t p = -1;
lcd.clear();
lcd.print("Please wait");
p = finger.deleteModel(id);
if (p == FINGERPRINT_OK)
{
Serial.println("Deleted!");
lcd.clear();
lcd.print("Figer Deleted");
lcd.setCursor(0,1);
lcd.print("Successfully");
delay(2000);
}

else
{
Serial.print("Something Wrong");
lcd.clear();
lcd.print("Something Wrong");
lcd.setCursor(0,1);
lcd.print("Try Again Later");
delay(2000);
return p;
}
}



1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *