Instructables

Arduino RFID Door Lock

FeaturedContest Winner
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
earlvanze2 months ago

For over a year I've been wanting to do this and I finally got around to it. Since I lived in a college dorm (now I'm in an apartment), we can't modify the locks or install an electric door strike, so I used a servo motor wired to the deadbolt with string instead. I have modified the original sketch so it works with a servo motor. I also connected a pushbutton switch so it can be unlocked from the inside. When the pushbutton switch is pressed or a tag is read, the servo motor attaches and instantly turns the deadbolt to unlock, and relocks it in 10 seconds. The servo motor detaches after relocking so that the regular key can be used in case of emergency (and to comply with building rules).

Anyway here's my modified sketch: https://www.dropbox.com/s/85ch1b2y5wp61di/RFID_Doo...

I tried cloning my own Arduino but something's wrong in my circuitry so I just used an Arduino Uno instead. I put the RFID circuit outside and wired it to the Arduino inside conveniently via a single Ethernet cable (used 6 out of the 8 wires). I also connected an RGB LED both inside and outside the door.

pcmofo (author)  earlvanze2 months ago

Awesome! Thanks for sharing your code.

pingywon3 years ago
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)  pingywon3 years ago
 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 pcmofo3 years ago
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)  pingywon3 years ago
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.
pcmofo (author)  pingywon3 years ago
 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 pcmofo3 years ago
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)  pingywon3 years ago
 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 pcmofo3 years ago
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.

This is what i get when i try to upload the code to my Arduino UNO with Atmega328 chip. Any help?

RFID_Door_Lock_Program.ino:127:13: error: #include expects "FILENAME" or <FILENAME>

RFID_Door_Lock_Program.ino: In function 'void loop()':

RFID_Door_Lock_Program:128: error: 'EEPROM' was not declared in this scope

RFID_Door_Lock_Program.ino: In function 'void readID(int)':

RFID_Door_Lock_Program:261: error: 'EEPROM' was not declared in this scope

RFID_Door_Lock_Program.ino: In function 'void writeID(byte*)':

RFID_Door_Lock_Program:277: error: 'EEPROM' was not declared in this scope

RFID_Door_Lock_Program.ino: In function 'void deleteID(byte*)':

RFID_Door_Lock_Program:314: error: 'EEPROM' was not declared in this scope

RFID_Door_Lock_Program.ino: In function 'int findIDSLOT(byte*)':

RFID_Door_Lock_Program:353: error: 'EEPROM' was not declared in this scope

RFID_Door_Lock_Program.ino: In function 'boolean findID(byte*)':

RFID_Door_Lock_Program:403: error: 'EEPROM' was not declared in this scope

I don't know about the rest without seeing your code. But the first line you probably forgot parentheses or angle brackets around your code.

E.g. if you are including the servo library, you would type at the top of your text editor not in a function:

#include <Servo.h>

or if its a header file you created, then put it in the same folder as your sketch and type:

#include "(whatever you called it).h"

Hey I am an Electrical engineering student, new to arduino, is it possible to change the simple arduino chip and components to the ARDUINO UNO?

pcmofo (author)  tylerboutilier3 months ago
Yes. All of the code will work on any arduino micro controller. You just need to use the right pins for serial and you can use any I/O for the leds and door unlock.
jiasheep6 months ago
Could you tell us the value of R1-R5 of the RFID Reader Board? Thank you!
pcmofo (author)  jiasheep6 months ago
The resisters R1-R5 on the RFID reader board will vary for each person. They control the voltage that is going to the tri-color led (R1-R3) and control the voltage for the buzzer and transister that activates the buzzer. You should use whatever values are recommended for the exact LED, transistor, and buzzer you have.
jiasheep pcmofo6 months ago
Thanks for the quick response :) If I'll be using a TRI-color LED with Vf=2.5v and If(green)=25mA If(blue&$red)=30mA--calc http://led.linear1.org/1led.wiz-- my R1=390 ohms, R2&R3=330 ohms. How about R4 and R5? How to compute?
vlasp016 months ago
Where do you plug in the strike plate on the arduino uno r3? and, how can I do this with a PN532 NFC/RFID shield by Adafruit?
hi iam very much interested in this project and want to build one for myself

i have em-18 rfid reader module where it doesn't send the start byte and the stop byte as in particular
just transmits 12 digit ASCII code to the serial monitor
i want to implement this code with some changes according to my reader ,but its really confusing , could you help me out in this issue
my tags read 6B0037E8398D ,6B003819CC86, 0800692B5D17
i wanted to remove the start byte comparison ,stop byte and even the check sum
just wanted to compare tags and respectively add or del cards and want it opened for 15 + cards in my arduino mega
jiasheep8 months ago
Hi! Great Project :) One question though, did you use 1N4001 for D1 in the controller_PCB?
How many cards can it store? Thanks.
How many cards can it store? Thanks
JustinRSharp9 months ago
Great write up. I do have one question for you (hoping you still receive updates about this post). Do you know if its possible to have rfid tags keep the door open as long as the tag is within range of the reader?
pcmofo (author)  JustinRSharp8 months ago
Yes and no. Yes you can do it, No it cant be done with this hardware or even general consumer grade hardware. I looked into doing a RFID setup for my car and its just not reliable enough or have enough range to be useful. Their are Active and Passive RFID tags. You would need an Active tag that has a battery and is always transmitting a signal (like a car rfid key) and you would need a receiver that has a strong enough range to cover the area you want to be inside. This typically means having a sensor both on the inside and outside of a building. Other setups have one on each side of the door and use both to figure out if your are inside or outside rather than constantly checking for your presence. You can always add a timer like wait 5 minutes or keep the door unlocked until you press a "lock" button etc.
jmaroney259 months ago
hey, this is probably a dumb question but I have an arduino uno already and was wondering if that would work. I know you said that you used an ATMEGA 168 and this has an ATMEGA 328, so is there anything different that I would need to do?

Thanks
bresser11 months ago
Is there any way to make this so that I can still open it with the key?
EET19821 year ago
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)  EET19821 year ago
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 pcmofo1 year ago
Thank you very much for the explanation. Helped allot.
What power supply did you use to power the Electric Strike?
What was your 12v power supply for the Electric Strike? Need a little help
MartijnD1 year ago
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,...
This is a cool project.

Have a look at different concept of door security system with image capturing
Do you have any idea another door lock that can be used for this project?
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.
Aust19831 year ago
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 :)
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)  unknownusername27021 year ago
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.
bunanaa1 year ago
Hello sir. Do you have any updates on your RFID Door Lock time-access system?
Naters1 year ago
I would love be able to build something like this :(, well it look amazing anyways! congrats
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!