
Build Your Own Lockitron With Twilio, Arduino, and Node.js - ranman
https://www.twilio.com/blog/2014/03/build-your-own-lockitron-with-twilio-arduino-and-node-js.html
======
3327
Great to see things like this back on the front page. This is what HN is about
rather than tech stocks, IPO, Tesla public announcements and things that
belong on Reddit. Thanks a bunch, that being said I will working on this
tonight!

~~~
jonmarkgo
Glad you like it! Let me know how it turns out - my ideal would be to evolve
it to use a 3d-printed servo mount rather than cardboard and duct tape, but
it's a good start!

~~~
3327
Great start indeed. Simple and good execution !

------
klinquist
Rather than only allowing access from a given phone number, you may want to do
what I did in another project: allow access from anybody in a given google
contact group.

My project allows people in a given contact group to open my garage. A phone
number is posted outside my garage and a sign that says "Text OPEN GARAGE" to
this number."

Twilio contacts my nodejs script and if they are in the google contact group,
it sends a message to the SmartThings API to trigger my ZWave relay.

This isn't very well documented, but if anyone has any questions let me know:

[https://github.com/klinquist/GarageAccess/blob/master/garage...](https://github.com/klinquist/GarageAccess/blob/master/garageopener.js)

Note this was my first real node project. :)

~~~
jonmarkgo
I love that approach, I believe SmartThings uses Twilio as well.

Another potential approach is to do access control using Twilio (make an
interface to add/remove authorized numbers via SMS) and store that in a DB on
your server

~~~
klinquist
I actually did something similar to that for a bachelor party - there were 10
of us, combinations of iphones and androids. Rather than having everyone
exchange phone numbers for a group SMS, I asked everyone to text their name to
a twilio phone number. (XXX-XX-PARTY)

If the twilio number received a text from someone not in the db, it added it.
If it was in the database, it would prefix any message they sent with their
name: and send the text to everyone else in the db.

Worked out great. Cost me about $20 for the weekend though. :)

~~~
toomuchtodo
Github the code?

~~~
yefim
Just threw together something that works really quick for you:
[https://gist.github.com/yefim/9823281](https://gist.github.com/yefim/9823281)

~~~
toomuchtodo
Very awesome of you. Thanks!

------
oldmanpants
i've been reading Hacker News forever and just now created an account to share
my project similar to this...

I built mine a couple years ago. I 3d printed most of the parts on a Makerbot
Thing-o-matic. It uses 24 rare earth magnets built into the feet to attach to
the door over the deadbolt. There is a 3d printed sleeve that slides over the
deadbolt lever and turns with a servo.

A piezo sensor on the frame of the device detects knocks on the door. knock
the correct pattern (shave and a hair cut, two bits, for example), and the
servo turns the deadbolt.

It is easily modified with an ethernet sheild to be controlled with my phone
when within range of wifi outside the house...

I still plan to do a proper write-up and share the source code and stl files
for printing- i just havent gotten around to it yet. I've got a few other
unique projects I'd like to share as well, I just need some time to organize
some photos and info.

photo:
[http://now.oldman.ca/lib/img/bg/heimdall.jpg](http://now.oldman.ca/lib/img/bg/heimdall.jpg)
video (early test):
[http://www.youtube.com/watch?v=5zFRAlZB0Sw&list=UUl6Pnlqx1eh...](http://www.youtube.com/watch?v=5zFRAlZB0Sw&list=UUl6Pnlqx1ehH9iRW0I_NKog)

~~~
jonmarkgo
That's awesome - do you have the 3D printer models up on thingiverse?

~~~
oldmanpants
thanks! no, I don't have the models up on thingiverse, but I plan to put them
up there and to document the build. I'd like to start documenting more of my
builds as well. I'm going to work on promoting myself and my work better as
it's something I've not spent much effort on recently.

I enjoy reading stuff like the original post here and am always looking for
such content but so easily forget that I could be sharing my projects and
methods... perhaps time to stop lurking so much :)

------
mcpherrinm
If you have your own home, or perhaps a very forgiving landlord, an electric
door strike is much superior to a servo twisting a lock. eg, this one is $40
[http://amzn.com/B003TN1HAM](http://amzn.com/B003TN1HAM)

It won't interfere with the regular operation of the door, and can be operated
by a simple relay -- the more complex mechanical bits are handled for you.

You may also be able to use an electric deadbolt with keypad like
[http://www.amzn.com/B0045Y1LNM](http://www.amzn.com/B0045Y1LNM) with your
existing keys, or even the existing outer facade so it isn't obvious to a
passerby (say, your landord) that you've swapped it out.

~~~
damian2000
Yes, and the one configured as fail secure is probably the most popular. When
power fails, it automatically locks: applying the 12V power opens the strike.

The only downside is installation cost? isn't it a job for a locksmith to
install, especially when your existing strike faceplace is metal. Also, you'd
need some power hooked up to it, on the inside of your door frame.

I have this one, which I bought from a local electronics supplier - AU $29.95
-
[http://www.jaycar.com.au/productView.asp?ID=LA5077](http://www.jaycar.com.au/productView.asp?ID=LA5077)

~~~
pkaye
Probably a fire code violation if a power loss prevents you from opening the
door to escape.

~~~
damian2000
Assuming your door has a traditional door knob & lock fitted as well, an
electric strike doesn't prevent you opening the door when its in the locked
position. The way an electric strike unlocks a door is by swivelling a part of
the strike plate away. When its 'locked' its really just like a regular door
with a fixed strike plate, as per this diagram ...
[http://www.hometips.com/wp-
content/uploads/2012/06/doorknob_...](http://www.hometips.com/wp-
content/uploads/2012/06/doorknob_lock_parts_diagram.jpg)

------
jon-wood
I keep thinking about building something like this but the thing that ours me
off is the possible implications in the case of having to claim on insurance
if someone robbed my house.

I have very little doubt that the insurance company would take a dim view of
my front door lock being connected to the web, and leap on the chance to deny
any claims on the grounds that the intruder could have broken in via my code,
making it equivalent to leaving the door unlocked when going out.

~~~
teacup50
There doesn't really seem to be any need to have it hooked up to the web. Not
sure why not BTLE or just local WiFi.

~~~
jonmarkgo
The original workshop for Makerland actually offered 2 options - RFID or SMS,
it's totally up to you which you use

------
goeric
Lockitron can't even build their own Lockitron. My order has been delayed
around 6 months now :(.

~~~
tgcordell
I've had the same experience. Delayed 3 different times, for about two months
each occurrence. :(

------
DanielN
I've been building a lockitron clone using a raspberry pi. The key
functionality selling point for me was being able to lock/unlock the door base
on proximity like lockitron's "sense" feature.

Turns out this is much more difficult than it sounds because bluetooth le rssi
is pretty unreliable. I've figured how to get it working for my particular
case but I would be curious how lockitron configures it to work consistently
for a wider range of locations and devices.

On a separate note, the servo can be attached to the door without duct tape or
modifying the door if you have a door like [1]. I simply bought a piece of
rubber tubing that fits over the knob and then configured a smaller piece of
rubber to fit the servo arm to the lock piece on the knob. This design is also
nice in that if the device malfunctions a key can override it.

1 - [http://www.happynews.com/living/livingimages/remove-door-
kno...](http://www.happynews.com/living/livingimages/remove-door-knob.jpg)

~~~
jonmarkgo
That's a good solution, did you just mount the servo to the door itself?

~~~
DanielN
The servo is mounted to the piece of rubber which is then mounted to the
doorknob. The only thing keeping the servo on the lock is friction.

------
primitivesuave
I've done this project before, except I used Tropo + Arduino Ethernet +
Twitter's API. Coding the server in Node.js is way easier, but requires a
computer to remain on and connected to the Arduino in order to work.

Also, the duct tape will come off after around 100 locks/unlocks, so I
eventually had to remake the whole thing with a 3D printed frame and shaft
that would be secured to the door. My initial version was horrible, held
together by glue/duct tape/cardboard/prayers.

If you want to turn the lock without the motor, you need to have the Arduino
detach the servo after the rotation is complete. If you don't detach the
servo, you'll damage the motor if you turn it by hand, because the internal
tachometer will fight as hard as it can to maintain the servo's position.

Overall a very cool project and a great primer into using Node with Arduino.

~~~
jonmarkgo
Thanks, glad you like it! My eventual goal is to evolve it to use a 3d-printed
servo mount, but sadly I do not have a 3d printer handy. Would love to see
your model though.

~~~
spokenn
Great project. Here's an idea - my neighborhood needs a timed garbage can
lock. I can't take the garbage can out at night for the garbage truck in the
morning because people dig through trash and leave a mess. It is annoying
because I hate walking out in the cold half awake.

------
ekux44
Last year I built something similar with Lego Mindstorms and a bluetooth
control app.

[http://kuxhausen.com/legoitron/](http://kuxhausen.com/legoitron/)

However, I stopped using it as the command strip's velcro would come apart
whenever the door was slammed shut.

~~~
jonmarkgo
That's a cool setup - does it manually turn the little lock thing?

------
krazydad
Cool project. I recently did a similar project that involved controlling an
Arduino from Node.JS. A friend suggested I use Firmata, which is a standard
protocol for talking to Arduinos via the serial port.

[http://firmata.org/wiki/Main_Page](http://firmata.org/wiki/Main_Page)

Very painless to use, and the script for the Arduino is included on the
Aruidino SDK examples menu. You can get up and running in Node.JS in just a
few lines of code.

For what it's worth, my project involved playing the brass bells on a
christmas ornament from a game of 2048.

[https://www.youtube.com/watch?v=FBLxCrZ49p8](https://www.youtube.com/watch?v=FBLxCrZ49p8)

~~~
jonmarkgo
Hah, I love 2048 hacks. Also, Firmata is the ideal way to handle something
like this - I was just trying to be barebones and keep things raw.

------
ccmoberg
This is very cool, and great to see a full writeup. I actually built a very
similar hack at the 2012 TechCrunch DisruptSF Hackathon:
[http://techcrunch.com/2012/09/09/meet-the-disrupt-
sf-2012-ha...](http://techcrunch.com/2012/09/09/meet-the-disrupt-
sf-2012-hackathon-winners-livebolt-takes-grand-prize-auctopus-and-heatdata-
are-runners-up/)

We used an electric imp and we 3D Printed a aperture for grabbing the deadbolt
handle.

Interestingly, this was about 4 weeks before lockitron announced the presale
of their current product...

Great work!

~~~
jonmarkgo
I think I saw that, actually. Really great hack - did you post the 3D model
anywhere? Would love to evolve my duct tape/cardboard into a 3D print at some
point.

------
jsvaughan
I built something similar too:
[https://vine.co/v/hmu5IlBj2pQ](https://vine.co/v/hmu5IlBj2pQ)

Mine uses NFC keys. Arduino does a lookup over GPRS against a web service to
check if the key is permitted to unlock.

As someone else has commented, this uses an electric door strike rather than a
servo.

You can register new keys using the webapp, make them allowed for certain time
periods etc.

------
j45
I don't recall much being proprietary about the first Lockitron -- it was off
the shelf insteon components for the lock and the controller as this post
highlights can be done in a number of ways.

It's nice to see different homebrew options popping up -- hopefully it will
lead to an open source equivalent that can be 3d printed eventually :)

------
shadesandcolour
I considered doing this for a while (although probably sans-twillo), but had a
hard time finding reliable information on servos you could read information
from. Is the Servo type used in the code in this project built in to the
arduino libraries? I've never seen it before.

------
NathanKP
When I get my Tessel I'm going to try to implement this in 100% Node.js With
the Tessel I should be able to communicate with Twilio directly from the
microdevice via Wifi without needing to start up a separate server on my
computer and communicate via serial port.

~~~
jonmarkgo
That's an awesome idea. I was going to use either a Raspberry Pi or Arduino
Yun for mine (to remove the computer from the equation) but a Tessel would be
even better!

------
richardlblair
Cool project, and really smart of them to put this on their blog. I know it
seems obvious to a lot of us, but there are a lot of people out there that
would never think of doing this.

~~~
jonmarkgo
Glad you like it! I love doing hardware hacking and am certainly happy that
Twilio is open to publishing things like this.

------
mauerbac
This is so awesome! Question: (I haven't used servos much) Will this still
allow the regular key functionality to work? Can you turn the servo manually
or is it resistant?

~~~
jonmarkgo
You'll likely need to add some kind of method to turn off the servo when it is
not actively in use. When a servo is powered, it resists being turned
manually.

~~~
mauerbac
ah, I see. Still extremely useful-- my roommates and I lose our keys all the
time. Also love the idea of adding "groups" of cell numbers to the permission
list.

------
jonheller
This is great, not just for the idea, but how detail the writeup is. I feel as
though I could do this even without much Arduino and Node.js experience.

~~~
jonmarkgo
Really glad you liked it!

------
robbiet480
I can't quickly tell, but does/could this support a mortise lock? If Lockitron
did, I would've ordered one years ago.

~~~
jonmarkgo
As long as the lock/unlock control is a 180-degree (or less) turn it should be
fine, though from my understanding most Mortise locks would not fit this
criteria

------
kennedysgarage
This is incredible. I am always amazed by what you can hack together with
Twilio.

~~~
jonmarkgo
Thanks!

------
michaelgold
I will take you out for steaks at Keen's if you build me one of these.

------
kaushalp88
This is a really cool alternative to the $179 lockitron. Nice job!

~~~
ssimpson
probably get it faster too.

------
jjacobson
Does this work with international numbers?

~~~
jonmarkgo
Yup. You can use any SMS-enabled Twilio number (or voice-enabled number if you
change some of the code to respond to dial-tones) - list can be found at
[https://www.twilio.com/international](https://www.twilio.com/international)

------
prtkgpt
Super!

------
jayzalowitz
Awesome!

