Lockitron Hardware Hookup Guide a learn.sparkfun.com tutorial
Available online at: http://sfe.io/t393
Lock It up
The Lockitron Mechanical Assembly from SparkFun is a perfect solution for the DIY home automation or Internet of Things (IoT) enthusiast, whether you want to make your life easier by not awkwardly fumbling with keys or add some extra security in your home with three-factor authentication.
Lockitron, the company, offers a complete solution that includes the mechanical assembly, embedded electronics that can connect to the Internet via Wifi or your phone over Bluetooth, and apps to control your deadbolt. That is definitely the easy, done solution to your automated locking needs.
But, you’re not here for easy, are you? What we have is the mechanical assembly, including motor and battery pack, to help you complete the automated security in your evil lair. An off-the-shelf solution just won’t cut it.
Covered in This Tutorial
In this guide, we will go over the guts of the Lockitron assembly and show you how to connect it to an Arduino Pro Mini. The Pro Mini, by itself, has no wireless capabilities. How you ultimately control your Lockitron will be up to you, whether it’s a tap sensor or through a WiFi connection.
Materials Used
In addition to the Lockitron Mechanical Assembly, you will need a few additional components:
Recommended Reading
Before getting started with the Lockitron, there are a few concepts that you should be familiar with. Consider reading some of these tutorials before continuing:
- Installing Arduino IDE
- Using the Arduino Pro Mini 3.3V
- Motors and Selecting the Right One
- Pulse-width Modulation
Lockitron Overview
Before we connect the Lockitron to anything, we should take a look at its internals to get an idea of what it does. Remove the black, plastic cover, and take a look at the inside.
- Motor Housing - This section contains the motor and gears necessary for rotating the outer ring.
- Motor Wires - The + and - wires for controlling the motor.
- Outer Ring - This ring has teeth around the edges so it can be turned via the motor. It also contains a number of “bumps” that the 2 bottom limit switches can use to determine its position. Additionally, it holds the inner ring in place and allows it to freely spin 90º.
- Inner Ring - The inner ring can freely spin 90º within the outer ring. If the outer ring spins past this 90º stop, the inner ring will begin to spin with the outer ring (in either direction). This free spinning motion allows a user to manually lock and unlock the deadbolt.
- Rubber Insert - This piece fits over the deadbolt’s thumbturn. It can be removed so that you can install the Lockitron on your door first before fitting the rubber insert onto the thumbturn.
- Battery Holder - A place to put 4x AA batteries and power the rest of the Lockitron (and possibly your electronics).
- Battery Wires - These wires (red for + and black for -) connect to the 4x AA batteries.
- It seemed to work best between 3 V and 9 V. It worked OK at 12 V, but judging by the fact that the Lockitron requires 4x AA batteries, 6 V is likely the optimal voltage.
- Just operating the rings (no deadbolt), the motor drew about 500 mA.
- The motor happily drew 3+ amps when stalled. Make sure your batteries or power supply can handle that if you accidentally get the rings stuck. The TB6612FNG motor driver can handle 1.2 A continuous and 3.2 A peak, so try not to let the motor stall for too long!
If you plan to wire up the limit switches (a good idea), now is a good time to remove the battery holder. Unscrew the two black Phillips screws from the bottom of the battery holder (underneath where the batteries would go), and carefully remove the holder.
- Limit Switches - There are 4 limit switches that are pressed whenever one of the “bumps” on the rings moves by. The top 2 switches coincide with the “bumps” on the inner ring (orange), and the bottom 2 switches look for “bumps” on the outer ring (black).
- Button hole - On the original Lockitron, a button stuck out of this hole that allowed you to configure the Lockitron’s wireless properties. Since we don’t have the original electronics, we are going to use the hole to route wires out of the Lockitron housing.
We are going to assign arbitrary names to the limit switches so that we know what to call them in our code. We also recommend labeling the wires (e.g. with a piece of tape and a pen) that are connected to the limit switches. When we put the battery housing back in the Lockitron, it will be very difficult to see which wire connects to which switch.
- 1A - First to be hit when the inner ring (orange) spins counterclockwise.
- 1B - First to be hit when the inner ring (orange) spins clockwise.
- 2A - First to be hit when the outer ring (black) spins counterclockwise.
- 2B - First to be hit when the outer ring (black) spins clockwise.
Hardware Hookup
Hook up Wires
We first want to connect a set of wires to the limit switches, motor, and battery compartment. In the end, we should have something like the picture below. The following steps will show you how to get there.
Connect Wires to the Switches
Unscrew the battery holder, and set it aside (if you have not done so already). Examine the limit switches.
- COM - Common terminal
- NO - Normally open. The COM and NO terminals are connected when the switch is engaged.
- NC - Normally closed. The COM and NC terminals are connected when the switch is not engaged.
Cut, strip, and tin 8x 6-8 inch wires (I used 4 green and 4 yellow wires). Solder them to the outermost terminals on the limit switches. We will be using the COM and NC terminals.
We recommend you label the wires so you know to which switch it is connected. In this instance, I tagged all the yellow (COM) wires with their respective switch (1A, 1B, 2A, 2B). I plan to connect the green wires (NC) all to ground and the yellow wires (COM) to individual Arduino pins.
Extend the Motor Wires
Cut, strip, and tin another 2x 6-8 inch wires for the motor. Use your favorite wire splicing technique (here are some good ones: 1, 2, 3) to connect to the motor wires. I used red and black to keep with the + and - theme.
Extend the Battery Wires
Once again, cut, strip, and tin another set of wires for the batteries. You will need 2x 6-8 inch wires. Use your favorite splicing technique to connect to the battery wires. I used red and black wires to connect to + and -, respectively.
Route Wires out of the Housing
Carefully pull all the wires through the button opening in the housing.
Solder Headers
Solder headers onto the Pro Mini and Motor Driver board. Don’t forget to add headers to the programming port of the Pro Mini (the part where you attach the FTDI breakout).
Attach Everything to a Breadboard
Attach the Pro Mini, Motor Driver board, and 2 buttons to the breadboard. Connect the wires from the Lockitron to the breadboard and add additional wires as shown.
Replace Battery Holder
Screw the battery holder back in place, making sure that the limit switch wires do not get caught underneath. Do not add batteries at this time.
Example Code
With all of the wires connected, we can upload some code to the Pro Mini.
- You generally don't want to control your door lock with just 2 buttons. You will probably want to add Bluetooth, RFID, fingerprint scanning, etc.
- Also, the code runs a "reset" loop when if first boots up. This just moves the two rings into a known setting that should fit on most locks. You will want to modify this part of the code for your own door (or, at the very least, let it run before installing the Lockitron) so you don't draw too much continuous current through the motor driver board if it gets stuck trying to move the deadbolt.
Example Sketch
Plug in the FTDI breakout to your Pro Mini, and connect a USB cable from it to your computer. Run the code from the Codebender window below, or copy and paste it into your Arduino IDE.
Run
Once the program has successfully uploaded to your Pro Mini, disconnect the FTDI breakout from the Pro Mini. Add 4x AA batteries to the battery holder, and the motor should rotate to a “home” position.
Try pushing the two buttons to mimic the “lock” (top button) and “unlock” (bottom button) functions.
Installation
The fine folks at Lockitron made a fantastic video showing how to install the Lockitron device. We skipped past the first 1:14 of the video, which shows how to connect the Electric Imp in the housing to WiFi (we don’t need that; we made our own electronics!).
If you want to mount the breadboard next to the Lockitron, you can use the sticky tape on the back of the breadboard or add your own tape/glue.
We’re using an RFduino in this picture, but the idea is the same.
Once you have everything working, you can always enclose the electronics for added security.
Resources and Going Further
The Lockitron is a great way to add some advanced technology to your door and venture into the world of home automation. This guide, hopefully, helped show you how to use the Lockitron Mechanical Assembly. From here, the possibilities are endless on how you want to control your door:
- Secret knock code
- Bluetooth app on your smartphone
- Connected to a webpage
- RFID
- Fingerprint scanner
- Iris scanner
- Voice commands
Resources
Other Tutorials
Need inspiration on how to interact with the Lockitron? Check out these tutorials:
SparkFun RFID Starter Kit Hookup Guide
BC118 BLE Mate 2 Hookup Guide
ESP8266 Thing Hookup Guide
learn.sparkfun.com |CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado