RFID Door LockPosted: September 16, 2011
I’ve been a college student for a few years now and one of the first things that I hacked together while staying in a dorm room was an RFID (Radio Frequency Identification) lock. I was always in a rush to get in and out of my room and having a wireless key made it that much easier. The challenging bit was that I needed to be able to attach it to my door without modifying any of the hardware and I also wanted it to be hidden from the outside. My first prototype was pretty rough, but over the past year I’ve refined my design and finished a minimalistic circuit board.
In the first half of the RFID TTJ episode, I walk through the process of building this design and loading the board up with code. I’d highly recommend watching the video as it will give a good explanation of how everything is put together and goes further in detail than this post.
Now then, let’s get onto the details. The first thing you’re going to need for this build is the actual circuit board that everything gets connected and soldered to. I put together the minimal board design using Eagle.
You can download all of the Eagle files and generated board files here:
For actually having the board manufactured and sent to you, I highly recommend BatchPCB. Although you may have to wait upwards of a month to get the finished board in the mail, it’ll only cost you $10-$15 including shipping. I’m hoping to put together kits in the near future to make this step a bit easier.
As explained in the video, you have two options for RFID readers. You can either use an HID reader (common among universities and corporate environments) or a Parallax reader that uses the EM4102 card standard. As I was issued an HID card to gain access to the various buildings on campus, I decided to go with an HID reader for my purposes. The main issue is that HID readers are significantly more expensive (~$150 retail). You can find them cheaper on eBay, so if you really want to be able to read HID cards then I would suggest that route. If you don’t already have any RFID cards, the Parallax reader (~$40 retail) is most likely the way to go. This circuit board will work with both options – you’ll just be connecting the readers to different pins and loading different code.
As for all of the parts you’ll need for this build, I’ve compiled the list below:
1. (1) Custom Circuit Board (~$15 ordered from BatchPCB)
2. (2) 47uF Capacitors [Mouser.com Part #: 647-UHE1E470MDD] ($0.30)
3. (1) 5V Regulator [Mouser.com Part #: 511-L4931CZ50-AP] ($1.15)
4. (1) 20 Pin Socket [Mouser.com Part #: 571-1-390261-6] ($0.21)
5. (1) ATtiny2313 [Mouser.com Part #: 556-ATTINY2313-20PU] ($1.91)
6. (1) Header Pins [Mouser.com Part #: 649-68000-416HLF] ($0.40)
7. (3) 3 conductor screw terminals [Sparkfun.com Part #: PRT-08235] ($4.50)
8. (1) 2 conductor screw terminals [Sparkfun.com Part #: PRT-08084] ($1.25)
9. (1) Magnet [Sparkfun.com Part #: COM-08914] ($1.00)
10. (1) Reed switch [Sparkfun.com Part #: COM-10601] ($2.00)
11. (1) Dome Button [Sparkfun.com Part #: COM-09181] ($10.00)
12. (1) 6V Power Supply [http://www.radioshack.com/product/index.jsp?productId=2049709] ($1.50)
13. (1) Hitec HS-311 Servo [http://www.amazon.com/Hitec-RCD-Inc-31311-Standard/dp/B0006O3WVE] ($10.00)
14. (1) Parallax RFID Reader + Sampler Kit
15. Door mounting hardware (foam, double sided tape, zip ties) [Home Depot] ($5.00)
Total Cost: ~$100
As far as assembly of the board goes, it’s pretty straight forward. Solder in the 20 pin socket (make sure to line up the notch), snap the screw terminals together and solder them in place, solder in the 2 capacitors, the voltage regulator, and then break apart the header strip to populate the programming header and servo header. Pop your ATtiny2313 microcontroller into the socket (making sure to match up the notch) and you’re ready to program.
At this point you’ll need something that is capable of writing code to an AVR microcontroller. If you have an Arduino, it’s possible to use that. For this build I ended up using a USBtinyISP Kit. You can pick one up from that link for $22 and it’ll give you a simple interface between USB and the ISP programming header (which will also come in handy for the second half of the episode). In the video I demonstrate how to write the code to the RFID board. The 3 software packages I mention correspond to which operating system you’re using:
You can download the source code for either a Parallax reader or HID reader from here:
As an additional step that wasn’t included in the video, you’ll need to get the code off your HID tag if you’re using an HID reader. I’ve put together an extremely simply Arduino sketch included in the HID source code zip file above that will allow you to get your tag code. All of the explanation should be included in the comments at the top of the file. If you’ve still got questions after checking out the sketch, feel free to post them in the comments.
Now that your board is assembled and the code is loaded up, all you have to do is screw in your connections and mount the reader to your door. Once again I’m going to prod you to watch the video because there’s a pretty good explanation of how all the components wire together (with the Parallax reader). I also talk about how the HID MiniProx reader gets connected. In summary, there are 4 wires you’ll need to connect. You can wire the Vcc and Gnd directly to the 6v adapter input and then just connect your Data 0 and Data 1 wires to the corresponding IN0 and IN1 connections on the PCB.
As far as mounting goes, each door is different. For the most part I’ve been able to get away with using zip ties to hold the servo onto the actual deadbolt handle and then use lightweight foam and double sided tape to hold the servo in place. Stick your magnet onto the door frame and mount your reed switch on the edge of the door so it detects the door opening/closing. Everything else can be mounted using double sided tape.
There you have it! Your very own RFID door lock that requires no modifications to the door. I know there was a lot covered in this post, so I will continue to update it with information I feel is useful. Although we love using RFID for a lot of our projects, make sure to check out our post on spoofing RFID tags to understand how they can be exploited. Hit up the comments below if you’ve got any questions and I’ll do my best to answer them and get your RFID door lock up and running!