Introduction: RFID DOOR LOCK - ARDUINO
This is a fun an very useful project that allows easy access into any door with a deadbolt. I have another version that is used on my garage door and uses the same basic circuit and fobs. The system operates in the RF region at 125 KHz. Fobs are used to actuate one of two relays on the main control board. With each scan the deadbolt toggles - if it is unlocked it locks and the red LED comes on, if locked it unlocks and the green LED comes on. One relay causes the deadbolt motor / mechanism to lock the door, the other causes the door to unlock. A regular key can still be used and the deadbolt can still be locked and unlocked manually if desired. Operating the circuit with the key or manually operating it with the deadbolt knob can cause it to fall out of sync with the controller and indicate locked when it is actually unlocked or vice versa. To correct this just cycle the unit with the pushbutton on the deadbolt housing or flip the deadbolt knob the opposite way. I have thought about adding some limit switches to eliminate this problem. Perhaps in some future version I will implement them. I have been using this project for a couple of months with very few hiccups. It is fun to build and adds a definite 'nerdivity' to my home.
I based the project on a store-bought electronic deadbolt. It was battery operated and had a keypad on the outside to allow entry with a user defined code. I removed all of the electronics from the indoor housing keeping only the electric motor and mechanism. The mechanism has a built-in clutch that prevents damage should the motor remain on for too long when cycling. My motor is set for a cycle time of about 1.25 seconds.
This project is based on the Kwikset Powerbolt Model # 907 15 SMT CP. It cost $69.97 at Home Depot. Almost any battery operated deadbolt will work. It needs some type of clutch mechanism to protect from over-cycling. This was the cheapest unit that Home Depot sold. You may get lucky and find an open box item or a defective unit that can be salvaged. It looks neater than trying to build the motor drive myself.
In future versions I will try to place all components inside the plastic housing where the OEM circuit board was located. There are many similar projects you can research on the Internet. Do a search for 'RFID ARDUINO DEADBOLT'. There a few on Instructables as well. A Universal RFID Key by drj113 available in Instructables is a good read on RFID theory. Going over this material will be time well spent.
Step 1: Operation
Here is an example of the device in operation. It is a bit noisy as the gears grind inside. It is virtually impossible to lock yourself out of the house using one of these. I had done this one too many times with my door key, so I disabled the locking mechanism of every door knob lock in my home. I only use deadbolts for locking doors now and am happy to report I have never locked myself out since.
Attachments
Step 2: The FOBS
Here is a picture of the FOBs used in this project. They are fully encased and are almost indestructible. A look inside shows a coil and microchip. There are two form factors that can operate the device, a FOB or a card. I keep the card version in my wallet and a FOB on my key chain. I just take my wallet an wave it over the reader and it unlocks. I use the same card / FOB to access my garage and my house. There will be more about this in the Arduino sketch section later. Power and data are delivered and retrieved via the antenna coil. There are no batteries inside to ever fail. This version contains an identification number and is read only. Other types are available that can have information stored on them. That would require a different reader than the one used here. I have yet to experiment with the read / write type. This technology is finding it's way into our everyday lives at breakneck speed.
Step 3: Prototyping and Breadboarding
This is the experimental version of this project. The microcontroller is an ATMEGA 328 loaded with a program called a bootloader. It is the bootloader that makes it an Arduino. It took some time to work out the kinks, but I enjoyed learning along the way. This version has an LCD display that when scanned shows the name associated with the FOB. It also shows fault messages like 'FOB Not Recognized' and 'Welcome Home Bill'. I thought adding a ladies voice to it might be cool. I will wait to add that to a doorbell project that I am pondering.
Step 4: Sub Assemblies
A quick shot of the subassemblies needed to build the project. Don't let the complexity scare you away. Build and test each piece one at a time. You may want to stop along the way and experiment. If you are new to Arduino there vast amounts of tutorials available online. The best one is the official Arduino website at http://www.arduino.cc/. Breadboarding the unit first can be helpful in working out the bugs.
Step 5: Circuit Boards and Major Components
I built two boards for this project. One has the Arduino microcontroller on with all input / output connectors attached. The Adruino is in a socket mounted on a breakout style board called RBBB from ModernDevice.com. It allows the resonator, voltage regulator, reset switch, power jack and power conditioning in one convenient place. Power for the entire project is fed into this board from a wall-wart (9VDC @ 1A) AC adapter. Power before the 7805 regulator is taken to run the motor. Power after the 7805 regulator and filtering is used to power everything else. Note the blue shrink wrap on the 7805. This was removed after testing and a small heat sink added in it's place. I have about 20 of these RBBB boards in my lab and this one was changed out sometime during construction.
The RFID reader itself is located on the small green circuit board on the lower left end of the controller board. It comes with a rectangular coil of wire which is the antenna. I housed it inside a plastic project box. You can read details about it's construction below. Be sure the use the UART type and not the WEIGAND. Only the UART will work with the code I have written for this project.
I like to use pre-made jumpers in my projects. They are very cheap and allow quick connect / disconnect during construction and debugging. The Arduino RBBB board above uses these and it makes for efficient work.
Step 6: Parts Layout - Control Board
The main board is located inside a beige box labeled CPU / INTERFACE MODULE. I could not think of a better name so I'll stick with this for now. Anybody have any ideas? When I refer to the main board I am speaking of the large perf board. There is also an Arduino board that I have been calling RBBB. This is what the manufacturer calls it. Both boards are located in the hinged box hanging to the left of the deadbolt enclosure.
Step 7: Schematics
The red circled numbers denote Arduino pin numbers. If you like, you can build the entire project on one piece of perfboard or create a PC board layout. When communicating with the Arduino chip you must unplug the connector labeled RX. You will get a fault from the Arduino software if you leave this wire connected while attempting to communicate. This pin is one of two that are used to send serial data to and from the RFID reader board to the Arduino. In normal operation this pin must be connected. I have placed a male pin on the circuit board with a female connector going to the RX pin on the Arduino circuit board. This pin is labled TX on the green RFID board and is connected to RX on the Arduino board. Simply unplug it, upload your sketch, plug it back in and all should be well.
The motor is wired using two single pole double throw relays. In the normally closed position both relays connect both motor terminals to - causing no movement. If relay A is energized and relay B is not then motor pin A will be connected to + and pin B will be connected to - causing the motor to spin. If this condition is reversed and relay A is not energized and relay B is energized then motor pin A is connected to - and motor pin B is connected to + causing the motor to spin in the opposite direction. In the unlikely event that both relays are energized then both motor pins will be connected to + causing no movement of the motor. When you are done assembling the project and you find the motor works backwards from your expectations, just reverse the polarity to the motor. If you have a connector like I had on mine just unplug it and plug it back in the other way around.
I received some great advice from fellow builder steveastrouk concerning motor noise. He recommends adding a bridge rectifier and 100 nF cap to guard against excess motor noise. I believe mine came from the factory with a cap across the motor leads but when I desoldered everything to add the wire cables, I forgot to replace it. Soon I will add a modified schematic to reflect the changes he recommends. The schematic shows a 100nF cap across the motor leads, but the cap is located on the main control board. It should be directly accross the motor leads.
Step 8: Control Board Assembly
Notice the red and black dots on back of the board. They indicate positive and negative power supply rails. It is very easy to get them mixed up during assembly. The relays, RFID receiver board, LEDs and miscellaneous connectors are all mounted on this board. You can use whatever construction method your imagination can come up with. Creating a universal PC board with all major parts on it might be an efficient approach if you are planning to build more than one. Wiring is not critical since only control signals are being used. The antenna coil is the only exception as it sends both power and data to and from the RFID board. My antenna coil is mounted about 14 inches away from the RFID board and has proven to be quite reliable.
Step 9: More Power to You
During tryout I found the motor would strain to cycle and the Arduino would sometimes restart. The problem was the power supply rail being pulled well below 5 volts. The fix was adding a 6800uF 25V electrolytic capacitor to stabilize the power rail thus allowing the motor the extra power needed to cycle the deadbolt.
Electric motors draw maximum current during startup, then draw less as they come up to running speed due to back EMF. Back EMF (Electromotive Force) is created because a motor acts like a generator when it is running. The generated current flows opposite to the current powering the motor. When the motor first starts there is very low rpm and very low back EMF. This is what causes the motor to draw maximum current during startup. As motor speed increases so does back EMF and the current needed to run the motor goes down.
Step 10: Main Control Enclosure (AKA CPU / INTERFACE MODULE)
Here are some pictures of the main enclosure. I added hinges to the left side and salvaged a knob and screw from an old lamp to keep it closed. The wiring could have been a little neater. There is no convenient way to resize the jumper extensions.
Step 11: Indoor Deadboalt Case
In the first picture at the top of this instructable there is a red push button where a hole is present in the unaltered deadbolt cover. Drill this out and install a normally open push button switch there. Be sure to put long enough wires to reach the control board. Notice the missing capacitor across the motor leads in rightmost picture.
Step 12: Outside Antenna / LEDs
Here you can see how I built the receiver box. I used the top of an old project box. Packaging tape was used to stick the antenna coil to the inside but it kept peeling off. I added some foam I had laying around to back it up. Just before screwing the box to the door I slipped enough foam behind the antenna to firmly hold it in place. Clear label tape gives a professional appearance that looks neat and clean. One hole was drilled through the door coming out in an open area of the deadbolt knob mounting plate. The wires were fed through this hole and then through some split loom wire raceway. The split loom is the black corrugated plastic tubing joining the deadbolt box to the control box which I labeled the CPU / INTERFACE MODULE. It was the best name I could come up with, Warp Reactor coil just didn't sound right. Flux Capacitor might have worked!
In my version, the receiver is not exposed to the elements since it is located inside a garage. If your version is outdoors I recommend caulking around the box after working out all of the bugs. This will also help to keep the real bugs out! Some small critters would likely find this a great place to set up a home with the groovy lights and everything, like a miniature bug-disco!
Step 13: Arduino Sketch Details
- Download the Arduino programming software.
- This can be downloaded free from the Arduino website: http://arduino.cc/en/Main/Software
- Download and open the .txt file in word or some other generic program that can display text files.
- Copy and paste the text of this file into the Arduino programming software.
- Connect the Arduino board (RBBB) to your computer using USB to serial cable.
- Disconnect the RFID reader board at the TX terminal or a fault will be generated and the upload will fail! (I forget to do this every time!)
- Upload the sketch into the Arduino chip.
- Under the tools menu, open the Serial Monitor and check that the .com port being monitored is the same one you just used to upload the Arduino sketch.
- Wave a compatible FOB or card over the antenna coil. You should see numbers displayed.
- These numbers should be unique for each FOB you wave over the antenna coil.
- Cut and paste these numbers into the top of the Arduino sketch.
- The numbers are located at the beginning of the sketch and are located under the heading 'SETUP VALID BADGES'.
Upload the sketch into the Arduino again.
- Plug the TX connector back in or there will be no communication between the RFID board and the Arduino and it will be unresponsive.
- Wave the card or FOB and the motor should cycle and LEDs change state indicating a successful scan. If the number in the FOB matches one in the table the deadbolt should cycle to the opposite state that is in. If the deadbolt is locked, it will unlock. If it is unlocked, it will lock.
- Edit the sketch as desired to help you keep track of your cards and or FOBs.
- I find it works best to wave the FOB about an inch away from the antenna coil and use a smooth even motion. Do not wave it back and fourth or the unit will click on and off over and over.
Step 14: Construction Tips and Final Thoughts
- Build the project on an experimenters socket first.
- Using the RBBB PC board for the Arduino makes is more convienent, but it is not necessary. If you prefer you can install the Arduino chip directly on to whatever type of board you are using. If you choose this method you will have to install the resonator or crystal, 7805 regulator and other components on the board as well.
- I use a 9 volt ac adapter to power the unit. If power fails, the key will always work.
- This could be operated from batteries but the current draw would cause them to need frequent replacement.
- Clear labels were printed with a Brother label printer. I used the computer software from the Brother website to create all of the labels.
- Be creative and play with the program. Let me know of any improvements you may suggest.
- If there is something I can help clarify let me know.
- I mentioned earlier I have a version of this for my garage door. It has been working for about two years now with very few problems. I plan on posting an instructable for that project in the near future.
- Some great ideas about dealing with potential electrical noise problems were posted by steveastrouk. Read through the comments below and the schematic section for more information.