Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to design a smartphone-operated door lock

By Ashutosh Bhatt June 26, 2023

In this project, we’ll design a unique door lock that can be operated without a keycard, input password, or biometric ID. A smartphone is the key to locking and unlocking the door via Bluetooth. 

This door uses a solenoid lock, which relies on a latch for electrical locking and unlocking. It also has LEDs to indicate whether the door is locked or unlocked and initiates a buzzer for sound notifications. A vibration sensor produces a warning signal, protecting the door from unauthorized or forceful access.

We’ll use an Arduino NANO board and require a smartphone with Bluetooth connectivity for this project. Let’s begin with the block diagram, followed by the circuit diagram.

System block diagram
The primary building blocks of the system include:

  • An Arduino NANO board
  • The Bluetooth Module HC05
  • A relay
  • A solenoid lock 
  • A 12 V buzzer. 

We’ll also use a few other blocks, with:

  • LEDs
  • A mini buzzer 
  • Vibration sensors 

A block diagram of the smartphone-operated door lock.

1. The Smartphone with Bluetooth connectivity to transmit commands via the phone to lock or unlock the door.

2. The Bluetooth module sends commands from the user’s smartphone to lock or unlock the door. The Bluetooth app sends these signals to the Arduino board through serial communication.

3. A vibration sensor is used to detect movement or vibrations on the door when it’s locked. If the sensor detects strong vibrations, it sends an alert to the Arduino board.

4. The relays: Relay 1 activates (energizes) the solenoid lock. It requires 12 V to power the internal coil of the solenoid. Relay 2 also uses 12 V, but it’s used to power the big buzzer. 

5. The solenoid lock is used to lock the door

6. The 12-V big buzzer generates an alert if anyone attempts to forcefully open the door when locked (without using the smartphone). 

7. The mini buzzer alerts whenever the door is locked or unlocked by generating a long or short beeping sound, respectively.

8. LEDs: Green and red LEDs indicate if the door is locked or unlocked.

Required components:

The Solenoid lock.

The Bluetooth Module HC05.

The Arduino NANO board.

The big buzzer (12 V).

The mini buzzer (5 V).

The relay – 12V PCB mount.

The vibration sensor module.

Schematic diagram:

The complete circuit diagram of the smartphone-operated door lock.

Circuit connections:
The Bluetooth Module HC05 has four pin connections: VCC, GND, Tx, and Rx.

  • Arduino provides the VCC pin with 5 V
  • The GND pin connects to the common circuit ground
  • The Tx and Rx pins connect to Arduino’s digital pins D11 and D12, respectively
  • The red and green LEDs connect to the digital IO pins D9 and D10
  • The digital IO pins, D7 and D8, drive the Relay 1 and Relay 2 coils through the transistors
  • Both NPN transistors BC547 are connected in switch configuration and their collector output drives the relay coil
  • The Relay 1 NO output drives the buzzers. The Relay 2 NO output energizes the solenoid coil
  • The common (C) terminals of both relays are supplied with 12 V (which is provided to either the buzzer or the solenoid lock)
  • The 5V mini buzzer connects to the digital pin D5

The vibration sensor module has three pin connections: VCC, GND, and D0.

  • Arduino provides the VCC pin with 5 V
  • The GND pin connects to the common circuit ground
  • The D0 pin connects to Arduino’s digital pin D6
  • Arduino’s VIN pin is given 12 V of input, thereby generating 5 V using its onboard 5 V voltage regulator. This 5V is then given to the other modules.

Circuit operation:
The circuit operation starts when it’s supplied with 12 V. Initially, the solenoid is in the locked position, and the red light is ON to indicate that the door is locked.

To begin, open the Bluetooth application in your smartphone and pair it with the HC05 module (enter the default passkey, 1234). Once complete, the HC05 module blinks at a slow rate and is ready to receive commands.

Next, send the command “ULCK” to unlock the door from your smartphone’s Bluetooth app. The HC05 module will receive this command and pass it onto Arduino serially through the Tx-Rx pins.

When Arduino receives the command, it will send Logic 1 to D8 pin, switching on Relay 2. This activates the solenoid and the door unlocks. At the same time, Arduino sends:

  • Logic 1 to the D9 pin, turning on the green LED, signaling that the door is unlocked
  • Logic 0 to the D10 pin, turning off the red LED (used only when the door is locked)
  • Logic 1 to the D5 pin for one second, indicating to the mini buzzer to generate a long beep, signaling that the door is unlocked

To lock the door, send the command “LOCK.” The HC05 module will receive this command and pass it onto Arduino. Arduino then switches off Relay 2 by sending Logic 0 to the D8 pin, which deactivates the solenoid and locks the door.

Arduino also sends:

  • Logic 1 to the D5 pin for half a second, which generates a short beep from the mini buzzer, indicating the door is locked. It turns off green led by
  • Logic 1 to the D10 pin, turning on the red LED, signaling that the door is locked
  • Logic 0 to the D9 pin, turning off the green LED (used only when the door is unlocked)

When the door is locked and the vibration sensor detects any kind of shock, force, or vibration, it provides an alert signal via Logic 1 to Arduino. Once received, Arduino will send Logic 1 to the D7 pin, which switches on Relay 1, producing an alarm from the 12 V big buzzer,

This circuit operation works because of the program that’s downloaded into the internal FLASH of Arduino’s ATMega328. The program is written in C/C++ language and compiled in the Arduino IDE software.

The program’s file (code) must be downloaded (uploaded) in the 32 KB program memory (FLASH) of the ATMega328.

Software program:

#include <SoftwareSerial.h>
SoftwareSerial BT_serial(11,12);
char recved_code[5];
char lock_code[5] = “LOCK”;
char unlock_code[5] = “ULCK”;
int i=0,siren_rly=7,buz=5;
int lock_rly=8,lock_led=10,unlock_led=9;
int door_vibr_sensor=6;
int lock_flag=0,unlock_flag=1;
void setup()
{
  // put your setup code here, to run once:
  BT_serial.begin(9600);
  Serial.begin(9600);
  pinMode(siren_rly,OUTPUT);
  pinMode(buz,OUTPUT);
  pinMode(lock_led,OUTPUT);
  pinMode(lock_rly,OUTPUT);
  pinMode(unlock_led,OUTPUT);
  pinMode(door_vibr_sensor,INPUT);

  digitalWrite(lock_rly,LOW);
  digitalWrite(unlock_led,LOW);
   digitalWrite(lock_led,1);
  digitalWrite(buz,0);
  digitalWrite(siren_rly,LOW);

}

void loop()
{
  int door_vib_sensor_stat,lock_sensor_stat;
  door_vib_sensor_stat = digitalRead(door_vibr_sensor);

  if((door_vib_sensor_stat==0) && (lock_flag==1))
    {
      digitalWrite(siren_rly,HIGH);
      Serial.println(“attempt to break the door”);
    }

  if(BT_serial.available())
    {
      recved_code[i] = BT_serial.read();
      Serial.print(recved_code[i]);
      i++;     
    }
  if(i==4)
    {
      Serial.print(recved_code);
      if(strcmp(lock_code,recved_code)==0)
        {
            digitalWrite(lock_rly,LOW);
            digitalWrite(buz,1);
            delay(1000);
            digitalWrite(buz,0);
            lock_flag=1;
            unlock_flag=0;
            BT_serial.print(“Door Locked”);
            digitalWrite(lock_led,HIGH);
            digitalWrite(unlock_led,LOW);
        }
      if(strcmp(unlock_code,recved_code)==0)
        {
            digitalWrite(lock_rly,HIGH);
            digitalWrite(buz,1);
            delay(500);
            digitalWrite(buz,0);
            unlock_flag=1;
            lock_flag=0;
            BT_serial.print(“Door UNLocked”);
            digitalWrite(lock_led,LOW);
            digitalWrite(unlock_led,HIGH);         
        }
      i=0;  
    }
}  

Video link:

You may also like:


  • How to send messages to WhatsApp or Telegram from ESP32

  • How to schedule embedded tasks in Arduino using FreeRTOS

  • How to read input from USB keyboard on Arduino
  • Getting Started With Arduino With Simple LED Blinking Code Circuit Setup On Breadboard
    Getting started with Arduino – (Part 1/49)

  • What are different types of biometric sensors?

Filed Under: Electronic Projects
Tagged With: Arduino, arduinonano, circuit, electronics, led, sensors, smarthphone, solenoid
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Voltage mode pushpull is a nonsense SMPS?
  • Input impedance matching network
  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Reducing "shoot-through" in offline Full Bridge SMPS?

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe