Arduino Projects

Arduino Bluetooth Smart Lock using Android cell phone application

Bluetooth Smart Lock Project Description:


This is a very detailed tutorial on how to use the HC-05 and HC-06 Bluetooth module to make the smart lock. In this tutorial, you will also learn how to change the name of the Bluetooth module and how to change its pin code or pairing code using AT commands. With the help of this project, the Electronic lock can only be controlled by the authorized person having the cell phone Application.

A relay module based on the 12V SPDT “Single and double throw” relay is used to control the 12V electronic Lock. The Android cell phone Smart lock application is designed in Android Studio. If you want to learn how to design your own Android cell phone Applications then read my article.

For more details and step-by-step explanation watch the video Tutorial given at the end of this Article.

Amazon Purchase Links:

Arduino Nano USB-C Type (Recommended)

12v Adaptor:

HC-05 Bluetooth Module:

Bluetooth Module: Hc-05:

12v Electronic Door Lock / Elock / Solenoid Lock:

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Electronic Lock, and Bluetooth Circuit Diagram:

Bluetooth smart lock, circuit diagram, in this image you can see the electronic lock and bluetooth modules are interfaced with the arduino

The Bluetooth Module HC-05 or HC-06 Interfacing with the Arduino Board is very simple. The RX pin of the Bluetooth module is connected with the Arduino’s pin number 8. The TX pin of the Bluetooth Module is connected with the Arduino’s pin number 7. While the power supply pins of the Bluetooth Module are connected with the Arduno’s 5V and ground pins.

A one channel relay module is controlled using the Arduino’s pin number 13. The type of relay used in this project is of the type SPDT. The 12V electronic lock is connected with the common and Normally Open legs of the Relay Module.


Cell phone App:Smart_Lock

Smart Bluetooth Lock Arduino Programming:

Smart Lock Bluetooth Arduino Code Explanation:

// Bluetooth Smart Lock

I started off by adding the SoftwareSerial.h header file, we need this to defined other Serial ports other then its default Serial port. The Arduino’s default Serial Port can be used for debugging purposes.

#include <SoftwareSerial.h>

I created a Serial port for the Bluetooth Module with the name Blue, on Pins 7 and 8. Pin number 7 is the RX while pin number 8 is the Tx.
SoftwareSerial Blue(7, 8); // Bluetooth module connected here

Finally, I defined some varialble and Pins.
long int data;

int relay1 = 13; // Electronic lock connected with relay

Following are the passwords, you can use long numbers, but for the demonstration purposes, I am using these short passwords.
long int password1 = 555;// to on switch
long int password2 = 551;// to off switch

Inside the setup() function, I set the relay as Output, activated the Serial communication and the Bluetooth Module with baud rates 9600.
void setup()

pinMode(relay1, OUTPUT);
digitalWrite(relay1, LOW);



The actual code is placed inside the loop() function, which repeats endlessly until we turn OFF the Arduino board.

void loop()

The following condition means, if no data is received from the bluetooth module then simply do nothing and wait over here.

while(Blue.available()==0) ;

The following if condition is used to check if the Arduino has received any data from the Bluetooth module. If the data is available, then simply read the Bluetooth module and store the data in variable data.

data = Blue.parseInt();


Finally, the following two conditions are used to Open and Close the Electronic Lock as per the command or password received from the Smart Lock android app.

if (data == password1)
Serial.print(“Switch On”);
Blue.write(“Door Open”);

if( data == password2)
Serial.print(“Switch OFF”);
Blue.write(“Door Close”);


Bluetooth Smart Lock Video Tutorial:


Other Bluetooth Related Projects:

Arduino Bluetooth controlled Robot using L298n Motor Driver Android App

Pulse Sensor/ Heartbeat Rate/ Heart rate measurement using Arduino & Bluetooth

How to use GSM and Bluetooth Together To monitor Any Sensors wirelessly using Arduino

Wireless battery voltage monitor using Arduino and Bluetooth

Arduino Bluetooth Pin Code and Name changing using AT commands

Wireless Temperature monitoring system using Bluetooth

8×8 LED Matrix MAX7219 Control using Bluetooth and Arduino

Related Articles

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button