Instructables

Easy Bluetooth Enabled Door Lock With Arduino + Android

FeaturedContest Winner
Picture of Easy Bluetooth Enabled Door Lock With Arduino + Android
Thanks to everyone who supported this project and voted for it in the Arduino Challenge! I was awarded second prize and hope to participate in more Arduino contests in the near future.

This tutorial will explain a simple way to make a password protected bluetooth door lock using your Arduino, which can be unlocked by sending a four digit pin from your Android phone!  The hardware setup is quite simple,  and the programming side of it is a bit tricky, but should be no problem for any Arduino ameuture.

 
Remove these adsRemove these ads by Signing Up

Step 1: Parts Needed

Picture of Parts Needed
1. Arduino (I am using the Duemilanove)

2. Electric Door Strike

3. Bluetooth Module ($9.99)

4. Power Supply (Required voltage and amperage differs among different door strikes/locks)

5. TIP120 Transistor

6. 1N4001 Diode

7. Hookup Wire

8. Solderless Breadboard

9. An Android phone (optional, considering that there are lots of devices you could use to send serial data to our bluetooth modem including Iphones, computers, and other Bluetooth devices)

Step 2: About The Transistor

Picture of About The Transistor
We'll start by focusing on one of the main components of the circuit, the transistor. Our transistor will allow us to control a device that requires more current than our Arduino can supply, by sending the transistor different values. The type of transistor we are using (the TIP120) has a base, collector, and an emitter which are labeled here. We will send the signal from pin 9 on the Arduino to the base of the transistor, and depending on the value sent, current will increase or decrease.

Step 3: Assemble The Circuit

The diagram shows how the transistor is wired up in our circuit. As you can see, we have a diode pointed away from ground that is connected to the collector of the transistor as well as the ground of the lock itself. This diode will protect our electronics from any back voltage that might be created when our lock is turned off. At this point you could set pin 9 to high or low to control the lock.
1-40 of 89Next »
anyone has the idea on how to modify this project so that the door lock/ relay should be activated once the bluetooth connection is paired between the phone and the module. and when unpaired(out of range), the relay should deactivated.

the system should work without any commands need to be send(in the project above we must send 'ABCD' to activate the relay) from the phone.

hope you can help me by giving some solution. much appreciated your help..

I'd really like to know how to do this as well.

jackbell163 months ago

Hi,

thank you for your project. It is a very cool one ! As I can understand, to open the door in the Arduino Code, you open and close a Relay. is it correct ?

imr34 months ago

QR code scan version of arduino door lock.

https://www.youtube.com/watch?v=gubRBe60_Go

leizo284 months ago

does anyone knows any app for iphone to do that? thank you

tiongson6 months ago

where is the connections of the electric door strike ???????

hi collin...its a great project..How did you code arduino? What program you used and what code, can you please help me with that? and Could you please upload a circuit diagram ? thank you.
randersen67 months ago
How do you open the door during a power outage ?
varun131688 months ago
How did you code arduino? What program you used and what code, can you please help me with that?
code for bluetooth module*
Great project. Could you please upload a circuit diagram so I can clearly see how to connect everything? Or a few close ups of how it's all connected to the breadboard.
bioana19 months ago
Hello. I tried to make this project but I have a problem with phone, he did't find the module of Bluetooth. My phone is samsung GT-S5610 and the module of Bluetooth is BT_BOARD V1.2pro. I dont know what is the problem. Please help me.Thank you.
jmarcinkowski9 months ago
Great project! Would you be able to upload a circuit diagram so that I can clearly see how its all connected?
Geniusdude2 years ago
What if you wanted to leave the door normally locked, then when you send the serial data unlock, and then stay that way until you send the data/passcode again at which point it would unlock? I cannot seem to figure out how the code would be modified for the life of me.
It does seem that this only unlocks it, and then leaves it unlocked forever until the Arduino is reset.

Add this line:
digitalWrite(lock, HIGH);
just before the line
Serial.println("Locked");

Then it should unlock for 5 seconds and then lock again.
omaryeye1 year ago
bro my project is door access system using Bluetooth and a biometric scanner do you know a way how can I connect this project to a biometric scanner
It should be pretty easy to attach a fingerprint scanner to this... something like https://www.sparkfun.com/products/11792. There should be plenty of pins left over on the Arduino.
JoshHawley1 year ago
shouldnt the diode be across the coil in reverse? like this:http://www.azatrax.com/image/CoilDiode.png

JoshHawley1 year ago
what brand/model of door strike is that? did you mount it in a wooden door?
hi collin! can i also have some clear copy of the wiring?
what module did you used?
Quantiera1 year ago
Hi,

I am using Arduino UNO, in this case is there any difference on the command line and I am using Arduino 1.5.2 to upload the command. Please give me more detail on this project.
danica171 year ago
what are those grounds? ground of power supply?
dmendoza121 year ago
What is the difference if you set PIN 9 to LOW or HIGH?
tolstoyan1 year ago
hi i started to build your project but i am having trouble with the wiring of the circuit, can you please send me a clear connection of the schematic diagram because i am confused on how you power the arduino and how the 12v is connected. when i tried to use the instruction above the electric door strike is keep on unlock. i am a beginner so i hope you can understand. my name is Louie from the Philippines. i hope you will respond. thank you
drmpf1 year ago
Nice Instructable Collin

Can I suggest my pfodApp ( www.pfod.com.au ) as an alternative Android App

Using pfodApp allows you to customize the mobile's display to present the user with a named button.

No Andriod programming is required, just a simple text message from the Arduino.

www.pfod.com.au has example code for a Garage Door opener which can be easily reused to drive the lock, by changing the "Garage Door" text in the Arduino code to "Front Door Lock"

Collin if you would like to contact me, we could talk about a non-english (UTF8) version of pfodApp.
stormdead1 year ago
I want to make this device but... i want a button activate the lock....

I'm using a 9v battery instead of a power supply


Is this ok?....:

int buttonPin = 2;
int ledPin = 13;
int lock = 9; //pin 9 on Arduino
int buttonState = 0;


void setup() {
pinMode(lock, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(lock, HIGH);
pinMode(ledPin, OUTPUT);
}

void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
digitalWrite(lock, LOW);
delay(5000);
}
else {
digitalWrite(ledPin, LOW);
digitalWrite(lock, HIGH);
}
delay(500);
}
stormdead1 year ago
Hi!... Where is connected the GND of the Power SUpply?
rickharris2 years ago
As always with this type of project what happens when the power supply fails how do you get in/out e.g in the case of a fire?

The program should give an audible signal to show code received otherwise you get multiple presses as users have no feedback.

Likewise you could offer audible feedback that the lock is open.
What happens if the power fails whilst the lock is open, there isn't anyway to re-lock it unless the mechanism has a mechanical default of closed.


This is the type of door latch often used on apartment buildings - it defaults to locked, except when energized, and has an audible click when it opens. It also still allows use of the key / knob, as usual.
The diode is in the wrong place: connect the end with the band to Vcc, connect the other end to the other end of the lock.

Steve
Collin Amedee (author)  steveastrouk2 years ago
I don't completely understand what the diode would protect in the case i set it up the way you mentioned. I implemented the diode after learning my lesson by killing my first transistor. I later used the picture (as shown) from an online tutorial to set up the diode correctly. The way i have it set up seems to be correct. If you disagree please explain
arduino_bb_pot_transistor_motor_diode.png
The Diode has to be across the inductive load - motor or relay. As shown in yours, it isn't/

When the current flowing in an inductor is forced to stop, the voltage across its terminals can rise to many tens or even hundreds of volts. The diode ensures that the current has an alternative path to flow through, as the transistor is switched off. Now, the maximum voltage across the coil is around 1V.

You should use a decent rectifier diode like the 1N4007.

Steve
if you really wanna get fancy and make it grind right to a stop you can use a relay to start the motor and a resistor across the motor when the relay is un-energized and the motor powered when energized. that will make the diode unnecessary because instead the resistor will dissapate the power and as an added bonus it make it a super fast stop (or lock)
The diode is necessary to protect the electronics, whether you have a relay or not. The diode also gives a certain amount of dynamic braking itself.
here is what i was thinking to use the arudino to drive a motor or an inductive load
here is what i was thinking to use the arudino to drive a motor or an inductive load
swpush.jpg
1.) An arduino won't drive a relay directly.
2.) Forget the resistor - you can't do better for braking than a shortcircuit.
3.) You still need a diode on the load, to prevent radiated noise.

Steve
Braking is caused by the resistor. if you just make it a short circuit across the motor then all electrical energy the motor generates and already has dissapates through the motors inductive load and the friction of the motor. the resistor causes the power to dissapate faster.

Just an example equation ignoring friction: if there are five amps flowing in a motor that has a inductive load around 2 ohms. Then power would be I^2 * R which would be 25 square amps * 2 ohms which would be 50 watts.

If i re-do the equations with five amps and a 100 ohm resistor accross the terminals of the motor (technically it would be 100 resistive and 2 inductive which ends up about 100.0199) then it would be 25 square amps * 100 ohms of impedance which is 2500 watts.

Just a small example of how a braking resistor brakes. Is it always necessary? nope. Can it be helpful and make your motor stop a LOT quicker? Yup. In my example the motor will stop around 50 times faster.

by the way on the diode i thought you were meaning accross the motor and being triggered by the relay. You can see in my diagram that i still included the diode across the output to prevent my relay from hurting my 'duino.

Oh and by the way if you search a website like mouser for relays limited the search to 5v and 40 mA (the specs for my 'duino's output). I got around 73 results

and just to make it fit my example i limited it to 5 Amps on the contacts. I still had multiple results


....Just saying
Much wrongness in one place.

There is no such thing as "inductive resistance" There is only inductive reactance. Reactance is NON-dissipative. The dissipation mechanism is resistive losses in the motor winding.

Firstly, your maths. Taking your example.

"5 amps across 2 Ohms" = 10V. (supply volts, say)

Dissipation = 50W.

NOW.

Motor voltage = 10 V (imposed by the supply) resistance = 100 Ohms, power dissipation = 100/100 = 1 Watt. Current is now 10/100 = 100mA.

Your math fails. ADDING external resistance REDUCES the load on the motor !!!

And, OK, Add an INFINITE resistor, which by your specious argument would be THE best possible load ! Leave the pins of the motor open ! Does it now stop FASTER than when its shorted ? Of course not.

If this is a Duo or Duemilenova, DON'T blow your arduino up by running at Absolute maximum rating - the recommended limit is 20mA, and the sum of all pin currents must be <100mA. This is at a maximum package
temperature of 25 C, so derate accordingly at temperatures above that.

....just saying.

Steve

1-40 of 89Next »