Picture of Arduino RFID Door Lock
Screen shot 2010-08-09 at 1.22.26 PM Aug 9.png
***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!

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
1-40 of 314Next »
earlvanze1 year 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:

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.

The best part about using a servo is I don't have to modify the existing door frame to fit an electric door strike, and it's fairly portable since everything is just hot glued or Command stripped to the door, no screws required. The USB power cable for my Arduino Uno is taped down. The Ethernet cable connecting to the black box RFID reader outside the door is routed down from the Arduino box and through the gap under the door, back up on the outside of the door to the reader. Usually apartment doors have wide enough gaps underneath.

The worst part about using the servo is getting the string to mesh with the deadbolt perfectly so there's just enough tension both opening and closing the deadbolt. That part takes hours. I wish I could just use a Lockitron that fits right over the deadbolt. Maybe I can 3D print a unit that mounts the servo to the deadbolt easily and without the use of strings.

The string I used is the strong, unstretchy kind used in window blinds. I reused a piece from broken window blinds.

pcmofo (author)  earlvanze1 year ago

Awesome! Thanks for sharing your code.

earlvanze pcmofo6 months ago

Here's a video of it in action (installed in my apartment building):

pingywon4 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.
pcmofo (author)  pingywon4 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 pcmofo4 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 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.

pcmofo (author)  pingywon4 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)  pingywon4 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 pcmofo4 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)  pingywon4 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 pcmofo4 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.
blackcamo2 days ago

cheap source for arduino and all associated stuff....

OsmanQ1 month ago

In this schematic that you uploaded above, will I be able to use the same schematic I/O on an Arduino Micro or an Ardweeny? And will I have to make any changes to the code?

SalaheddineS2 months ago

please i want just ask you about the TIP31A if i replace it with a TIP41C

h.akan_4 months ago

nevermind the comment from me before!, i got it thanks a lot! great project

yumdeyum h.akan_2 months ago

What is it?

yumdeyum2 months ago
What do you need for the power supply? Can you take the controller pcb.pdf and the reader pcb.pdf and have them etched somewhere?
h.akan_4 months ago

Can someone please tell me what kind of breadboard powersupply that is, or where i can buy one. i really need it for a school project. Thanks alot!

Hi Do you have the ready set, I want to purchase it......

azaroth085 years ago
 Very good and clever.  Im a little curious about how you could add a log.  It sounds like a challenge :P
pcmofo (author)  azaroth085 years ago
 you could store a log in memory storing the date and time + the number of the ID that was accessed. Using the ATmega168 is not too practical for this though. If I do that it will be using a network adaptor and sending the log information over the internet. 

At the very least you could store the last 10 people to enter or something along those lines and pull it back out with additional code. 

How do you create the master card

jewelzc4 pcmofo4 years ago
also the addition of an SD adapter for data logging purposes could work if a network connection is not desirable. This would take care of memory space issues on the ATmega.
ultra126 months ago

Hy guys , i need help about the master card.. How to set a card as a master card ??? I mean how to hard coded it ??

arsmrn6 months ago

Hi. I have an RDM630 reader instead of the ID-20 by Innovations. Will it still work? What would the schematic diagram look like?

arsmrn6 months ago

Hi! I've decided to make one for my school project. What're the values of the electric components used on the reader? Can't find it on the schematics.

dsaddleme7 months ago

Hey guys!

I need help! Serious one..

I'm not a pro acc user hence i can't download any PDF. WOuld anyone be kind enough to mail me the PDF and the circuit diagrams and all the stuff required to make this project.

M a TE EnTC engineer. I need this project.

Thank you.

omersiar made it!7 months ago

Hello again,

I'm so sorry about that i spammed comments, it was by mistake. I tried several Browsers to send comment but no luck, now it seems working.

I have another 13.56MHz RFID Reader called RF - RC522 which talks with Arduino on SPI protocol, I tried make it to work with your code which is really cool, your EEPROM algorithm amazing. Thank you sharing your work, really inspired me.

RC522 Library for Arduino and Modified code on GitHub.

TAG Read.PNGIMG_20140801_175934.jpg
BrentS18 months ago

I'm in a similar situation, and this seems like a fun way to make life a lot easier. How much did this project end up costing you? And is there any way to make an analog bypass to this system?

pcmofo (author)  BrentS17 months ago

The physical key is still there. It still opens the door.

omersiar made it!7 months ago
(removed by author or community request)
pcmofo (author)  omersiar7 months ago

Nice work!

rhevierose7 months ago

Hi sir or anyone. I want to know what type of lock mechanism you used and how you connected it to the arduino? thank you.

mwessler8 months ago

When I first moved into my home, I knew I wanted to do something like this. Would it be easy to use NFC rather than RFID? I plan on getting the NFC ring ( for other various uses, and being able to do this would be great!


Joe_Studer9 months ago

If I wanted to take this same concept, but apply it to a gate, what changes, if any, would I need/want to make?

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)  tylerboutilier1 year 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.
1-40 of 314Next »