Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Based Smart Locker with Keypad, I2C LCD, and Fingerprint Sensor

Image of Arduino-Based Smart Locker with Keypad, I2C LCD, and Fingerprint Sensor

Smart Locker Circuit Documentation

Summary

This document provides a detailed overview of a smart locker system based on an Arduino UNO microcontroller. The system integrates a 4x4 membrane keypad, a 16x2 I2C LCD, an R307 fingerprint sensor, a 12V solenoid lock, a 5V relay, and a buzzer. The locker can be unlocked using either a correct keypad code or a registered fingerprint.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. 16x2 I2C LCD

    • Description: 16x2 character LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  3. 12V Solenoid Lock

    • Description: Electromechanical lock that operates on 12V.
    • Pins: VCC, GND
  4. 4X4 Membrane Matrix Keypad

    • Description: 4x4 matrix keypad for user input.
    • Pins: R1, R2, R3, R4, C1, C2, C3, C4
  5. 5V Relay

    • Description: Relay module for switching high voltage devices.
    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
  6. Fingerprint Scanner

    • Description: R307 fingerprint sensor for biometric authentication.
    • Pins: VCC, TX, RX, GND
  7. Buzzer

    • Description: Piezoelectric buzzer for audio feedback.
    • Pins: PIN, GND
  8. 12V Power Supply

    • Description: Power supply providing 12V DC.
    • Pins: +, -

Wiring Details

Arduino UNO

  • 3.3V to Fingerprint Scanner VCC
  • 5V to 5V Relay VCC and 16x2 I2C LCD VCC
  • GND to Buzzer GND, 16x2 I2C LCD GND, Fingerprint Scanner GND, and 5V Relay GND
  • A4 to 16x2 I2C LCD SDA
  • A5 to 16x2 I2C LCD SCL
  • D13 to 4X4 Membrane Matrix Keypad R1
  • D12 to 4X4 Membrane Matrix Keypad R2
  • D11 to 4X4 Membrane Matrix Keypad R3
  • D10 to 4X4 Membrane Matrix Keypad R4
  • D9 to 4X4 Membrane Matrix Keypad C1
  • D8 to 4X4 Membrane Matrix Keypad C2
  • D7 to 4X4 Membrane Matrix Keypad C3
  • D6 to 4X4 Membrane Matrix Keypad C4
  • D5 to Buzzer PIN
  • D4 to 5V Relay In
  • D3 to Fingerprint Scanner RX
  • D2 to Fingerprint Scanner TX

16x2 I2C LCD

  • GND to Arduino UNO GND
  • VCC to Arduino UNO 5V
  • SDA to Arduino UNO A4
  • SCL to Arduino UNO A5

12V Solenoid Lock

  • VCC to 5V Relay Normally Open
  • GND to 12V Power Supply -

4X4 Membrane Matrix Keypad

  • R1 to Arduino UNO D13
  • R2 to Arduino UNO D12
  • R3 to Arduino UNO D11
  • R4 to Arduino UNO D10
  • C1 to Arduino UNO D9
  • C2 to Arduino UNO D8
  • C3 to Arduino UNO D7
  • C4 to Arduino UNO D6

5V Relay

  • VCC to Arduino UNO 5V
  • GND to Arduino UNO GND
  • In to Arduino UNO D4
  • Normally Open to 12V Solenoid Lock VCC
  • Common terminal to 12V Power Supply +

Fingerprint Scanner

  • VCC to Arduino UNO 3.3V
  • TX to Arduino UNO D2
  • RX to Arduino UNO D3
  • GND to Arduino UNO GND

Buzzer

  • PIN to Arduino UNO D5
  • GND to Arduino UNO GND

12V Power Supply

  • + to 5V Relay Common terminal
  • - to 12V Solenoid Lock GND

Code Documentation

/*
 * Arduino based Smart Locker with Keypad, I2C LCD, R307 Fingerprint Sensor
 * and 12V Solenoid Lock
 *
 * This code interfaces with a 4x4 membrane keypad, a 16x2 I2C LCD, an R307
 * fingerprint sensor, and a 12V solenoid lock. The system allows unlocking
 * the solenoid lock using either a correct keypad code or a registered
 * fingerprint.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Fingerprint.h>
#include <Keypad.h>

// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Fingerprint sensor setup
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial);

// Keypad setup
const byte ROWS = 4; // four rows
const byte COLS = 4; // four columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {13, 12, 11, 10}; // connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; // connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

// Relay and buzzer pins
const int relayPin = 4;
const int buzzerPin = 5;

// Predefined correct code
String correctCode = "1234";

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  finger.begin(57600);

  // Initialize LCD
  lcd.init();
  lcd.backlight();

  // Initialize relay and buzzer pins
  pinMode(relayPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(relayPin, LOW);
  digitalWrite(buzzerPin, LOW);

  // Display welcome message
  lcd.setCursor(0, 0);
  lcd.print("Smart Locker");
  lcd.setCursor(0, 1);
  lcd.print("Initializing...");
  delay(2000);
  lcd.clear();

  // Initialize fingerprint sensor
  if (finger.verifyPassword()) {
    lcd.print("Sensor found");
  } else {
    lcd.print("Sensor not found");
    while (1) { delay(1); }
  }
  delay(2000);
  lcd.clear();
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("Enter Code or");
  lcd.setCursor(0, 1);
  lcd.print("Scan Finger");

  // Check for keypad input
  String inputCode = "";
  char key = keypad.getKey();
  while (key != '#') {
    if (key) {
      inputCode += key;
      lcd.setCursor(0, 1);
      lcd.print(inputCode);
    }
    key = keypad.getKey();
  }

  // Check if the entered code is correct
  if (inputCode == correctCode) {
    unlock();
  } else {
    lcd.setCursor(0, 1);
    lcd.print("Wrong Code");
    delay(2000);
    lcd.clear();
  }

  // Check for fingerprint
  if (fingerprintMatch()) {
    unlock();
  }
}

bool fingerprintMatch() {
  finger.getImage();
  if (finger.image2Tz() != FINGERPRINT_OK) return false;
  if (finger.fingerFastSearch() != FINGERPRINT_OK) return false;
  return true;
}

void unlock() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Access Granted");
  digitalWrite(relayPin, HIGH);
  digitalWrite(b