Endeavors of hacks, howtos, and destruction

RFID Door Lock

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.

RFID Lock PCB

Prototype RFID Lock

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:

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.

Assembled Circuit Board

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:

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.

Fully Wired Board

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.

Servo Lock Mounting

Foam used for mounting the Servo

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!

Advertisements

Share this:

Like this:

Related

47 Comments on “RFID Door Lock”

Hey, I also have put one of these on my dorm room door running with an arduino when I was a freshman. Can you post or email the schematic for your board design? Instead of having a custom one made…I’ll just DIY my own board.

That’s awesome you’re going to DIY the board 🙂 If you download the schematic and board design I posted above you can load it up in the free version of Eagle. It should give you a pretty good idea of what you’ll have to put together. Just let me know if you have any questions!

Hey I just finished my door setup..turned out my apartment door is metal so I couldn’t have a completely indoors contained system. I am using a 11.1v li-poly battery with a 5 volt regulator to run my system…the last question I have is how do I make it so that the reader can verify and open the door with more than one rfid code. I have a tag for my roommmate and myself, but how do I enable both tag’s code’s to be allowed to open the door in the code? In the quotations do I just separate the two 10 digit codes by a comma?

[…] of the first things that [Eric] hacked together when he got to college was an RFID door locking system. He found that he was often in a rush to get in and out of his dorm room, and that using a simple […]

I actually figured out my issue. I only have 10K and 330ohm resistors on hand, so I had to do what I could with what I had..

I wound up putting two 330s in parallel and that brought me to exactly the 30ma maximum current for the reader. It powered up perfectly, read the code, and now I just need to get the hardware to burn one of those chips.

Unfortunately I got one of the Arduino Unos that have the new mini chip (basically meaning I can’t remove or replace the processor). Any suggestions on what’s the best method on burning the code onto one of the ATtiny85 chips?

Even though the page states that it doesn’t work with the Uno, apparently people are reporting that it does indeed work. If you can’t get it to work though, I’d highly recommend the USBtinyISP from adafruit: https://www.adafruit.com/products/46 It’s a simple kit that will get you up and burning code in no time. You just need to build a programming cradle so you have a 6 pin ISP header connected to an 8 pin socket.

Huh…that’s really strange. The code should’ve automatically taken care of the parity bits properly. Are all the other bits exactly the same? It’s up to the device taking input from the reader to check parity, so it may or may not work. Check out this document for a bit more info on the card format:

I got in touch with the creators of the code and it appears there is in fact a bug with the way the parities are being calculated/outputted.

Looking at the code, only ONE parity (“odd parity”) is being created. Since there are only 2 parity bits, and each can only be a 1 or 0, there’s a 25% chance it’ll be right on your cloned tag, depending on your site ID and unique ID 😉

I got a version 1.2 of the code, but still doesn’t totally look right to me. The parities are being calculated by doing a parity calculation on the Site ID and Unique ID (which is incorrect). It might be a bit tricky, but I may have to create a code fix and submit it- Taking SiteID + first 4 bits of the unique ID (for parity 1) and last 12 bits of unique ID (for parity 2)..

Do you just need the assembled board and RFID tag or do you also need a way to mount it? I wouldn’t mind putting together some of the boards for everyone who wants one…it’s just tricky for mounting hardware because all door locks are different.

I’ve been wanting to implement that on the next revision…unfortunately it’s not quite as simple as just swapping in the lock. For controlling a servo a very low current PWM signal is being generated by the microcontroller and the power is being pulled straight from the 6V adapter. You’ll most likely need to incorporate a MOSFET into the design that can switch the amount of current that the strike plate pulls. The easiest way to do this is with a logic level FET that will accept 5V as an input and tie it into one of the microcontroller pins (the same one that generates the PWM signal for the servo could be used).

[…] hard, but with a handful of groceries it’s a difficult task. You can piece together your own RFID lock that unlocks with a wireless key and locks itself automatically. It’s not the most exciting […]

[…] hard, but with a handful of groceries it’s a difficult task. You can piece together your own RFID lock that unlocks with a wireless key and locks itself automatically. It’s not the most exciting […]

Great guide here and I would love to implement this in my apartment, but there is one concern that I have. Would this system still allow for the physical key to be used to open the door? I would imagine that the answer would be yes as a blackout would basically lock you out of your house if this did not allow for it. But, I also need to make sure the maintenance people can get in if needed without having to dismantle the entire thing.

1) If it does work, it’ll just BARELY work. Worth a shot either way though!

2) You should be able to tune your servo values so it only turns the exact amount you want it to. Just start off with some conservative values and keep bumping them up until it successfully unlocks the deadbolt.

Thanks for replying!!!! I ran into another problem today…I have no idea how to get the power cord to power the actual servo. Am I suppose to cut off the end of the power cord and somehow attach it to the servo itself?

Servos typically run at 6V. You should be able to use any sort of 6V power supply. You can cut the red/black wires and connect these to 6V. Then just tie the ground of the Arduino to the ground of your 6V supply.

Great tutorial! I’m looking to order a board but it’s been a while since you posted this tutorial and BatchPCB has been taken over by these guys. http://oshpark.com
I tried to upload the file as you had it but it didn’t meet their guidelines.
Do you have any suggestions as to how to upload to get the correct board?

Hey Eric, Im actually working on something similar to this but I’m making it so that you can lock and unlock the door from a website. i’m having problems coming up with the actual hardware for the locking mechanism. Do you have any suggestions? Thanks!

[…] of the first things that [Eric] hacked together when he got to college was an RFID door locking system. He found that he was often in a rush to get in and out of his dorm room, and that using a simple […]