Arduino-Based Smart Locker with Keypad, Fingerprint Scanner, and I2C LCD
View and Edit Project In Cirkit Designer
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
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
16x2 I2C LCD
- Description: 16x2 character LCD display with I2C interface.
- Pins: GND, VCC, SDA, SCL
12V Solenoid Lock
- Description: Electromechanical lock that operates on 12V.
- Pins: VCC, GND
4X4 Membrane Matrix Keypad
- Description: 4x4 matrix keypad for user input.
- Pins: R1, R2, R3, R4, C1, C2, C3, C4
5V Relay
- Description: Relay module for switching high voltage devices.
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
Fingerprint Scanner
- Description: R307 fingerprint sensor for biometric authentication.
- Pins: VCC, TX, RX, GND
Buzzer
- Description: Piezoelectric buzzer for audio feedback.
- Pins: PIN, GND
12V Power Supply
- Description: Power supply providing 12V DC.
- Pins: +, -
Wiring Details
Arduino UNO
- 3.3V: Connected to VCC of Fingerprint Scanner
- 5V: Connected to VCC of 16x2 I2C LCD and VCC of 5V Relay
- GND: Connected to GND of 16x2 I2C LCD, GND of Fingerprint Scanner, GND of 5V Relay, and GND of Buzzer
- A4: Connected to SDA of 16x2 I2C LCD
- A5: Connected to SCL of 16x2 I2C LCD
- D13: Connected to R1 of 4X4 Membrane Matrix Keypad
- D12: Connected to R2 of 4X4 Membrane Matrix Keypad
- D11: Connected to R3 of 4X4 Membrane Matrix Keypad
- D10: Connected to R4 of 4X4 Membrane Matrix Keypad
- D9: Connected to C1 of 4X4 Membrane Matrix Keypad
- D8: Connected to C2 of 4X4 Membrane Matrix Keypad
- D7: Connected to C3 of 4X4 Membrane Matrix Keypad
- D6: Connected to C4 of 4X4 Membrane Matrix Keypad
- D5: Connected to PIN of Buzzer
- D4: Connected to In of 5V Relay
- D3: Connected to RX of Fingerprint Scanner
- D2: Connected to TX of Fingerprint Scanner
16x2 I2C LCD
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- SDA: Connected to A4 of Arduino UNO
- SCL: Connected to A5 of Arduino UNO
12V Solenoid Lock
- VCC: Connected to Normally Open of 5V Relay
- GND: Connected to - of 12V Power Supply
4X4 Membrane Matrix Keypad
- R1: Connected to D13 of Arduino UNO
- R2: Connected to D12 of Arduino UNO
- R3: Connected to D11 of Arduino UNO
- R4: Connected to D10 of Arduino UNO
- C1: Connected to D9 of Arduino UNO
- C2: Connected to D8 of Arduino UNO
- C3: Connected to D7 of Arduino UNO
- C4: Connected to D6 of Arduino UNO
5V Relay
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- In: Connected to D4 of Arduino UNO
- Common terminal: Connected to + of 12V Power Supply
- Normally Open: Connected to VCC of 12V Solenoid Lock
Fingerprint Scanner
- VCC: Connected to 3.3V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- RX: Connected to D3 of Arduino UNO
- TX: Connected to D2 of Arduino UNO
Buzzer
- PIN: Connected to D5 of Arduino UNO
- GND: Connected to GND of Arduino UNO
12V Power Supply
- +: Connected to Common terminal of 5V Relay
- -: Connected to GND of 12V Solenoid Lock
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() != F