Introduction
The Fingerprint is one of the safest ways to detect and identify the Authorized person, We know that fingerprint is unique even identical twins do not have identical fingerprints. By using this we can make pretty sure about security needs. To add fingerprint verification in evive project we can use this all-in-one optical fingerprint sensor-scanner (R307), It makes fingerprint detection and verification super simple.
The fingerprint identification process has two steps which are
- Enrolling Fingerprint
- Matching Fingerprint.
In this tutorial, we are going to match a fingerprint. If you want to know how to Enroll a fingerprint go to the previous tutorial on the fingerprint sensor.
Circuit Diagram
Code
- Capturing an image and converting it into an uint8 array matrix. After that, we are finding a degree of closeness to this matrix and enrolled the image in the previous tutorial.
- Displaying each process on the evive TFT screen. When the fingerprint is matched TFT will show ID and degree of closeness.
#include <evive.h>
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int x=39;
int a=38;
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()
{
pinMode(x,INPUT);
pinMode(a,INPUT);
tft_init(INITR_BLACKTAB);
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0,10);
Serial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
tft.println("\n\nAdafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword()) {
tft.println("Found fingerprint sensor!");
} else {
tft.println("Did not find fingerprint sensor :(");
while (1) { delay(1); }
}
int X=0;
tft.println("press b to start");
while(X==0)
{
X=digitalRead(x);
}
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0,10);
finger.getTemplateCount();
tft.print("Sensor contains "); tft.print(finger.templateCount); tft.println(" templates");
tft.println("Waiting for valid finger...");
delay(3000);
}
void loop()
{
getFingerprintIDez();
delay(50); //don't ned to run this at full speed.
}
uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No finger detected");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK success!
p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
tft.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
tft.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
tft.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
tft.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
tft.println("Could not find fingerprint features");
return p;
default:
tft.println("Unknown error");
return p;
}
// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK) {
tft.println("Found a print match!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
tft.println("Communication error");
return p;
} else if (p == FINGERPRINT_NOTFOUND) {
tft.println("Did not find a match");
return p;
} else {
tft.println("Unknown error");
return p;
}
tft.fillScreen(ST7735_GREEN);
tft.print("Found ID #"); tft.print(finger.fingerID);
tft.print(" with confidence of "); tft.println(finger.confidence);
return finger.fingerID;
}
// returns -1 if failed, otherwise returns ID #
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) return -1;
tft.fillScreen(ST7735_GREEN);
tft.setCursor(0,10);
tft.print("Found ID #"); tft.print(finger.fingerID);
tft.print(" with confidence of "); tft.println(finger.confidence);
delay(5000);
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0,10);
tft.println("Waiting for valid finger...");
return finger.fingerID;
}
Output
Conclusion
This tutorial was about how to match a fingerprint using the all-in-one optical fingerprint sensor-scanner (R307) with evive. We first saved the Adafruit-Fingerprint-Sensor-Library-master library into the libraries folder of the Arduino programming software. We then wrote the code to capture an image and convert it into an uint8 array matrix, and then match the image with the enrolled image from a previous tutorial. We then displayed the process of matching on the evive TFT screen, along with the ID and degree of closeness. With this, we were able to successfully match a fingerprint using the all-in-one optical fingerprint sensor-scanner (R307) with evive.