In this project, we will build a Biometric Security System with Arduino & fingerprint sensor. This system will be able to identify someone by their fingerprint and give them entry to a secure area. We will be using an R307 fingerprint sensor module to capture and store fingerprint data.
This data will be used to validate the identity of a person when he/she tries to access the secured area. The system will be able to reject or access the person based on their fingerprint data.
Thank You, NextPCB!
Our project reached successful completion thanks to the beneficial help of NextPCB. If you’re working on a PCB project, we highly recommend you visit their website to take advantage of some fantastic discounts and coupons.
The system will be equipped with a LCD screen to display status messages, and an LED to provide feedback. Check my previous post on GSM Based Home Security System Using Ultrasonic Sensor
Required Material
- Arduino board
- Fingerprint sensor module
- 16×2 I2C LCD display
- Relay module
- Push buttons
- LEDs (optional, for visual feedback)
- Jumper wires
- Breadboard;
The Biometric Security System ensures secure access using fingerprints. It uses an R307 fingerprint module, Arduino, relay, solenoid lock, LCD, and buttons. Users interact via push buttons for enrollment, deletion, and scanning. Pressing “Scan“ prompts placing a finger on the module. It scans, sends data to Arduino, and verifies against stored fingerprints.
A match activates the relay, thus powering the solenoid lock to unlock. The LCD provides user feedback, like “Access Granted” or “Access Denied.”
Circuit Diagram & Connection – Biometric Security System
Here’s the circuit diagram of the Biometric Security System with Fingerprint Sensor & Arduino designed using Fritzing Software:
The project includes various components that work together to create a result, Let us take a more in-depth look at the connections among the various components in this project.
Connect the Fingerprint Sensor:
- TX to Arduino D2
- RX to Arduino D3
- VCC to Arduino 5V
- GND to Arduino GND
Connect the LCD Using I2C:
- SDA to Arduino A4
- SCL to Arduino A5
- VCC to Arduino 5V
- GND to Arduino GND
Connect the Pushbuttons: (enroll, delete, up, down)
- Connect one side to digital pins (8, 9, 10, 11)
- Connect the other side to GND
Connect the LEDs for Door Indicators: (Door Open, Door Close):
- Door Open LED:
- Longer leg to digital pin 4
- Shorter leg to GND
- Door Close LED:
- Longer leg to digital pin 5
- Shorter leg to GND
Connect the Relay Module:
- IN pin to digital pin 6
- VCC to Arduino 5V
- GND to Arduino GND
- COM: Connected to Solenoid Lock
- NC: Connected to 12V
These simplified instructions should make it clear how to connect your hardware components to the Arduino for your biometric security system.
The system runs on a 12V DC Power. A 7805 Voltage regulator provides 5V to the fingerprint Sensor, relay, and Arduino UNO. A 100uF/35V Electrolytic Capacitor provides a stable voltage at the power supply pins.
Install Required Libraries
The Biometric Security System with Fingerprint Sensor code, written in Arduino IDE, depends on two libraries for compilation. Firstly download the blow library and add it to your Arduino IDE:
Go to “Sketch“ > “Include Library” > “Manage Libraries,” and then search for and install the “********” library.
Upload the Code
Copy the below code and paste the provided code into the Arduino IDE.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
#include <Adafruit_Fingerprint.h> #include <SoftwareSerial.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize the LCD SoftwareSerial fingerPrint(2, 3); // Define constants for pins #define enroll 8 #define del 9 #define up 10 #define down 11 #define Door_Open 4 #define Door_Close 5 #define RELAY_PIN 6 uint8_t id; Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerPrint); void setup() { // Initialize pins pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, LOW); // Initially, relay is off pinMode(enroll, INPUT_PULLUP); pinMode(up, INPUT_PULLUP); pinMode(down, INPUT_PULLUP); pinMode(del, INPUT_PULLUP); pinMode(Door_Open, OUTPUT); pinMode(Door_Close, OUTPUT); // Initialize LCD lcd.init(); lcd.backlight(); lcd.print("Fingerprint"); lcd.setCursor(0, 1); lcd.print("Security System"); delay(2000); lcd.clear(); Serial.begin(9600); finger.begin(57600); lcd.clear(); lcd.print("Finding Module"); lcd.setCursor(0, 1); delay(1000); if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); lcd.clear(); lcd.print("Found Module "); delay(1000); } 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 UP/Down "); lcd.setCursor(0, 1); lcd.print("to start System"); digitalWrite(Door_Close, 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(Door_Open, HIGH); digitalWrite(Door_Close, LOW); lcd.clear(); lcd.print("Allowed"); lcd.setCursor(0, 1); lcd.print("Gate Opened "); digitalWrite(RELAY_PIN, HIGH); delay(5000); digitalWrite(RELAY_PIN, LOW); digitalWrite(Door_Close, HIGH); digitalWrite(Door_Open, LOW); lcd.setCursor(0, 1); lcd.print("Gate Closed "); return; } } } checkKeys(); delay(1000); } void checkKeys() { if (digitalRead(enroll) == 0) { lcd.clear(); lcd.print("Please Wait"); delay(1000); while (digitalRead(enroll) == 0); Enroll(); } else if (digitalRead(del) == 0) { lcd.clear(); lcd.print("Please Wait"); delay(1000); 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; } } 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; } } 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; } 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(1000); } else { Serial.print("Something Wrong"); lcd.clear(); lcd.print("Something Wrong"); lcd.setCursor(0, 1); lcd.print("Try Again Later"); delay(2000); return p; } } |
Make sure your Arduino board is chosen under “Tools“ > “Board” and the correct port is selected under “Tools” > “Port.” Click the “Upload” button to upload the code to the Arduino.
How the Arduino Biometric Security System Operates
After uploading the above code to the Arduino Nano Board, the system project is ready to be tested.
That’s it! Follow these steps to use the system for secure access control with fingerprint recognition.
- Enroll/Back: Enroll new fingerprint or go back.
- Delete/OK: Delete a fingerprint or confirm an action.
- Up/Match: Move up or increase values, and start fingerprint verification.
- Down/Match: Move down or decrease values, and use for fingerprint verification.
1. Power On:
- Supply the system is powered using a 12V DC.
2. Start Setup:
-
- The system will start and display “Fingerprint Security System.”
- Wait for user input.
3. Enroll Fingerprints:
- Press the “Enroll“ button.
- The LCD will show you through the enrollment procedure:
- Choose a location for the unique fingerprint Using the Up and Down Button( 1 to 25).
- Put your finger on the sensor as ordered.
- Repeat the procedure until registration is finished.
- The system stores the fingerprint data.
4. Delete Fingerprints:
- Press “Delete“ to remove a fingerprint.
- Follow the LCD Display to select the one to delete.
5. Grant Access:
- Press “Up“ or “Down“ for access.
- Put your finger on the sensor when the LCD shows you.
- If identified, the door unlocks (relay activates).
- LCD shows “Gate Opened.“
6. Access Timeout:
- After a delay, the door locks.
- LCD shows “Gate Closed.“
Conclusion
The Biometric Security System, with Arduino and a Fingerprint Sensor, leverages the capabilities of significant advances in security solutions using fingerprints. In summary, this project shows how to build a biometric security System.