How To Make Bluetooth Controlled Smart Door Lock Using Arduino | Smart Door Lock | Smartphone Door Lock

February 05, 2022

Description

Hello, In this article, I'm going to show you "How To Make Bluetooth Controlled Smart Door Lock Using Arduino Nano & HC-05 Bluetooth Module", In this project, I’m using the HC-05 Bluetooth module as a communication medium between the User & Arduino. For this project I’ve designed an Application named Bluetooth Door Lock, I’ve provided a download link below so you can easily download that application & use it for door lock & unlocking purposes. Nowadays safety is the most important in our life, so we are not going to compromise it, If you see many peoples use old-fashioned door locks which are basically mechanical locks, but these locks are not very reliable as compared to this Smart door lock. In this project, I've used a 12V solenoid lock for locking & unlocking purposes. The complete locking system of the Smart door lock is on the indoor side so it's difficult to break. Now you can ask me how to open the door using an application, well, for that I've designed an application in the application you will get the Lock & Unlock button to control the solenoid lock wirelessly. It results in the door getting locked & unlock. So let's make the project.

Material Required

For making this project we need some components to build the circuitry, So I have left the best buy link below, you can buy the components from there.

Sr.No

Product Name

Quantity

Best Buy Link

1

Arduino Nano

1

https://amzn.to/34cS3SM

2

HC-05 BLE Module

1

https://amzn.to/3B7Qx0U

3

1-Channel Relay Module

1

https://amzn.to/3rOFl4M

4

Breadboard

1

https://amzn.to/3r4UPCI

5

Jumper Wires

1 Nos

https://amzn.to/3r4UPCI

6

Solenoid Lock

1

https://amzn.to/34gVtV7

7

Red & Green LED

1,1

https://amzn.to/3IZrmAa

8

470E Resistor

2

https://amzn.to/3rsofuH

Circuit Diagram

Circuit Diagram

Pinouts Of HC-05 Bluetooth Module

HC-05 BLE Module Pinouts

Refer to the above image to understand the pinouts of the HC-05 module.

  • State:- The State pin acts as a Status Indicator, It shows the module is connected or not
  • Rx:- This pin is used to receive the data from the TX pin of the microcontroller.
  • TX:- This pin is used to transmit the serial data to the RX pin of the Microcontroller.
  • GND:- This is the Ground pin of the Bluetooth module.
  • VCC:- The VCC pin is used to power the module from 3.3V to 5V.
  • KEY/ EN:- The KEY pin is used to bring the HC-05 Bluetooth module in AT command mode.

How It Works

In this project, I’ve used the HC-05 Bluetooth module for communication medium between the Smartphone (User) to Microcontroller, Arduino Nano. When a user wants to lock or unlock the door that time user just needs to open the application & click on the unlock/ lock button, at a moment smartphone sends a command to the Arduino through the Bluetooth module & the door will unlock/lock get unlocked & vice-versa. So in this way this project works.

Application Overview

In the above image, you can see the interface of the Application. On-screen there are two buttons which are Lock & Unlock by clicking these buttons the solenoid lock gets locked & unlock. If you click on the Techno-E-Solution button it'll redirect you to my website. On my website, you will get my new articles means new projects on Arduino, Raspberry & much more.

How To Use Application

In the following clipart, I've shown you how to connect the smartphone with the HC-05 Bluetooth module, If the Bluetooth module gets successfully connected to the Arduino you have to click on the lock & unlock button to perform the task.


  • Turn on the Bluetooth of the Smartphone.
  • Open the Application.
  • Click on Bluetooth Button.
  • From the Bluetooth device list select the HC-05 Bluetooth module.
  • Above the Bluetooth button, you can see It shows "Connected"
  • Simply click on the Lock & Unlock button to open & close the door.

Arduino Code

Simply upload the following code to your Arduino Nano

/*
 * Hello Welcome back to "TECHNO-E-SOLUTION"
 * Project Name:- How To Make Bluetooth Controlled Smart Door Lock Using Arduino
 * Project Video:- xxxxxxxxxx
 * Article Link:- xxxxxxxxx
 */

#include <SoftwareSerial.h>
SoftwareSerial Blue(2, 3); // BLE module TX & RX pin to D2 & D3
 
String readString;
#define Relay 5
#define RedLED 8
#define GreenLED 10
  
void setup()
{
  Serial.begin(9600);
  Blue.begin (9600);
  pinMode(Relay, OUTPUT);
  pinMode(RedLED, OUTPUT);
  pinMode(GreenLED , OUTPUT);
  
  digitalWrite(RedLED, HIGH);
  Serial.println("Welcome");
 
}
 
void loop()
{
  while(Blue.available())  
  {
    delay(10);                 
    char c = Blue.read();    
    if (c == '#'){
      break;                   
    }
    readString += c;            
  }
    if (readString.length() >0)
    {
      Blue.println(readString);
                  
      if(readString == "0"){   
        digitalWrite(Relay, LOW);
        digitalWrite(GreenLED, LOW);
        digitalWrite(RedLED, HIGH);
        Serial.println("Door Locked!");
      }
      else if(readString == "1")
      {
        digitalWrite(Relay, HIGH);
        digitalWrite(GreenLED, HIGH);
        digitalWrite(RedLED, LOW);
        Serial.println("Door Unlocked!");
      }
      }

      readString="";
    } 

You can buy me a coffee If you got this article helpful.