KrïtikaDr. Umesh DuttaVikas SharmaVaishnavi
Published

Bluetooth Password-Controlled Door Lock

Unlock your door with a secure password via Bluetooth—convenience and safety at your fingertips!

BeginnerFull instructions provided152
Bluetooth Password-Controlled Door Lock

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
The main microcontroller for processing input and controlling the lock.
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
Enables wireless communication for password entry.
×1
1-Channel Signal Relay 1A SPDT I²C Mini Module
ControlEverything.com 1-Channel Signal Relay 1A SPDT I²C Mini Module
Controls the locking mechanism of the door.
×1
Jumper wires (generic)
Jumper wires (generic)
For making necessary connections between components.
×1
Solenoid Lock
Provides a secure locking mechanism for the door.
×1
PSD3304 power sour
Supplies stable power for the system.
×1

Software apps and online services

Arduino IDE
Arduino IDE
Used to write, upload, and run the code on the Arduino Uno
BlueApp.io
BlueApp.io
A mobile app (like Bluetooth Terminal) used to send commands to the HC-05 module. You may also create a custom app if desired.

Story

Read more

Schematics

Bluetooth Password Door Lock

This circuit diagram illustrates the connections for a Bluetooth password door lock system using the Arduino Uno as the main controller. The HC-05 Bluetooth module enables wireless communication, while the relay module controls the solenoid lock for secure access. The PSD3304 power source provides stable power to the entire system. Ensure proper connections for optimal functionality.

Code

Arduino Code for Bluetooth Door Lock

C/C++
Initializes Arduino Uno and Bluetooth communication.
Waits for a password input via Bluetooth.
Grants access if the password matches ("1234").
Unlocks the solenoid lock for 3 seconds when access is granted.
Provides feedback via the serial monitor for access status.
#include <SoftwareSerial.h> // Include the SoftwareSerial library for Bluetooth communication

// Create a SoftwareSerial object for Bluetooth communication on pins 10 (RX) and 11 (TX)
SoftwareSerial rfSerial(10, 11);

// Define the lock pin connected to the door lock mechanism
int lock = 12;

// Declare character arrays for storing the received ID and the expected ID
char id[13];
char id1[4] = "1234"; // Set the password to "1234"

void setup() {
  Serial.begin(9600);        // Initialize the serial communication at 9600 baud rate
  rfSerial.begin(9600);     // Initialize Bluetooth communication at 9600 baud rate
  pinMode(lock, OUTPUT);     // Set the lock pin as an output
  digitalWrite(lock, 1);     // Set the lock pin to HIGH (lock is engaged)
}

void loop() {
  doorlock(); // Continuously check for door lock functionality
}

void doorlock() {
  // Check if data is available from the Bluetooth serial
  if (rfSerial.available() > 0) {
    // Read the incoming bytes into the id array until a null character is found
    rfSerial.readBytesUntil('\0', id, 4);
    id[4] = '\0'; // Add null terminator to the end of the received string

    // Compare the received ID with the predefined ID
    if (strcmp(id, id1) == 0) {
      Serial.println("HELLO ACCESS GRANTED"); // Print access granted message
      digitalWrite(lock, 0); // Unlock the door (set lock pin to LOW)
      delay(3000);           // Keep the door unlocked for 3 seconds
      digitalWrite(lock, 1); // Lock the door again (set lock pin to HIGH)
    } else {
      digitalWrite(lock, 1); // Ensure the door is locked (set lock pin to HIGH)
      Serial.println("PLEASE PROVIDE RIGHT DETAILS ACCESS DENIED"); // Print access denied message
    }
  }
}

Credits

Krïtika

Krïtika

4 projects • 2 followers
:)
Dr. Umesh Dutta

Dr. Umesh Dutta

42 projects • 59 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Vikas Sharma

Vikas Sharma

4 projects • 4 followers
Vaishnavi

Vaishnavi

3 projects • 1 follower
Beginner

Comments