Create keyless entry to any door in your house?
Use your existing deadbolt and the Deadbolt Hack Kit combining a high - quality servo, a low - profile pushbutton switch, RGB LED for status indication, a serial RFID reader kit that includes a sample of four unique tags, some resistors and transistors, a prototyping board to assemble the circuit and a Pro Mini microcontroller to tell everything what to do.
There is also a 6VDC slim power adapter to power the circuit and Jameco's moldable plastic, ProtoDough, to make the custom bracket that will connect to your deadbolt pin to the servo.The deadbolt is not included and you should make sure you will be able to modify the deadbolt setup to work with the servo.
Step 1: Required Tools and Parts
Required Tools and Parts:
- USB/FTDI adapter to program the Pro Mini
- Soldering iron & solder
- Wire cutters
- +136°F water to melt the ProtoDough and all ow molding
- Ceramic or metal bowl to mix ProtoDough
- 1/2" OD tubing or similar to make a cylinder of ProtoDough to mold to the lock pin (depends on your lock)
- Hook - up wire to reach from the power adapter to the project box
- Drill and drill bits ( 1/4" and 5/8 " bit or a little bigger and 2" hole saw )
- 1 1.6" x 2.7" prototying board Illuminated pushbutton switch with red & green LED (discontinued)
- 1 Carbon black anti-vandal metal pushbutton switch
- 1 Clear RGB LED - Common Anode 2 Transistor, 2N2222A, TO-18 10 1/4 watt resistor, 10k Ω 10 1/4 watt resistor, 1k Ω
- 1 Single row 20-position male pin header (break apart what you need)
- 1 Heavy-duty servo, HS-322HD 1 ABS plastic project box, 6" x 3.5" x 1.87"
- 1 ProtoDough, 250g bag of moldable plastic 1 DFRobot Pro Mini microcontroller, 5V
- 1 Circuit board mounting hardware kit 1 Serial RFID reader kit with 4 sample tags
- 1 6VDC 500mA wall adapter with 2.1mm plug
Step 2: Product Review
Read the instructions completely before starting. You should have an idea of the task at hand and how you may need to make tweaks to the steps in the guide to accommodate your lock setup. Notice the knob comes off after removing the two screws, but the deadbolt lock is still securely fastened to the door.
This is an ideal setup because the plate can be removed and reinstalled to hold the project box firmly to the door with no additional hardware. The RFID reader module can be press - fit in the bottom of the project box and should be biased to one side (top).
The bottom half of the project box will be reserved for the deadbolt and servo assembly. A piece of 1/2 " OD plastic tubing that fit around the lock - pin was used to mold the custom bracket. Make sure you have all the components and review the schema tic further down the document.
Step 3: Assemble the Circuit
Circuit Tips :
The pushbutton switch can be mounted anywhere on the case as long as it doesn't interfere with the servo's movement. You can use wire leads from the protoboard to the terminals of the switch.
The RGB LED is used as a lock status indicator and is not required for proper function. The longest lead is the common anode (positive wire) for the LED and each one of the other leads is the ground point for a single color. Apply 5V to the power pin. A light pipe would be the nicest way to present the color, but a hole in the lid somewhere to allow the light to come out will work just as well. Use a 100 ohm resistor for the red LED. The green LED can do without a resistor.
Test the RFID reader by itself to verify the tags can be read through the door. The door in the example is a hollow core aluminum door. T he reader can read tags from both sides, so try not to pack the area behind the RFID reader with too many electronics that may cause unwanted performance. Use the GetTags sketch to get the unique IDs of the tags you want to use. Write them down because y ou will need to enter them into the final code later.
Consider biasing the circle part that you will cut out for the deadbolt to one of the lower corners of the case to create a larger area for the electronics rather than if it were in the middle. Leave room for the deadbolt retaining plate if yours uses one. Try to keep the top half clear for the RFID reader.
Orient the headers so when installed and the servo and RFID card reader are connected, their connectors or wires don't interfere with the servo or the mechanics of the lock and unlock cycle. You will need the full depth of the case.
The FTDI header is for the USB/Serial programmer to upload the code. It is a 6 - pin device. Pin - 5 GND is unused in this application. Pin - 1 (DTR) should be connected to the RESET pin on the ProMini through a 0.1μF capacitor
Step 4: Mold the Protodough
Don't worry if you can't get all of the shaping done in one pass. You can reheat more water to make it pliable again until you get the desired shape. You can speed up the hardening process by putting it in the refrigerator. When forming the material inside the tube for the lock pin of the deadbolt (shown in the next step), you will need the ProtoDough in the tube to be moldable.
While the ProtoDough is in the shaping state, push it onto the lock pin and slightly into the lock unit. Try to keep the base as parallel to the door to allow the smoothest operation for the servo. The center of the servo horn will need to be on center with the deadbolt pin or it won' t work correctly. The bracket can be removed once it has fully cooled , but it is a good idea to mark dead center if you can. Use your key from the other side of the door to toggle the lock so you can locate center. Use a Sharpe to make a dot or use a little dot sticker to locate center.
When the dot doesn't change position while turning the lock, you've found center. You can use some of the screws included with the servo to mount it to a servo horn. Use clippers to cut any excess screw so it doesn’t interfere with the lock mechanism.
Step 5: Prepare the Enclosure
- A 2" hole saw was used to bore a hole for the deadbolt mechanism to fit through .
- The 2" hole was biased more to one side but left enough space from the edge for the retaining plate of the lock.
- A 1/2" or 5/8" drill bit was used in the enclosure face for the button switch. It is 0.62" diameter, so you may need to use a file or Dremel to open up the hole. Before drilling the hole, consider where you've mounted the switch on the protoboard, the direction of the servo and RFID reader headers point , the location of the servo and lock, and the location of the RFID reader.
- Use a 1/4" drill bit to make a hole for the power supply wires. Hole placement will depend on your installation and preference.
Step 6: Connect the Board
- Feed the power supply lines through a hole in the enclosure before you solder them to the board. The 6V supply is for the servo and 'RAW' pin of the Pro Mini.
- 5V for the switch, LEDs and RFID reader are sourced from 'VCC' pin on the Pro Mini.
- Use hook - up wire from the I/O pins on the Pro Mini to various points of the protoboard to connect the two LED colors via the transistors, the switch, the servo header, the RFID reader header, and the FTDI USB/Serial programming header.
Step 7: Attach the Servo
- Connect the servo to a header on the board that provides 6V, ground, and a signal to D9
- Set the servo to 135 (lock) before attaching it to the lock pin. You can use the Motor Setup sketch to set the servo to 135. A delay of a few seconds has been added so you can pull the plug at the value yo u want. Use the serial monitor to confirm the value when you stop the servo. You may need to use different values depending on the rotation required to toggle your deadbolt. "90" should be the center position on the servo.
- Make sure your deadbolt is in t he lock position because when you upload the code provided, it will start from the lock position.
Tip: If your deadbolt only requires 90 degrees of movement, divide the degrees of travel by two and add/subtract that number from the center position (90) to get your suggested locked and unlocked positions. Working from the middle will ensure you have enough rotation to complete the lock or unlock movement .
Step 8: Attach the RFID
- Use a detachable cable between the RFID reader module and the connection header on the
protoboard. When uploading code, the reader module must be disconnected from the Pro Mini or the upload will fail. At a minimum, the DOUT to D0 /RX ("RXI") must be detached before uploading code.
- You may wire directly from the RFID module to the Pro Mini, but use a jumper block/header or some method to break the connection on the DOUT/RXI signal so you can successfully upload code.
- The RFID module nearly holds itself in place when pressed into the enclosure. Some electrical tape should also keep it in place.
- The module needs 5V, ground, a signal wire to D0/RX and another signal wire to D2 on the Pro Mini
Step 9: Final Assembly
- Secure the enclosure to the door. This will depend on your deadbolt configuration, but in the example, the deadbolt has a retaining plate to hold it in place. Remove the retaining plate and place the enclosure on the door with the 2" hole over the deadbolt and reattach the retaining plate so it holds the enclosure securely to the door.
- Install the RFID reader. Press fit the reader into the top part of the enclosure. It should sit flush and be nearly held in place with the friction between the reader and the walls of the enclosure.
- Install the servo onto the lock pin with the adapter made with the ProtoDough. You can use additional ProtoDough to secure the servo in place. Be sure you are satisfied with the lock operation before making a more permanent servo mount
- Mount the circuit board to the enclosure using the included hardware or leave it hanging if it doesn't interfere with anything . The protoboard has a notch on each side for mounting hardware. Screw a standoff and hex stud together with the protoboard between them. Drill holes through the enclosure face to reach the hex stud s and attach the circuit .
- Attach the servo and RFID headers to the circuit board. Any time you upload code to the ProMini, you will need to disconnect the RFID or the D0/RX line.
- The servo and deadbolt should both be in the locked position. You can set the servo to the lock position with the Mot orSetup sketch. If you need to get your tag IDs, run the GetTags sketch and open the serial monitor. Open the RFID_Deadbolt sketch and change the permitted RFID tags to your numbers. Upload the code to the Pr oMini. Reattach the RFID header or disconnec ted D0/RX line . Test the operation with the pushbutton and with your tags. The RFID reader has a red/green status LED that changes color when a tag is being read. You can test that the lock does not function when an unapproved card is scanned. Once you are satisfied with the placement and operation, you can close the lid with the included screws.
Step 10: Upload Sketch
You will need to make sure the RFID Reader is not connected to the circuit board, or at a minimum, the wire connection to D0 needs to be open. This must be done to ensure the code is successfully uploaded. Use the MotorSetup sketch to set your servo motor to the center position or whatever position you need. Use GetTags to find out the unique ID for your specific RFID tags. Record the value for use in the final sketch. RFID_Deadbolt _rev2 is the complete program. You will need to change the variables in the final sketch to match your RFID tags, motor lock and unlock positions (shown below, the highlighted part is where you change to your tag ID and motor positions) .
Make sure your deadbolt is in the lock position when you upload the final code. It is best to upload the code and test the function before final attachment to the deadbolt. All sketches can be found in the "Additional Files" ZIP archive on the kit product page.
20 int lock = 135 ; //servo position for locked (value from 0 to 180)
21 int unlock = 45 ; //servo position for unlocked (value from 0 to 180)
22 int pos = 135 ; //starting position, locked
23 boolean locked = false ;
25 int val = 0;
26 char code;
27 int bytesread = 0;
28 char tag1 = " 84003408F0 " ; // RFID Tag 1 (change to your tag number)
29 char tag2 = " 70006F6E79 " ; // RFID Tag 2 (change to your tag number)
30 char tag3 = " 360065DE91 " ; // RFID Tag 3 (keyfob)