Arduino RFID Door Lock

Arduino RFID Door Lock
***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 1Parts Needed

Parts Needed
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)

« Previous StepDownload PDFView All StepsNext Step »
251 comments
1-40 of 251next »
May 23, 2010. 8:52 PMpingywon says:
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
May 30, 2010. 10:05 PMpingywon says:
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
Jun 1, 2010. 5:48 AMpingywon says:
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.
Jun 1, 2010. 8:07 PMpingywon says:
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.
Dec 7, 2011. 4:59 PMelectfire says:
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!
Nov 8, 2011. 5:01 PMweekendtech says:
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?
Oct 30, 2011. 3:27 PMjmayes1 says:
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!
Oct 30, 2011. 3:34 PMjmayes1 says:
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"
Sep 22, 2011. 11:03 AMStomp says:
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
Jul 10, 2011. 9:03 AMagsking says:
could you use this project to lock/unlock a deadbolt lock instead? if so, what deadbolt would work with this?

thanks
Aug 2, 2011. 11:58 AMLegoGuy23 says:
I would Imagine so. If you connect the Arduino to a servo attached to the deadbolt, I think it could work. Just a theory though.
Sep 19, 2011. 6:13 PMAlfaZulu says:
hey, i'm just a little confused with how you programmed the eeprom. I was planning on using an arduino uno with an ATMega 328p, mainly because i don't believe they make the 168 anymore..

would this code work just fine straight in the arduino software?
Sep 19, 2011. 12:50 PMSilent99 says:
Willing to pay someone with experience to build me one of these or provide all instructions I would need to build one myself. Msg me
Sep 12, 2011. 12:15 AMkgee says:
i also had a question about the RFID cards that you programmed to work for the door... that wasn't for the door. like you made a copy. but can you erase it?
Jul 28, 2011. 8:04 AMnmstar56 says:
I'm getting "error: 'EEPROM' was not declared in this scope" for "EEPROM.write(i, 0);"

Please help.
Aug 14, 2011. 4:17 PMTrueHybridX says:
did you include the eeprom header files?
Aug 7, 2011. 10:55 AMjlim10 says:
would it be possible to program your fingerprint with a biometric reader as the mastercard?
if so can you guys teach me how, im really bad at programming
Jun 16, 2011. 2:32 AMnatsud1 says:
Hi i have an Arduino328 and a parallax rfid reader but i dont really know how to write code although im trying to learn my first problem is that when i load the code and run it the blue led is not on but the other 2 are so i looked at your "normalModeOn" part and it looks to me that it is exactly backward of what i thought it should be since you have the "powerpin" high and the rest low and the tricolor led has one + and three - electrodes this seemed backward .all i have hooked up is the reader and the tricolor led if i reverse the normalModeOn from high to low and the lows to high i get the blue led so i then swiped a card and nothing happensi cant seem to figure out what to do or what to change is it because of the different arduino and reader or am i just supposed to figure out where the code needs to be changed for theses Pleas Help i dont know much about code
Jun 16, 2011. 3:32 AMnatsud1 says:
OK so its been another 3 hrs but i made some progress i had a different rfid code that would read the card and diaplay it in the serial monitor and i found this "if((val = Serial.read()) ==10)" was different than your code yours was: "if((val = Serial.read()) ==2)" so i changed all instances to the number 10 and i got it to make the led blink odd color purpleish .. like i asked before about the led out highs and lows being reversed in the void sections well i reversed all of them and now when i swipe my non master/non saved card it turns red and when i swipe my master it goes to the program blinky sequence and it grants access to the former card when i reswipe it so i think i got some of it working but im not sure about the door lock part i have an led stood in place of the lock but it doesnt light up yet ill let you know if i get anywhere else on it sorry about the long comments this is a great 'ible im sure all my problems stem from lack of knowledge of code and other stuff hope what i said made since and maybe helps somone else
Jun 3, 2011. 10:50 PMkidmosey says:
That enclosure seems to have enough space to add a keypad as an alternative means of entrance, in case you lose your rfid tag. Might also be good to disable the tumbler lock, since any Joe Smith can pick a lock, nowadays.

Also, if you put your rfid tag in a retractable thumbdrive (lined with aluminum), would that prevent people from passively thieving your rfid?
Jun 1, 2011. 9:05 AMtinker234 says:
wow use the star trex door with this
May 11, 2011. 3:58 AMjoshnosh says:
iv got quite far on this project now
iv got it working on a bread board and iv made a PCB i just need to drill and assemble. I cant get the newer code to work but oh well ill live

anyway iv been in discussion with someone and realised it would be a good idea to include a high voltage diode across the door lock pins.
when the door lock is closed the magnetic feald collapses in the door strike and this can cause quite high voltages to be produced as it collapses. these voltages will try and discharge through your tip31a transistor and can damage it over time
putting a diode there will allow the the door strike to loop back through itself and discharge. its not needed but it might help improve the reliability of the system
May 8, 2011. 9:36 PMinsignia96 says:
What's Hilarious is that I, at this point in time, have an arduino, i am custom etching a shield, I have an outlet box, 2 RGB status leds, and to shorten this list up almost an identical project/Instructable I am working on and This is the first time I have read through this. Pretty funny, I guess great minds think alike!
Apr 30, 2011. 7:41 AMboudreau-inventor2 says:
I have couple questions. Where did you find the breadboard power supply for 12 volts? And, what size is the breadboard you are using?
Apr 7, 2011. 10:57 AMPrivatHost says:
Which Values has the Resistors R1, R2, R3, R4, R5?
Apr 7, 2011. 10:36 AMPrivatHost says:
What diode (D1) did you used?

Is it the 1N4007 ?
Apr 29, 2010. 11:06 PMusamasiraj says:
Hi i am a bit confused about the connections of header, header1 and the tip31a transistor. Do we have to connect Header from the rfid reader schematic to the controlling schematic. And what about the header1.??? Please help me out
Apr 5, 2011. 8:48 PMkipfan23 says:
Both of the headers do have to be connected. header1 is used to connect the ATMega to the reader while Header is used for the RGB LED.
Apr 29, 2010. 11:55 PMusamasiraj says:
I am also confused about the schematic, since the pins in the pictures and the pdf seems to be different..Please explain which one is right??..Thank u
Apr 5, 2011. 8:44 PMkipfan23 says:
The pdf is a PCB layout, the image is a schematic. the pins on the ATMega in the schematic might not be in the same place as the pins in real life. It looks like the pins on the left are used for basic arduino functioning while the pins on the right are used for signal. you can look up the datasheet for the ATMega online to find the excact placement of all of the pins.
Hope this helped!
Jun 26, 2010. 7:45 PMTechno Dancer says:
What's the value of C7?
Apr 5, 2011. 8:40 PMkipfan23 says:
0.1uF
Mar 15, 2011. 10:51 AMjoshnosh says:
hey
im getting a
"eeprom was not declared in this scope" error
any way to fix this im stuck
it refrences the "EEPROM.write(i, 0);" line about a 5th off the way down
Mar 13, 2011. 9:30 PMmarkp912 says:
On the RFID schematic from header pin number 2 to the id-20 board pin 9 what is that connection? Is that 16 from the arduino board? Also what are your values for R4 and R5 in the RFID schematic? Please help! And thank you.
1-40 of 251next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
69
Followers
4
Author:pcmofo
I like to take things apart, sometimes they go back together sometimes they end up as something entirely different then where they started.