Introduction: How to Build an RFID Deadbolt Controller
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)
This guide will walk you through how to build an electronic deadbolt lock actuator which can be controlled via an RFID card and reader, an IR remote and sensor, or a button mounted on the side of the enclosure.
Here is a list of parts which you will need:
- Arduino Uno
- USB to USB type B cable
- USB wall adapter
- MF522 RFID reader
- MiFare RFID card or tag
- TowerPro MG996R servo
- IR sensor and remote
- Threaded momentary pushbutton switch
- Red 3mm LED
- Green 3mm LED
- Resistors (2 x 220 Ohm and 1 x 10k Ohm)
- 6 Screws (I used 6-32 flatheads)
- Nuts and washers
- Wire headers
- Wire (ribbon cable from old IDE or floppy cables works well)
- Electrical tape
Here is a list of tools which you will need
- 3D printer (alternatively, you could modify an existing enclosure and create a deadbolt grip by hand)
- Soldering iron with solder
- Hot glue gun
- Super glue
- Drill and drill bits (unless you design the holes within your 3D model.
Step 1: Design a 3D Model
Here is a link to all of the 3D models which I used for printing my project: 3D Models
All of the 3D models were designed in Autodesk Inventor. The main components which the base of the enclosure is designed around are the servo and the Arduino Uno. I made a few small modifications to this design by hand after printing. Two of these modifications were slits that I cut for the servo and RFID reader ribbon cables to exit the case. The RFID reader needs to be mounted remotely because the door is too thick for the signal to get through. In my case, I mounted it on the door window. I also drilled the mounting holes for the servo by hand. To do this, I placed the servo in the hole in the base of the case and drilled through the 4 screw holes on the servo using a bit which was the same size as the holes.
You will likely need to modify the position and size of the hole in the lid in order for it to lineup with and fit over the round plate between the deadbolt latch and the door. You will also likely need to modify the deadbolt latch grip that mounts to the servo in order for it to fit your specific deadbolt. Finally, depending on the size of the pushbutton switch that you choose to use, you may need to adjust the size of the switch hole in the case.
Step 2: Programming the Device
Here is a link to the Arduino sketch and all of the libraries which I used that aren't already included with the Arduino IDE: Arduino Sketch
The main loop is contained within Final_Project_Sketch.ino. Only two changes to the code will be necessary. One of them, the RFID key, is security related. I've stored the RFID key simply as a 16 byte string on block 2 of the RFID card. You may want to change not only the string, which is stored in variable "blockcontent", but also the location of the key to one of the security blocks. In order to write the key to the card, uncomment the line which contains "writeBlock(block, blockcontent)". Comment this line after you have written the key to the card. Otherwise, it will attempt to re-write the key onto any card that is scanned.
The other necessary change will be the number within "if((readSwitch(debounceTime) == true) || (current_results == 4294967295))". This number is the decoded signal from the IR remote which I was using. It will vary depending on what IR remote you choose to use. In order to find out what the number is for a certain button on your remote, add the line "Serial.println(current_results)" just under the line which contains "current_results = results.value;".
Step 3: Wiring
I've attached images that show both the breadboard and schematic view for the necessary wiring. For the schematic view, here is a pinout for the RFID reader pins:
Each of the LEDs are wired in series with a 220 ohm current limiting resistor. A 10k ohm pull-up resistor is on the data line of the IR sensor because the sensor modulates the signal by pulling that pin low. The button doesn't need a pull-up resistor because the input pin has already been set high (5V) in the Arduino sketch.
For the actual wiring, I soldered to male pin headers which were plugged into the Arduino and the servo cable. The RFID reader ribbon cable is soldered to a female pin header at the RFID reader side.
Step 4: Final Assembly
Mounting the Servo
In order for the servo cap to be flush with the enclosure when it's placed over the servo, the servo mounting holes needed to be countersunk. For this, I used a drill with a countersinking bit and checked the depth a few times while I drilled with one of the 6-32 flat head screws that I planned to use. With the holes countersunk, I placed the servo through the hole in the enclosure and used the screws and nuts to mount it.
Mounting the Deadbolt Latch Grip
For the latch grip that connects to the servo, I just super glued one of the plastic levers that came with the servo to the back of the grip. This ensured that the grip would mount snugly to the servo shaft and wouldn't slip while turning. Finding the correct angle to place the grip onto the servo shaft will require some trial and error while it's actually rotating the deadbolt.
Mounting the Arduino
Next, I mounted the Arduino. For my build, I actually drilled holes in the case and used nuts and bolts to mount the Arduino. However, if you use the 3D model that I provided, then you should be able to screw the right size sheet metal screws into the existing mounting posts.
Mounting the Switch
Depending on the diameter of the switch that you're using, you can either thread the switch into the case itself, which is what I did, or use a nut on the outside of the case to hold the switch in place.
Mounting the LEDs and the IR Sensor
Both of the LEDs and the IR sensor are just held in place by small dabs of hot glue. Just place each of them in the correct holes and use a small amount of hot glue to hold them in place.
Mounting the Servo Cap
Line up the servo cap over the back of the servo, which should now be protruding out of the back of the enclosure. Place a small dab of hot glue on the case directly to the left and right sides of the servo and quickly press the servo cap against the case. Hot glue dries quickly, so you will need to act fast.
Screw in the Lid
Now screw the enclosure lid on. I also used 6-32 flat head screws, here.
Step 5: Mounting the Deadbolt Controller to the Door
With the deadbolt controller placed over the deadbolt and plugged in, you will need to actuate the servo with the controller in a few different positions to find out where the servo is lined up with the pivot point for the deadbolt. When you actuate the servo and it doesn't sound like it's being strained and the controller isn't moving, then it's lined up. I used velcro to mount the deadbolt controller to the door. That way, I can take it off or make slight position adjustments if necessary.
To mount the RFID reader, you can either use velcro or tape.
Congratulations! You now have an RFID, remote, and button controlled door lock!
We have a be nice policy.
Please be positive and constructive.