loading

Here we are with the classic RFID door lock. It's classic in that whole, "We live in the future and take it for granted at this point" sense. In this tutorial, we will set up a door latch that can be opened with the swipe of an RFID Tag! We will program a list of acceptable 'key' cards that will unlatch the door for a specified amount of time. This is a really simple project, but it does require that you alter your door jamb, so be prepared to do some wood work if you the strike plate to fit securely and flush.

Step 1: Project Parts List

These are the recommended parts for this project. You can use another Arduino variant, relay, or compatible RFID Tag, but we recommend using the RFIDuino Shield so that the code we will provide you in this tutorial works without a hitch.

Note that using a straight door latch solenoid requires power to unlock the door. If you lose power, you will be effectively locked out and unable to open your door until power is returned to the system. With the electronic strike plate, you can still use your regular key to open the door in the case of a power outage. Choose wisely.

Step 2: Get Your RFID Tag Data

  1. Connect your RFIDuino as shown. (Click here for the v1.1 Connection Diagram)
  2. Open RFIDuino_helloworld onto your board. You can find this sketch under
    File>Examples>RFIDuino>RFIDuino_helloworld
  3. You will need to make sure the code is adjusted for your RFIduino hardware.
    v1.2 shields (2 pin antenna, 'REV 1.2' printed on the board) will need the following code
    RFIDuino myRFIDuino(1.2);     //initialize an RFIDuino object for hardware version 1.2
    v1.1 shields (4-pin antenna, no version number printed on the board) will need the following code
    RFIDuino myRFIDuino(1.1);     //initialize an RFIDuino object for hardware version 1.1

    Both lines of code are available in the RFIDuino_helloworld sketch, simply uncomment the one you don't need.

    If you are still unsure about what hardware you are using, see this page

  4. Connect a micro USB cable from your computer to your Geekduino
  5. Load RFIDuino_helloworld3 onto your board using the upload button in the Arduino IDE.
  6. Once loaded, you can leave your board connected to your computer - you will need this connection to power the board and to communicate with the computer
  7. Open the Serial Monitor.
    Tools -> Serial Monitor

    The serial monitor should be set to its default settings ('No Line ending', 9600 baud)

  8. Swipe a tag across the RFIDuino antenna. The green light will light up and your buzzer will make a noise.
  9. The Serial Monitor will display 5 numbers. These numbers make up the ID of your tag.
  10. Copy down these numbers for future use. It can be handy to write the ID on a sticky note and attach it to the tag. NOTE: You will need the ID for at least one tag for the next step.

Step 3: Wiring and Programming


  1. Connect your components as shown here.
  2. Open RFIDuino_demo3_lockbox_multi onto your board. You can find this sketch under
    File>Examples>RFIDuino>RFIDuino_demo3_lockbox_multi
  3. You will need to make sure the code is adjusted for your RFIduino hardware.
    v1.2 shields (2 pin antenna, 'REV 1.2' printed on the board) will need the following code
    RFIDuino myRFIDuino(1.2);     //initialize an RFIDuino object for hardware version 1.2
    v1.1 shields (4-pin antenna, no version number printed on the board) will need the following code
    RFIDuino myRFIDuino(1.1);     //initialize an RFIDuino object for hardware version 1.1

    Both lines of code are available in the RFIDuino_demo3_lockbox_multi sketch, simply uncomment the one you don't need.

    If you are still unsure about what hardware you are using, see this page. The RFID Experimenter's Kit comes with the version 1.2 shield.

  4. Modify the code for the number of cards you want by editing line 58. For example, if you have three cards, use the code
    #define   NUMBER_OF_CARDS 3     //total numer of key cards that the system will respond to.  		
  5. You will also need to modify the sketch to include the IDs of the tags that you want to include. These IDs can be found using the Hello World sketch. Find the block of code starting at line 62 - it looks like this.
    byte keyTag[NUMBER_OF_CARDS][5] ={
    {0,0,0,0,0},  //Tag 1 //commenting each tag with a description can help you keep track of them
    {0,0,0,0,0},  //Tag 2
    {0,0,0,0,0}, //Tag 3
    {0,0,0,0,0},//Tag 4
    }; 		
    Now insert the IDs for your tags. If we had three key tags, our code might look something like
    byte keyTag[NUMBER_OF_CARDS][5] ={
    {77,0,44,22,242},  //Tag 1 //commenting each tag with a description can help you keep track of them
    {200,1,4,98,236},  //Tag 2
    {23,64,4,25,1}, //Tag 3
    }; 		
  6. Connect a micro USB cable from your computer to your Geekduino
  7. Load RFIDuino_demo3_lockbox_multi onto your board using the upload button int the Arduino IDE.
  8. Once loaded, you disconnect the USB cable from your computer..
  9. Swipe any of the 'key' tags across the RFIDuino antenna. The green light will light up and your buzzer play three different notes. Additionally, the solenoid will fire.
  10. Swipe any tag that is not the 'key' tag across the RFIDuino antenna. The red light will light up and your buzzer play three monotone notes. The solenoid will not react.

Step 4: Mount It Where You Can Use It

Once you're sure that you have it programmed and the latch releases when you swipe the correct RFID Tag, mount it in your door frame. We had a metal frame door with glass windows, so it was an easy call putting the RFID Reader behind the glass. You may want to mount the antenna in a weatherproof box for accessibility and keep the ~duino and other electronics indoors for safety.

There are instructions with the strike plate that should help you mount that. We recommend keeping the plate as flush as you can to the wall it's mounted to, and to be careful when running wires through a wall.

Step 5: You're Done!

That was fun! So now that you have an arduino that can let you into your home, what are you going to do next? You could add a keypad for code entry, that'd be pretty cool. What about integrating bluetooth, so you can unlock your door with your phone? There are loads of features you can add, and we'd love to see what you come up with!

<p>Would I have to get two sets if I want to unlock two doors independently with the same key, or installing another relay and antenna would work?</p>
Be careful if you have this lock on the only entrance to an apartment or house. Make sure it can be unlocked from the inside with the power off or you'll get stuck inside during a power failure.
<p>Great instructable. Puts me on track for doing away with the ignition key on my old car. RFID card and big red starter button. Thanks </p>
<p>Yeah be careful, I recently lost my keys so I decided to &quot;hot wire&quot; my car cause I thought it would be easy, and it was. However, as I found out just before I drove off, the steering wheel on some cars remains *mechanically* locked unless the key is inserted.</p>
That'll be cool! But you might need to work out how to unlock the steering wheel without the key?
<p>That sounds AWESOME. Make sure to post an instructable about it when you're done, that really sounds like a fantastic project!</p>
<p>A very good Instructable, thank you for sharing. A question however; how would you do this WITHOUT holding the authorised tags IDs in the actual sketch? I have built an RFID thingy similar in scope to this however, I don't want to keep my tag IDs in the sketch. I have an SD card attached to my RFID thingy and I have programmed it to read data off the card but I haven't yet sussed out how to get the thing to read authorized IDs from the card and act accordingly. It does work when the tag IDs are in the sketch but not on SD card. </p>
<p>I have complete code for using the generic Wiegand readers with Arduino that utilises EEPROM to store tags in an 'offline' setup. I have 2 other versions that use Ethernet too, one you can program over Telnet (writing up to 50 tags to EEPROM), the other uses MQTT in a challenge/response setup for use in home automation.</p><p>Simple, cheap, easy.</p>
<p>Alternatively, You can save the card details in EEPROM and retrieve it. It'll be a better option than storing the card ID in program itself.</p>
<p>I'm not personally familiar enough with the SD card library structure to give you any meaningful pointers beyond checking out the documentation on arduino.cc <a href="https://www.arduino.cc/en/Reference/SD">https://www.arduino.cc/en/Reference/SD</a> </p>
The more security you have the more a thief will think you have something of value , no security no valuables <br>
<p>Nice Project! Remember though that the cards you are using can be read with a bit of hardware from quite a distance, and that they can be easily cloned including the ID of the card. I would not recommend to use that system for your main entrance because of that.</p>
Meh. Or somebody could just throw a rock through the glass. Or pick a conventional lock with any one of the youtube videos on the net. I don't think this is any less secure than anything else really.
<p>It is quite a bit faster and easier to use an <a href="http://www.ebay.co.uk/sch/i.html?_odkw=rfid+reader&_osacat=0&_from=R40&_trksid=m570.l1313&_nkw=handheld+rfid+reader&_sacat=0" rel="nofollow">RFID reader for $10</a> than it is to learn to competently pick locks though. A copied RFID card also leaves no trace of forced entry which may cause problems with insurance claims.</p><p>Speaking of which, insurance policy is <em>the</em> reason to think twice about putting a homebrew lock on your front door as a security classification of some kind on the lock may often be a condition for a full pay-out.</p><p>So while it is worthwhile to every now and then point out that tumbler locks aren't very safe to begin with, also pointing out flaws in any alternative scheme is just a responsible thing to do.</p>
No, it's just nitpicking and unappreciated.<br>A paperclip with several youtube videoa on lock picking is cheaper and more readily available than a $10 RFID reader, and leaves no trace. Most people can learn to jiggle tumblers quicker than they can learn computer programming fundamentals, then RFID including which equipment to procure, then programming and use of that equipment.<br>Or, they could just kick the door or throw a rock thru a window.<br>If your insurance specifically calls for a minimum security classification then yeah, you're taking a gamble, but life is a gamble.<br>Everybody nitpicks too much motivated by wanting to sound smart. The smart people can tell the difference between nitpicking and legitimate critiques.
<p>Locks were made to keep honest men honest.</p>
<p>Or my version: Locks were meant to keep the honest people out!</p>
<p>(chuckles) We always said it kept the honest thieves out. </p>
<p>(chuckles) We always said it kept the honest thieves out. </p>
Truth
<p>I wonder if you could create something similar that would use your phone instead, with NFC or something like that</p>
<p>Totally possible with an arduino compatible NFC transceiver. I'd love to see it happen.</p>
I was wondering the same thing.
You want a normally SECURE or fail secure lock. Normally open or fail safe locks are used on fire doors and open on loss of power. Just remember, Normal is considered how it is in your hand, no power supplied. Just like switch positions.
<p>The one linked in the parts list is listed as Normally Open and Fail Secure. It stays in locked position unless it receives power. I should definitely make a mention of the terminology. This could get confusing for someone in a hurry! Thank you very much!</p>
<p>My plan is to modify an electronic push button lock (they are usually about $100), to operate through the RFID reader by using a DPDT relay directly to the lock motor. By simply connecting the motor to the common pins, and the normal motor wires to the normally closed contacts, and then connecting the locks battery to the normally open contacts. A 2 second pulse to the relay would unlock the door. The lock itself has a button to simply lock the door. This would give the added use of a keypad if there is no power, or if the arduino malfunctions. With a wooden door (even with a metal cover inside and out), you could connect the coil wires of the relay through 2 hinges of the door, and completely hide the wires in the door frame (especially if you have a door with a glass insert. There is a RFID control lock you can get on ebay for about $15 that includes RFID tags, that does much of what is needed, but it is a plastic casing and could easily be compromised if it is outdoors, but you can add an external antenna. I like the arduino idea, because you could add BT or wifi to operate from a cell phone, or central controller with logging, and could even sense if the door is opened or unlocked through remote query. .. Lots of ideas. !!!</p>
<p>Sounds legit, we'd love to see it! Using the relay to jump the wires that would normally be used by a switch is essentially how we set up the RFID kit to work with our garage door, and you're absolutely right, it works and leaves the keypad in usable condition. Thanks for sharing!</p>
<p>Good work! It'd be interesting to see a version using a wifi enabled arduino (to do things such as centralising logging and control)</p>
<p>Thank you! We'd love to make one that utilizes wifi to log usage data for sure.</p>
<p>It will be fun to get into the house, when there is a power shortage, or something breaks (because in my experience, most of the DIY things made by amateurs are not stable). But yeah, nice Instructable! </p>
<p>The electronic strike plate does not impede the use of your normal set of keys, allowing you access regardless of the power situation. We haven't had any stability issues, and we've had one of these running for nearly 3 years now. I'd say it's a pretty safe bet that anyone on this site that can build it in the first place can keep it running without an issue. Thanks for the input!</p>
<p>if i were to use a arduino micro what rifid module would work? also would this work with nfc</p>
<p>Not sure, but with a quick google search, I found a fellow who was doing it with an arduino mini pro <a href="https://www.adafruit.com/product/789">http://forum.arduino.cc/index.php?topic=17085.15</a><br>With this equipment, it would not work with NFC. I'd recommend this guy if you want to use NFC: <a href="https://www.adafruit.com/product/789">https://www.adafruit.com/product/789</a></p>
<p>Could be interesting for this project : http://www.seeedstudio.com/depot/MicroNFCBoard-p-2431.html?cPath=19_24</p>
<p>^ good suggestion.</p>
<p>Would it be possible to have the RFIDuino save a log file to the SD card with all the access requests time-stamped?</p>
<p>It would! We were recently discussing the way we wanted to handle log files in the office, and that's one of the ways. SD Card is a decent solution, but really the end result is that you're going to load that file on a computer to read it, so we've been working on ways to send to a network drive without adding too much complexity or cost.</p>
Ok thanks
How much did this cost? Bte great instructable
<p>This was just over 100 dollars in parts, which is a little less expensive than a commercial system.</p>
*btw

About This Instructable

59,704views

759favorites

License:

Bio: The RobotGeek team is a 6-man operation that wants to make it even easier to use Arduino to make electronics and robots. Check out our ... More »
More by robotgeek_official:Voice Control Chip-E With Google Home Rock'em Sock'em Literal Robots 3D Printed Automatic Small Fish Feeder (Single Servo and Arduino) 
Add instructable to: