Arduino Easy Smart Home Series: Smart Keypad Door Lock with Daily Changing Password

Ardunova Maker Series: Smart Keypad Door Lock with Daily Changing Password

Welcome to the Ardunova Maker Series! 🔐 In this project, we will build a Smart Keypad Door Lock that updates its password every day automatically. Only the owner can access the new password via a secure method, making it a futuristic, high-security solution for homes and offices.

Table of Contents

  • Introduction
  • Required Hardware
  • Arduino IDE Setup
  • Wiring the Components
  • Arduino Code
  • How It Works
  • Testing Your Project
  • Advanced Modifications
  • Common Issues and Troubleshooting
  • Learning Insights
  • Conclusion

1. Introduction

This project is designed for maximum security. It combines a 4x4 Keypad, Servo Motor Lock, and a Real-Time Clock (RTC) module. The password changes daily, and the owner receives it via a secure mobile notification or email. Perfect for smart homes, offices, or personal safes.

2. Required Hardware

  • Arduino Uno (~₹500)
  • 4x4 Keypad (~₹200)
  • Servo Motor MG996 (~₹250)
  • RTC Module DS3231 (~₹150)
  • Buzzer (~₹50)
  • LEDs (~₹30)
  • Resistors & jumper wires (~₹100)
  • Arduino IDE installed on your PC

3. Arduino IDE Setup

  1. Install Arduino IDE on your computer.
  2. Connect Arduino via USB cable.
  3. Select the board: Tools → Board → Arduino Uno.
  4. Select the correct COM port: Tools → Port → (your Arduino port).
  5. Install libraries: Keypad.h and RTClib.h.

4. Wiring the Components

  • Keypad → Connect rows and columns to D2-D9 on Arduino.
  • Servo Motor → Signal to D10, VCC to 5V, GND to GND.
  • RTC → SDA → A4, SCL → A5, VCC → 5V, GND → GND.
  • Buzzer → D11, LED → D12.

5. Arduino Code

Upload this code to Arduino. It generates a daily password based on the date and unlocks the servo when entered correctly.

#include <Wire.h>
#include <RTClib.h>
#include <Keypad.h>
#include <Servo.h>

RTC_DS3231 rtc;
Servo lockServo;

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8,9};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

String inputPassword = "";
String dailyPassword = "";

void setup() {
  Serial.begin(9600);
  lockServo.attach(10);
  lockServo.write(0); // Lock closed
  if(!rtc.begin()) {
    Serial.println("RTC not found!");
    while(1);
  }
}

String generateDailyPassword() {
  DateTime now = rtc.now();
  int pwd = (now.day() * 1000) + (now.month() * 100) + now.year()%100;
  return String(pwd);
}

void loop() {
  dailyPassword = generateDailyPassword();
  char key = keypad.getKey();
  if(key) {
    if(key == '#') {
      if(inputPassword == dailyPassword) {
        lockServo.write(90); // Unlock
        Serial.println("Door Unlocked");
      } else {
        Serial.println("Wrong Password");
      }
      inputPassword = "";
    } else if(key == '*') {
      inputPassword = ""; // Clear input
    } else {
      inputPassword += key;
    }
  }
}

6. How It Works

The system uses the RTC module to calculate a daily password. The user enters the password on the keypad. If correct, the servo rotates to unlock the door. '#' confirms entry, '*' clears it. Only the owner, who knows the algorithm, can derive the password for the day. Optional: send the password via mobile notification using ESP8266 for extra security.

7. Testing Your Project

  1. Upload the code to Arduino.
  2. Connect all hardware and power Arduino.
  3. Check the servo motor locks/unlocks when correct daily password is entered.
  4. Verify buzzer and LED indicators for wrong or correct password.

8. Advanced Modifications

  • Add Wi-Fi module to send daily password via app notification.
  • Integrate fingerprint sensor for two-factor authentication.
  • Store multiple users’ daily passwords securely.
  • Control multiple doors with a single Arduino.

9. Common Issues and Troubleshooting

  • Servo not moving: Check wiring and power supply.
  • Keypad input not detected: Check row/column wiring.
  • Wrong password always: Ensure RTC date is correct.
  • Daily password not matching: Check generateDailyPassword() logic.

10. Learning Insights

  • Understand secure password generation using RTC.
  • Learn keypad interfacing and servo motor control.
  • Explore concepts of IoT notifications for security.
  • Foundation for advanced smart home automation.

11. Conclusion

This Smart Keypad Door Lock is a high-security, futuristic Arduino project. It demonstrates daily password automation, secure access, and hardware interfacing. Perfect for makers who want to upgrade their smart homes with cutting-edge security.

By Kaushal Haladi

Comments

Popular Posts