How To Detect Fingerprints ID Stored In Fingerprint Sensor R307 Using Arduino | #arduinotutorial

January 30, 2022


Description

Hello, In this article, I'll show you how to detect stored fingerprints IDs in fingerprint sensors. When we work on fingerprint sensors we enroll some fingers Id's & then we make projects using the sensor but sometimes we forget the finger Id which is important while implementing programs. To perform this test we need an Adafruit fingerprint sensor Library, so first install that library in your Arduino IDE. I have already made a complete tutorial video on this point you can refer to my youtube channel video.

Watch out the video If reading bores you.

If you got this article helpful then subscribe to our blog as well as our youtube channel for more interesting projects.

Material Required:-

[ Following links are affiliated links, if you buy from them we will get some bonus from it. ]

Sr.No

Product Name

Quantity

Best Buy Link

1

Arduino Uno

1

https://amzn.to/3nCSn4j

2

R307 Fingerprint Sensor

1

https://amzn.to/33DqFgR

3

Breadboard + Jumper Wires

1

https://amzn.to/3fIWUO5


Adafruit Fingerprint Sensor Library:-

We need to install this library in Arduino IDE, so follow the following steps to install this library.

1. First Download the following Library by clicking on the Download button.
2. Click on Sketch Menu in Arduino IDE.
3.Select Include library >> Add. Zip library.
4. New pop-up window will open Select the downloaded Zip file & click on Open Button.
5. In this way this library will get installed in Arduino IDE.

Adafruit Fingerprint Sensor Library:- [Download]


Circuit Diagram:-


Refer above circuit diagram to make proper connections.

Arduino Code:-[ Download ]

/*
   Hello guys welcome back to "Techno-E-Solution"
   Tutorial Name:- How To Detect Fingerprints ID Stored In Fingerprint Sensor R307 Using Arduino
   Tutorial Video:- https://youtu.be/Bv2k3_oqsmo
*/

#include <Adafruit_Fingerprint.h>

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1
// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
// comment these two lines if using hardware serial
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()  
{
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit finger detect test");
  // set the data rate for the sensor serial port
  finger.begin(57600);
  delay(5);
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }
  finger.getTemplateCount();
    if (finger.templateCount == 0) {
    Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
  } 
  else {
    Serial.println("Waiting for valid finger...");
      Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
  }
}
void loop()                     // run over and over again
{
  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:
      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!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.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;
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID; 
}

 

You can Buy me coffee If you got this article helpful.