Arduino RFID Door Lock by pcmofo
Contest WinnerFeatured
IMG_0227.jpg
Screen shot 2010-08-09 at 1.22.26 PM Aug 9.png
IMG_0579.jpg
***Updated 8/9/2010***

I wanted to make an easy and secure way to enter my garage. RFID was the best way to unlock my door, even with my hands full I can unlock the door and push it open! I built a simple circuit with a basic ATMega 168 arduino chip and a ID-20 RFID reader to control an electronic door lock.

The circuit consists of 3 separate parts, a Reader to read RFID tags, a Controller to accept data from the reader and control the output of the RGB LED and the Electric door lock. The door lock is first installed in a door and tested with a 9v battery to ensure correct installation. In most cases you want a Normally Open circuit on the door lock, or Fail Secure. This means the door stays locked when no current passes through it. When 12vDC is passed through the electromagnet in the door lock, a plate in the lock gives way and allows the door to be pushed open freely.

The reader is placed on the outside of the door and is separate from the controller on the inside so that no one can circumvent the security by breaking open the Reader and trying to short circuit the reader. The controller receives serial data from the Reader and controls the RGB led and the Door lock. In this case I have put both on separate bread boards for testing. Here is a video overview of the system in action Read on to see how to build one for your self!



**Update** 
All of the code, schematics, and PCB designs have been tested and refined. They are all posted here as of 8/9/2010

Updated video of the final system installed and working.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts Needed

IMG_0227.jpg
Here are a list of parts and links to SparkFun.com where I bought them. This is the basic set of parts you need to build and arduino and a circuit to read RFID tags into the arduino. I am assuming you have a breadboard, power supply and hookup wires already.

Arduino Stuff

ATmega168 with Arduino Bootloader $4.95

Crystal 16MHz $1.50

Capacitor Ceramic 22pF $0.25 (x2)

Resistor 10k Ohm 1/6th Watt PTH $0.25

Mini Push Button Switch $0.35

Triple Output LED RGB - Diffused $1.95

RFID stuff

Either one of these, 20 has better range, 12 is smaller
RFID Reader ID-12 $29.95
RFID Reader ID-20 $34.95

RFID Reader Breakout $0.95

Break Away Headers - Straight $2.50

RFID Tag - 125kHz $1.95

Other

TIP31A transistor (radio shack/local electronics store $1.50)

Door Lock is from ebay.
Door Fail Secure access control Electric Strike v5 NO
$17.50 (kawamall, bay)

1-40 of 277Next »
pingywon says: May 23, 2010. 8:52 PM
I own a pizzeria and the delivery drivers come in and out of the back door all the time. I have taken your schematic and the modified version of your code (including the eraser card) and modded it myself a little further. I am currently installing this as a system on my back door. I have currently finished all the wiring and am just waiting for a few more parts from spark fun. I have made some changes to fit my actual wants and needs of the location, but overall it is the same lay-out. The whole project has proven REALLY fun so far and I hope to have it all wrapped up with in a week or so.
IMG_0492.jpgIMG_0491.jpg
pcmofo (author) says: May 24, 2010. 8:52 AM
 Thats awesome! Glad to see you are getting some practical use out of my project. I am etching some prototype boards this week and hope to permanently install it on my garage brewery this week.
pingywon says: May 30, 2010. 10:05 PM
So like I said it should be a week later and my project is all done. I have some pics and am uploading a "demo" video to you tube right now. I used RJ45 to run everything and with the 8pins there was one short coming of my version of the project. I will let all of you be the judge to see if you can figure it out. The whole system performs flawlessly....so far anyway.

If there is anyone who decides to do anything else with this code I would really love to see it or even help you test it.


The vid link doesnt show up as a reply. I'll make another post with it.

IMG_0502.jpgIMG_0503.jpgIMG_0504.JPGIMG_0506.jpgIMG_0509.jpgIMG_0514.jpgIMG_0515.jpgIMG_0516.jpg
pcmofo (author) says: May 31, 2010. 7:04 AM
 Wow, I am impressed. You did a really nice job of  throwing that together without using a PCB. I like the eraser card code as well. I cant wait to get mine up and running as well. I hope you had fun building this. It looks like it turned out really nice. 
pingywon says: Jun 1, 2010. 5:48 AM
Thanks man. I really appreciate that. I havent soldered anything this "complicated" in about 2 years, so my soldering started out terrible and by the time I was done it was looking great. I wanted to go back and resolder the whole thing, but I decided to leave good enough alone.

The "outside board" with the rfid reader... I enclosed it in a water proof box, but I also took the time to "paint" all the connection with "Liquid Electrical tape" to help water/moisture proof the whole thing.

Like I had said before if anyone had an additions to the code or design, I would love to see it. Maybe even impliment some of it.
pcmofo (author) says: Jun 1, 2010. 7:32 AM
 Nice! someone here made a PCB design to get the boards printed... I am going to print and etch my own reader board to fit a small electronic enclosure and mount it outside like you have done. It's under a patto so it should not be too exposed. For now I am going to leave the breadboard inside so I can play with the code more.

I designed the circuit diagram so you can still connect a programmer and reprogram it. I really like the idea of a master erase card. One idea I thought of is to have a "programming" master card... then a function card, like... "Add" "Erase" "Erase All" etc. which would allow more customized programming. I'm thinking stuff like one-time-access, access at a specific time of day or span of days.... say someone is coming to do electrical work.. they can go in and out all day but the card wont work the next day etc....

Also planning on using a networked RFID system to track and identify customers/beers we are brewing in the brewery.... so planning on using the same readers and tags for everything.... such that anyone carrying a empty keg into the brewery gets access via the keg because clearly they are helping carry heavy things and dont have time to mess with keys.... or the same tag for a friend may allow them to pour as much beer as they want and pay later but not access into the brewery unless I authorize it etc....

So basically I have lots of plans for RFID and this door reader is only the beginning. 

Working on an arduino remote car starter next... may or may not have RFID... but I expect to be playing around with both sets of code regardless soon. 
pingywon says: Jun 1, 2010. 8:07 PM
I like the idea of one time use cards or "day pass" cards. In order for this system to meet my needs perfectly it would need to have an hours of operation type feature. So that my workers would not be able to enter the door in the middle of the night (11pm-7am) but at the same time I would like my card to work.
That is a feature I would like.
I also think im going to put a simple switch push button on the Arduino RX line so that I can push the button and break the connection between the ardunio and the ID-12 so that I can just jack in to the black box inside housing the ardunio to change the code. instead of having to curently open the box and disconnect the wire.
I was going to use software serial, but I just wanted to get the project done.

Please let me know as you make any new code. I would love you review it and possibly even help test it.
pcmofo (author) says: Aug 9, 2010. 11:05 AM
After a couple prototypes and attempts I have worked out all of the bugs and published the updated PCB designs and schematics. I also embeded a video on the main page showing the new boards and the system working in action. Im looking into getting boards made somewhere incase others would like to order them.
bresser says: May 20, 2013. 8:40 AM
Is there any way to make this so that I can still open it with the key?
EET1982 says: Apr 22, 2013. 1:12 PM
Hello. I just received my locking mechanism for the project. It's exactly like yours. It seems to me that it will only work if the door knob is thumb latched from the inside and no way to unlock it physically from the outside. Otherwise, any turning of the knob, if the thumb latch is unlocked, will just open the door no matter if the electronic lock is engaged or not? Is that the way your door knob is set up? thumb latched on the inside at all times and just pull or push the door to open it? Thank you in advance for your insight. Take care and thank you for the great instructable!!!
pcmofo (author) says: Apr 23, 2013. 9:53 AM
This is discussed at some point in the comments. Many people questioned what would happen if the power went out or the security of the RFID. The answer of course is that the lock stays the same on the door knob but the door jam catch is replaced. This means their is two ways to open the door. Either with a key or with RFID. In the case of a key the door works like it did before. With RFID the door stays locked but the latch gives way and the door can open.

This is nice if you lose power or something goes wrong with the lock. In my garage I also use it to unlock the door if I keep going in and out.

You can also get other types of door handles. They have some just for apartment buildings that can be locked from the outside but the inside can simply twist to open the door and it will remain locked. This lets you leave without using RFID or unlocking the door.

If you want RFID only you can use a different type of door knob or use an electric deadbolt etc.
EET1982 says: Apr 23, 2013. 10:40 AM
Thank you very much for the explanation. Helped allot.
pyroscience10 says: Mar 26, 2013. 5:31 PM
What power supply did you use to power the Electric Strike?
pyroscience10 says: Mar 25, 2013. 6:50 PM
What was your 12v power supply for the Electric Strike? Need a little help
MartijnD says: Mar 18, 2013. 7:44 AM
Another benefit could be that when a card is lost, you can put it on the alarm list so when a old employe or not so honest finder tries it alarm goes of, pictures are taken,... You could even use it as a working hours registration, log-in and log-out times, read data file.... Start disabling function on scooter or car,...
GeniusDevils says: Mar 9, 2013. 10:40 PM
This is a cool project.

Have a look at different concept of door security system with image capturing
unknownusername2702 says: Feb 22, 2013. 8:32 PM
Do you have any idea another door lock that can be used for this project?
shamrock124 says: Feb 2, 2013. 3:07 PM
I am currently looking to replicate your system which I must say is beautifully done. I was going through your parts list and when I went to look at the ATmega168 with Arduino Bootloader it is no longer being sold by SparkFun Electronics. I am wondering if there is an alternate unit that I could use in the place of this piece.

Thank You for the instructable.
Aust1983 says: Jan 6, 2013. 12:13 PM
Amazing. I'm not an electronics advocate but this project looks very interesting to try. Thank you for sharing the components as well as the price. The next weekend I'm going to try this with help of some friends just for fun. I was impressed to see the guy who applied this to his pizzeria, it's really cool.

Thanks for the guide :)
unknownusername2702 says: Oct 13, 2012. 8:41 PM
HI, PLease answer this question the Mini Push Button Switch $0.35 was for turning the machine on and off right? also the Door Fail Secure access control Electric Strike v5 NO $17.50 is out of stock on ebay could you reccomend any other place to order it online? THanks awaiting your answer :D
pcmofo (author) says: Oct 16, 2012. 11:14 AM
The switch is to reset the micro controller. Many companies make electronic strikes. I would check ebay or amazon for a similar model. Your guess is as good as mine.
bunanaa says: Oct 7, 2012. 9:39 AM
Hello sir. Do you have any updates on your RFID Door Lock time-access system?
Naters says: Sep 22, 2012. 10:29 PM
I would love be able to build something like this :(, well it look amazing anyways! congrats
jpersons1 says: Sep 11, 2012. 1:45 PM
I have got almost this whole circuit figured out. I am about to start ordering the parts and start to build. However, I want to make sure I understand how to complete this project before I dive head first into it.

SO,

The only problem I am having trouble understanding is what I need to program the chip?

Can anyone give me links or suggestions as to where I can find a programmer/chip that will work with the provided code (Not really interested in typing own code even though I probably could).

I am an electrical engineer at school and this is my first project on my own. I am open to stand alone chips or a arduino board with the programmer built in.

Any help at all would be appreciated, thanks!

jwalk3 says: Aug 20, 2012. 1:00 AM
Hi

I cannot buy the ATmega168 because it is outdated but there is a ATmega328 will thiswork?

Also if the power is turned off will it have memory loss or not

Thank You
dtechusa says: May 14, 2012. 5:29 PM
if it will not compile and you get an EEPROM error:
change #include to this

#include

its the first line of the code
dtechusa says: May 14, 2012. 6:07 PM
LOL, well it doesnt show up when I use the actual characters

#include alligator eats EEPROM.h alligator leaves

alligator eats is <
alligator leaves is >
redfox05 says: May 13, 2012. 11:30 AM
Whats R3, as its not mentioned in the "parts needed" section. Are there any other things that are needed in addition to the initial parts list? Not a complaint, I know you cant specify 'every' single thing, but I want to make sure I can order everything in one go, as the electronics store is not particularly close to me.

Many thanks!
Russ
redfox05 says: May 9, 2012. 3:43 AM
Hi, great instructable, its my first arduino project! One question though:

For the FTDI Programmer, do I need a 3.3v o 5v? I have bought the ATmega328 as this is newer than the 168 which appears to be outdated now. Is this correct/still compatible?

Ftdi choices (i hope its one of these :)
3.3v - http://uk.rs-online.com/web/p/communication/0429307/
5v - http://uk.rs-online.com/web/p/communication/6877770/

The are many other choices on the site, what are the differences???
http://uk.rs-online.com/web/c/?searchTerm=Usb+to+ttl&sort-by=P_breakPrice1&sort-order=asc&view-type=List&sort-option=Price

P.s. im UK based in case of tips for other shops.

Thanks,
Russell
pcmofo (author) says: May 9, 2012. 10:30 AM
FTDI programmers have both 5v and 3v lines on them. Most arduino stuff is 5v. Almost any FTDI cable will work with any FTDI port on an arduino.
redfox05 says: May 9, 2012. 3:32 PM
Thanks for the quick reply pcmofo. I'll go with 5v then. One more question, is there any difference/preference between a cable ftdi and a breadboard one?
redfox05 says: May 10, 2012. 5:30 AM
Im buying the parts right now from RS Components, and they dont have any 0.167w resistors. The lowest ones they do are 0.25w would tht work? How does the wattge affect it, as even the arduino.cc site just says a 10k ohm resistor, without stating wattage.

Sorry for all the questions, but i want o go out and buy these today so I can start on the project tonight.

Thanks in advance!
Russell
yadoo86 says: Mar 2, 2012. 6:06 AM
I just want to inform you that your lovely tutorial has been published on our facebook page ( http://www.facebook.com/faceuino ). Please feel free to join us and add your future tutorials.

Thnx for your effort
Faceuino team
weekendtech says: Nov 8, 2011. 5:01 PM
How do i fix the "eeprom was not declared in this scope" error
I am doing this for a college project and have never used arduino before we are building it to interface it with computer help would really be appreciated is there part of the code i am missing?
loizosgroutas says: Feb 29, 2012. 6:02 AM
I had the same problem. To fixed is easy. paste at the firt line
#include // Needed to write to EEPROM storage
this .
Now look like this.
#include // Needed to write to EEPROM storage.

Sorry for my english.
electfire says: Dec 7, 2011. 4:59 PM
On the second video @ 3:24 when you are showing the power supply socket.... Is that a modified wall plate for connecting built-in speakers in a home theater? It looks like it... so instead of connecting it for left and right audio channels you used it for positive and negative power connections... This is a neat idea... though it would really only be worth it if you intend on using many things that run on 12 volts...
Also I hope you have this hooked up to back up power!
Jsmxbox says: Oct 30, 2011. 3:27 PM
Hey im getting a problem i have 4 RFID keyrings they all work and i can read them all fine but the problem is 2 of them start with 00 00 and will not work as master, delete or wipe but the other 2 start with 00 01 and work without problems any reason why this would happen?

many thanks

Jamie!
Jsmxbox says: Oct 30, 2011. 3:34 PM
Also found a floor in it too being that if you scan a key that ain't stored in the EEprom more than 3 times it still unlocks the "door"
Stomp says: Sep 22, 2011. 11:03 AM
Can someone pls. tell me all the components I need to the PCB Techno Dancer have maked for this excelent project? Referering to his Eagle files...

Regards

Mikkel
agsking says: Jul 10, 2011. 9:03 AM
could you use this project to lock/unlock a deadbolt lock instead? if so, what deadbolt would work with this?

thanks
1-40 of 277Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!