In this article , I am going to provide you circuit design and code for testing R305 Fingerprint sensor with LCD on Arduino UNO board. You need to download Adafruit Fingerprint Sensor Library from the link given below.

 

Download Adafruit FingerPrint Library

Components Required

1. R305 Fingerprint Sensor
2. Arduino Uno
3. Breadboard
4. LCD 16X2
5. 10K Potentiometer

Make the connection as shown in below given circuit diagram.

Circuit Diagram

Code for Enrolling

#include <LiquidCrystal.h>
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
LiquidCrystal lcd(12, 11, 4, 5, 13, 10);
uint8_t id;
uint8_t getFingerprintEnroll();
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()  
{
lcd.begin(16, 2);
while (!Serial);  // For Yun/Leo/Micro/Zero/...
delay(500);
Serial.begin(9600);
lcd.print("Sensor Started");
Serial.println("Fingerprint sensor enrollment");
delay(2500);
lcd.clear();
// set the data rate for the sensor serial port
finger.begin(9600);
if (finger.verifyPassword()) {
lcd.print("Found  Sensor!");
Serial.println("Found fingerprint sensor!");
delay(2500);
lcd.clear();
} else {
lcd.print("Did not find");
Serial.println("Did not find fingerprint sensor :(");
delay(2500);
lcd.clear();
while (1);
}
}
uint8_t readnumber(void) {
uint8_t num = 0;
boolean validnum = false; 
while (1) {
while (! Serial.available());
char c = Serial.read();
if (isdigit(c)) {
num *= 10;
num += c - '0';
validnum = true;
} else if (validnum) {
return num;
}
}
}
void loop()                     // run over and over again
{
lcd.print("Enroll a finger");
id = readnumber();
lcd.print("Enrolling ID #");
lcd.print(id);
while (!  getFingerprintEnroll() );
}
uint8_t getFingerprintEnroll() {
int p = -1;
lcd.print("Waiting for valid finger to enroll as #"); lcd.print(id);
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
lcd.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
lcd.print("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
lcd.print("Imaging error");
break;
default:
lcd.print("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(1);
switch (p) {
case FINGERPRINT_OK:
lcd.print("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
lcd.print("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
lcd.print("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
lcd.print("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
lcd.print("Could not find fingerprint features");
return p;
default:
lcd.print("Unknown error");
return p;
}
lcd.print("Remove finger");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER) {
p = finger.getImage();
}
Serial.print("ID "); lcd.print(id);
p = -1;
lcd.print("Place same finger again");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
lcd.print("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
lcd.print("Imaging error");
break;
default:
lcd.print("Unknown error");
break;
}
}
// OK success!
p = finger.image2Tz(2);
switch (p) {
case FINGERPRINT_OK:
lcd.print("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
lcd.print("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
lcd.print("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
lcd.print("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
lcd.print("Could not find fingerprint features");
return p;
default:
lcd.print("Unknown error");
return p;
}
// OK converted!
Serial.print("Creating model for #");  lcd.print(id);
p = finger.createModel();
if (p == FINGERPRINT_OK) {
lcd.print("Prints matched!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
lcd.print("Communication error");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
lcd.print("Fingerprints did not match");
return p;
} else {
lcd.print("Unknown error");
return p;
}   
Serial.print("ID "); lcd.print(id);
p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
lcd.print("Stored!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
lcd.print("Communication error");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
lcd.print("Could not store in that location");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
lcd.print("Error writing to flash");
return p;
} else {
lcd.print("Unknown error");
return p;
}   
}

Note: Code Provided is just for enrolling a user’s fingerprint. You can find more examples in the adafruit library for further implementation.

Please comment below if you find any difficulty making this.