Project tutorial
Protect Your Room with Fingerprints for Under $20

Protect Your Room with Fingerprints for Under $20 © GPL3+

Create a locking system that locks your room with your fingerprint and an access code on the cheap.

  • 7,720 views
  • 2 comments
  • 24 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

In this tutorial, we will build a system that protects your room based on your fingerprint and a set security code.

Step One: Overview

First, watch the video to get an overview of the project.

YouTube Video Overview

Step Two: Wiring

Wire your circuits up based on the following instructions.

I was only able to find a few of the parts in Fritzing so I included what I could in the schematic. All of the connections made are in the pictures below.

First, wire up the included components in the schematic.

Next, connect the 4x4 Keypad up to the Arduino Mega using the digital pins listed below.

Most fingerprint sensors have 6 wires. The only ones that matter are the red, black, white, and green wires. Connect them up to the Arduino Uno using the wiring diagram provided below.

Step Three: Door Lock-Unlock Assembly

For locking and unlocking the door, I made some 3D designs in Tinkercad and printed them out on my 3D printer. However, if you do not have access to a 3D printer, you could hot glue the servo arm onto the door lock for a more permanent and similar effect.

For those of you that do have a 3D printer, the designs I made are linked below. Print them out with your printer's default settings and they should take about an hour to print.

Door Lock to Servo Adaptor: https://www.tinkercad.com/things/7F2q3VAR0Lt

Servo Knob Holder: https://www.tinkercad.com/things/f6cQwq9BDPV

I then printed them and attached the components together using hot glue. Its not a permanent solution but it gets the job done reliably.

After assembling the pieces and hot gluing them in place, I ended up with a solution that looked something like this:

Step Four: Programming

Programming the system is easy if you know what you are doing. Otherwise, it can take a lot of time and effort.

1) First, start off by downloading and installing a few libraries into the Arduino IDE.

It is a fairly simple process. First, download the required libraries from the links below:

Next, use the process in the video below to import the libraries into your Arduino IDE.

How to import .ZIP libraries into the Arduino IDE

Next, upload the following code to the Arduino Mega. Make sure that the TX and RX wires connecting the UNO and MEGA are unplugged while uploading this code. Change the board in the tools menu to MEGA and plug in the Arduino MEGA. Select the COM port and upload the following sketch the board.

/*************************************************
This code was compiled by Srivishnu Piratla
****************************************************/
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Password.h>
Servo doorLock;
int incomingByte = 0;
String newPasswordString; //hold the new password
char newPassword[6]; //charater string of newPasswordString
LiquidCrystal lcd(8,9,4,5,6,7);
//initialize password to 1234
//you can use password.set(newPassword) to overwrite it
Password password = Password( "1092" );
byte maxPasswordLength = 6; 
byte currentPasswordLength = 0;
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
int buttonState = 0; 
//Define the keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
//// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {34,35,36,37}; //connect to row pinouts
// Connect keypad COL0, COL1, COL2 and COL3 to these Arduino pins.
byte colPins[COLS] = {30,31,32,33}; //connect to column pinouts
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
  doorLock.attach(44);
  doorLock.write(100);
  Serial1.begin(9600);
  pinMode(44, OUTPUT);
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Passkey: ");
  pinMode(2, INPUT);
}
void loop(){
  char key = keypad.getKey();
  buttonState = digitalRead(2);
  if (buttonState == HIGH) { 
     doorLock.write(-180);
     delay(10000);
     doorLock.write(100);
     setup();
  }
  if (key != NO_KEY){
     delay(60); 
     switch (key){
     case 'A': break; 
     case 'B': break; 
     case 'C': break; 
     case '#': checkPassword(); break;
     case '*': resetPassword(); break;
     default: processNumberKey(key);
     }
  }
}
void processNumberKey(char key) {
  Serial1.print(key);
  currentPasswordLength++;
  password.append(key);
  lcd.print(int(key)-int(48));
  if (currentPasswordLength == maxPasswordLength) {
     checkPassword();
  }
}
void checkPassword() {
  if (password.evaluate()){
     Serial.println(" OK.");
     lcd.clear();
     lcd.print("Key Authorized");
     delay(1000);
     lcd.clear();
     lcd.print("Complete BioLock");
     Serial1.read();
     Serial1.flush();
     while (!Serial1.available()){
     }
     while (int(Serial1.read())==!int(1)){
     }
     lcd.clear();
     lcd.print("User Authorized");
     doorLock.write(-180);
     delay(10000);
     doorLock.write(100);
     setup();
  } else {
     lcd.clear();
     lcd.print("Access Denied");
     delay(1000);
     setup();
  } 
}
void resetPassword() {
  password.reset(); 
  currentPasswordLength = 0;
  lcd.clear();
} 

Next, change the board in the tools menu and plug in the Arduino UNO. Select UNO in the Boards dropdown and the COM port assigned to the Arduino UNO.

To enroll fingers on the device's memory chip, follow the instructions from the Adafruit video below using the fingerprint library you installed earlier:

How to Enroll Fingerprints on to the Device

Next, upload the following sketch the board making sure that the TX and RX wires are still unplugged.

/*************************************************** 
 This is an example sketch for our optical Fingerprint sensor
 Designed specifically to work with the Adafruit BMP085 Breakout 
 ----> http://www.adafruit.com/products/751
 These displays use TTL Serial to communicate, 2 pins are required to 
 interface
 Adafruit invests time and resources providing this open source code, 
 please support Adafruit and open-source hardware by purchasing 
 products from Adafruit!
 Written by Limor Fried/Ladyada for Adafruit Industries.  
 BSD license, all text above must be included in any redistribution
****************************************************/
/*************************************************
This code was slightly modified by Srivishnu Piratla
****************************************************/
#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
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
void setup()  
{
 Serial.begin(9600);
 while (!Serial);  // For Yun/Leo/Micro/Zero/...
 delay(100);
 // set the data rate for the sensor serial port
 finger.begin(57600);
 if (finger.verifyPassword()) {
 } else {
   Serial.println("Did not find fingerprint sensor :(");
   while (1) { delay(1); }
 }
 finger.getTemplateCount();
}
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;
 }   
 Serial.print(1);
 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;
 Serial.print(1);
}

Then connect the TX and RX wires back to the Arduino.

Step Five: Finish and Demo

So that's it, you have built yourself a device which can unlock your door with a special access code and your fingerprint. Here is a video of the system working.

Video of System Working

If you found this tutorial helpful, then please consider liking and subscribing to my YouTube channel.

Comments

Similar projects you might like

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,826 views
  • 17 comments
  • 75 respects

Programmable Wireless Room Thermostat (Bluetooth Accessible)

Project tutorial by Tamer Savaşcı

  • 3,096 views
  • 0 comments
  • 8 respects

Bluetooth Based Home Automation

Project tutorial by Team Brink.IO

  • 9,652 views
  • 13 comments
  • 38 respects

Gesture-Controlled Lock

Project tutorial by Arduino “having11” Guy

  • 8,669 views
  • 6 comments
  • 35 respects

Room Service - "Alexa, Please Get Rid Of All My Remotes"

Project tutorial by Madhur Gupta

  • 710 views
  • 2 comments
  • 8 respects
Add projectSign up / Login