Bluetooth Door Lock (Arduino)

100,732

590

46

About: Enjoying the projects? Support this page on Patreon: https://goo.gl/QQZX6w

Recently I rewatched the Amazing SpiderMan, in one scene Peter Parker locks and unlocks his door from his desk using a remote. When I saw this I instantly wanted my own for my door. After a bit of tinkering I got a working model. Heres how I made it

Step 1: Parts List

For this project we will need the following:

Electronics:

Parts:

  • Slide Lock (Get it here)
  • Six screws for the slide lock
  • Cardboard
  • Wire

Tools:

  • Soldering Iron
  • Glue Gun
  • Drill
  • Drill Head
  • Drill Head for pilot hole
  • Box Cutter
  • Computer with arduino IDE

Step 2: How It Works

The idea is that I can easily lock and unlock my door without having to carry a key or even go near it :D but this is only a fraction of what we can do. From here we could add a sensor like a knock sensor so we can unlock our door with a special knock or even a voice recognition system!

The servo arm will be connected to the slider lock and will move to 0 degrees to lock the door and 60 degrees to unlock it using commands it gets from out Bluetooth device.

Step 3: Wiring Diagram

Lets start by wiring the servo to the Arduino (I would like to note that even though i'm using the Arduino nano the Arduino uno will work just as well with the exact same pin layout)

  • The Brown wire on the servo is ground and it gets connected to ground on the Arduino
  • The Red wire is positive and it gets connect to 5v on the Arduino
  • The Orange wire is the servos source connection and it gets connected to pin 9 on the Arduino

Now I would recommend testing the servo before moving on, you can do this by going to examples in the Arduino IDE and selecting sweep. When we are sure that the servo works we can add the bluetooth module. We will connect the rx pin on the bluetooth module to the tx pin on the Arduino and the tx pin on the bluetooth module to the rx pin on the Arduino But don't do this yet! while these connections are made nothing can be uploaded to the Arduino so make sure you upload the code before soldering.
With this in mind this is how we wire the bluetooth module to the Arduino

  • Rx pin on the bluetooth module connects to the Tx pin on the Arduino
  • Tx pin on the bluetooth module connects to the Rx pin on the Arduino
  • Vcc (positive) on the bluetooth module connects the 3.3v on the Arduino
  • Ground goes to Ground

If any of this was confusing please follow the wires on the picture provided

Step 4: Testing

Now that we have all the parts together lets make sure the servo is strong enough to push and pull the locking mechanism without a problem before I started designing the final concept I built a mock up just to make sure my servo was strong enough, at first mine wasn't so I added a tiny bit of oil on the sliding mechanism which helped everything move smoothly. Its really crucial that everything moves smoothly or there is a chance you'll get locked on or out of your room! :D

Step 5: Electronics Casing

I decided to leave my servo "exposed" and to only build a small cardboard case to protect the arduino nano and Bluetooth module. We can build this by tracing the around the arduino nano onto a peice of cardboard and add about 1 cm (0,39 inch) of space onto each side now we have to cut out the other 5 sides of the rectangular cube. We also have to cut a hole on one of the faces for the power cord to connect to the arduino.

The measurements for the case are:

  • Bottom piece = 7.5cm by 4cm (2.95 by 1.57 inch)
  • Top piece = 7.5cm by 4cm (2.95 by 1.57 inch)
  • left piece = 7.5 cm by 4cm (2.95 by 1.57 inch)
  • Right piece = 7.5 cm by 4cm (2.95 by 1.57 inch)
  • Front face = 4cm by 4cm (1.57 by 1.57 inch) (cut power hole in this one)
  • Back face = 4cm by 4cm (1.57 by 1.57 inch)

Step 6: The App

So to lock and unlock the door we need a device running either android or windows with bluetooth builtin, Mac users i wasnt able to get this working on an iphone or a macbook pro I think there might be some driver issues but im sure one of you can figure it out :D. If you're installing on Android you will need to go to the play store and download and app called Bluetooth Terminal and for windows its called TeraTerm next we need to connect the hc-05 to our phone it should be called linvor and the password will be either 0000 or 1234. Once its paired open the app we just installed, click on options and tap connect to device (insecure) now our phone is basically simulating the arduino serial monitor which means we can see and send information coming from the arduino.

If you type 0 and press enter you should see the door lock and see the message "door locked"

and when you type 1 and press enter you should see the door unlock and see the message "door unlocked"

The process is basically the exact same on windows except you need to download an application called Tera Term and you can find the download link here (https://ttssh2.osdn.jp/index.html.en)

Step 7: Mounting the Lock

First things first we need to mount the servo on the sliding lock we do this by cutting off the edge of the servo mounting holes so that when we lay the servo down it will be flush with the lock next we put the servo arm into the lock hole where the handle used to be and test that everything moves correctly if so glue it down.

Now we need to start drilling pilot holes in the door for the screws, place the sliding lock againts the door and use a pencil to trace where the holes are now drill the pilot holes where you made the traces drill them to the depth of about 2.5 cm now place the the lock againts the door and screw in the screws onces its secure make sure the system still works

Step 8: Power Supply

To make sure we can leave this we are going to need a power supply, the cable and usb mini plug to connect to the arduino.

Connect the ground connection on the power supply to the ground connection on the usb mini port and connect the red cable to the red cable on the usb mini port now lead the cable from the lock to one of the door hinges and from there lead it to a power outlet

Step 9: The Code

#include <Servo.h>

Servo myservo;

int pos = 0;

int state; int flag=0;

void setup()

{

myservo.attach(9);

Serial.begin(9600);

myservo.write(60);

delay(1000); }

void loop()

{

if(Serial.available() > 0)

{

state = Serial.read();

flag=0;

} // if the state is '0' the DC motor will turn off

if (state == '0')

{

myservo.write(8);

delay(1000);

Serial.println("Door Locked");

}

else if (state == '1')

{

myservo.write(55);

delay(1000);

Serial.println("Door UnLocked");

}

}

Step 10: Finished!

Enjoy your bluetooth controlled door lock, dont forget to mess with your friends by locking them out of your room!

Thanks for reading if you have any questions please feel free to pm me or leave the question in the comments.

Arduino Contest 2016

Participated in the
Arduino Contest 2016

Share

    Recommendations

    • Sensors Contest

      Sensors Contest
    • Backyard Contest

      Backyard Contest
    • DIY Summer Camp Contest

      DIY Summer Camp Contest

    46 Discussions

    0
    None
    saguisa

    Question 1 year ago on Step 9

    sir where im going to put the code???what kind of app??

    0
    None
    MillerI

    1 year ago

    Couldn't spend $3 on a package? A simple project box would keep this from looking kludgy even if it is.

    0
    None
    SUKUMART

    1 year ago

    my mail id tlsukumar555@gmail.com

    0
    None
    SUKUMART

    1 year ago

    sir can you send me the pdf please.Thank you

    0
    None
    nazmiazahari69

    1 year ago

    Im building my own apps. How can i connect to the board? Im using the button option instead not using the '1' and '0' option.

    0
    None
    PastorJohn

    2 years ago

    Cool ? instruct boss.
    Story for the disrupts that talk talk talk and not contribute.
    Privacy ? locks are just that, not for security. Have fun and mess with your friends. Great idea.

    1 reply
    0
    None
    PastorJohnPastorJohn

    Reply 2 years ago

    My Dad always said...
    "Locks are to keep honest people out."

    0
    None
    akhlak malik

    2 years ago

    how i m upload the code in the arduino (step 9).
    and where i m get the arduino board

    0
    None
    MacB19

    2 years ago

    sir! do you have a black diagram of this?

    1 reply
    0
    None
    MacB19MacB19

    Reply 2 years ago

    can you send me sir please !!!!!!! thank you:) macbalbes@gmail.com

    0
    None
    rich.altmaier

    2 years ago

    Please be aware there is no security in this solution, in that any random person can walk up, pair, and open the door. So you can consider this lock the equivalent of no lock at all.
    It looks like a fun project! But for a real door, it would be cheaper and equivallent security to have no lock at all.

    3 replies
    0
    None
    rjmahrich.altmaier

    Reply 2 years ago

    You can change the Adruino program to only open on a 4 digit passcode. Also alter HC06 default paring code making it harder to "pick" this lock.

    0
    None
    instructible01rich.altmaier

    Reply 2 years ago

    Rich, though I would not recommended this for any significant security need, I wood disagree that it provides zero security.
    First, I will make the statement that the method of engaging and disengaging the lock is security by obscurity which is unreliable but you are evaluating this from the standpoint of someone who has seen the other side of the door and has entire knowledge of the project. Looking at it from the standpoint of someone who walks up to the door and finds it locked, it is a deterrent so much as they aren't willing to kick the door in. That person would also most likely not know how to overcome the automation in a stealthy manner. It
    is probably great for siblings or minorly annoying roommates as it stands. However, it would, without a doubt, need a significant upgrade to manage external security.

    0
    None
    wimton

    2 years ago

    Have a look at this entertaining presentation: https://media.ccc.de/v/33c3-8019-lockpicking_in_the_iot to avoid of the pittfalls.

    0
    None
    KDMChiTown

    2 years ago

    As noted below, the lock provides limited security for an external door, but I could see an application on a kitchen cabinet to keep your snacks/food secure from a hungry roommate...

    0
    None
    batmat

    2 years ago

    Very cool. But put a battery in your project. Energy AC eletric can fault.

    1 reply
    0
    None
    Eliyahu IlyaLbatmat

    Reply 2 years ago

    One could introduce a usb power bank in the middle