Sie sind auf Seite 1von 5

Homebuilt: How to assemble

an electronic door lock

Saraju P. Mohanty, Duotong Yang, and Anim


Andrew
Amarsingh
Ong

W
e have ma-
chines to brew
our coffee, turn
on the air condi-
tioner, and wash
our laundry. Why
then, do we not have machines to
lock and unlock our front doors
automatically? This thought per-
vaded my mind as I had to unlock
not one, not two, but three doors
multiple times per day at my stu-
dent dorm.
When I moved to a campus apart-
ment, the lock situation changed for
the worsemy slick radio-frequency
identification (RFID) card was re-
placed with a large, bulky metal key.
It ripped holes in my pocket, made
noise, scratched whatever else it
came in contact with, and was not
fun to use in the dark. And with a
deadbolt, I had to use the key when
entering and exiting. Using a key
was tedious and inconvenient and
could be easily automated.
The lock I imagined needed these
features:
unlock when either I or my
roommates walk up to it
automatically lock a deadbolt
when the door closes
report all access granted/
denied and door open events
k
oc
to the Internet. hic
st
p
ra
be operable by the school hous- yg
db
se
ing administration lice
n
ge
ma
sei
Hou

Digital Object Identifier 10.1109/MPOT.2015.2428751


Date of publication: 8 September 2015


0278-6648/152015IEEE IEEE Potentials September/October 2015 n 43
be operable manually with a key wait. It was discreet (nothing showing be a delay between reading and
from the outside and fingers on the outside) and relatively cheap. unlocking.
from the inside (no push to The circuit was also interesting be- 3) The read distance was 3 in
exit button). cause on the other side of the doorbell maximum.
A benefit of building your own you receive an amplitude-shift-keyed 4) There were all kinds of tutori-
door lock actuator is that you get signal, which you have to rectify and als online about how to fake
to choose whatever triggers it. This regulate to logic levels for the micro- these tags.
means you can create as many key- controller. Ultimately, I chose none of These restrictions eventually led
cards as you want in whatever form the above because they were just not me to change the RFID reader to
you wish. You can then hide these as quick and easy as holding an RFID an HID Thinline II that I bought on
keycards in clever places. You can card to a reader. eBay. Now my roommate and I could
also enable and disable keycards Having settled on RFID, I didnt just press our school IDs against the
at will. Compare this to a metal key have many choices. I read about ac- door. The tag-reading process was
that, if lost, cannot be disabled. In- tive RFID, where each user carries much faster with the Wiegand in-
stead, I would be charged a US$50 a radio-frequency tag with a bat- terface. In fact, with a second RFID
key replacement fee, my roommates tery, but I read that this was expen- reader, I had nothing to do with the
would have to have their keys re- sive and I could not find a place to first two tags. I ended up using them
placed, and the lock core itself would purchase tags and base stations. as secret lockout tags that you had
have to be replaced. The modern-day equivalent to ac- to present to the card reader in the
tive RFID is called Bluetooth 4.0 right order to open the door.
The design phase Low Energy (BLE). It detects whether The HID Thinline II was nice, but
All engineering starts with design. In two radios are in a 50-ft range. By it did not solve the small 3-in read
this case, the most important deci- choosing between BLE Class 1, 2, or distance issue. We still had to press
sion to make is what the input 3, you can trade off between range our tags to the door. I solved the
device will be. and transmission power. Bluetooth read distance problem by setting up
My circuit needed two inputs: is what commercial smart locks use an eBay alert for the ultimate RFID
an authenticator today. The user does nothing but readerthe HID Maxiprox (Fig. 2),
a door open/closed detector (only walk up to the door. However, there for use with parking lots. It retails
necessary for the deadbolt). was no BLE in the fall of 2010. for US$400 but has a read distance
The authenticator could be any- My first proximity detection de- of 24 in, which allowed me to read
thing. I saw builds online where vice (Fig. 1) was a Parallax RFID through the wall. If placed correctly,
people used 12-button keypads, reader (model 28140) that read stan- this meant I would not even have
QWERTY keyboards, secret knock se- dard EM4100 tags. However, there to take my wallet out of my pocket.
quences, text messages, and Hack-a- were a few problems. You could not believe my excitement
days RGB light-emitting diode (LED) 1) My roommate and I had to carry when I scored this industrial equi-
pad. The most fascinating one to me special RFID tags in our wallets ment for US$13 at an eBay junkyard
was the single-button entry system instead of using our student IDs. sale. You may still find long-range
in which you have to input Morse 2) The baud rate of the RFID reader RFID readers online, albeit not by
code-like sequences by pressing your was hardcoded at an extremely HID. And if you use Bluetooth, you
doorbell a number of times and then slow 2,400 baud, so there would can avoid this search entirely.

fig1 The first prototype using Arduino, Parallax, and HID RFID fig2 Prototype 4s RFID reader was placed at waist height so
readers along with a servo motor to pull the handle. that it could read through the wall, straight into my pocket.

44 n S e p t e m b e r / O c t ober 2015 IEEE Potentials


The other necessary input de- The output device piece: the actuator. This was so that
vice is something to tell the micro- The most important part of an elec- my schools staff could still enter
controller when the door is open or tronic door lock is the lock. Fortunate- with their keys.
closed. The easiest way to accom- ly, I never had to actually engineer a If I were to tackle this same prob-
plish this is with a magnetic reed lock, just actuators for the lock. lem today, I would not buy a lock
switch or an infrared LED and de- My first prototype used a bottom- actuatorI would use my schools
tector. I used a reed switch. How- of-the-line HS-311 servo motor tied three-dimensional printer to make
ever, if you want a sexy one-piece to the mortise lock with very strong my own actuator. This would be much
design, aim for an accelerometer or plastic string under a lot of tension. I more satisfying and better electrically
other motion sensor and measure
the difference in motion for when
the door is opened versus when it Ultimately, I chose none of the above
is closed.
because they were just not as quick and easy as
The microcontroller holding an RFID card to a reader.
I had four prototypes of this lock
and used an Arduino in prototypes
13. Unfortunately, when I wanted used string because I was under the since there would be no Faraday cage
to connect an Arduino to the Inter- restriction of not drilling through around the lock. I could make it my
net, it was a major pain. The ATme- the door. I had to disassemble the own and engrave my name on it too.
ga328 does not have enough static mortise lock a little, but eventually I
random-access memory (SRAM) to tied the servo down enough so that it Solenoids
store even one Ethernet packet. would not budge. I actually did this project at home in
Further, I needed a web-hosting ser- I saw a video of an X10 dead- San Francisco as well. Surprise! Or
vice and a database to hold my bolt online. It used an iPhone app maybe not. At home, there were
entry and exit logs. and X10 plug-in relay modules sol- actually two doors and hence two
In prototype 4, I switched to a dered to a Morning Industry dead- keys to suffer through, so there was
more Internet-friendly microcon- bolt remote. The X10 relays would even more benefit to be realized.
trollerthe Electric Imp (Fig. 3). Al- activate the remote, and the door One aspect I really didnt like
though the pin count was lower, a would unlock. about residences versus commercial
wireless local area network was now I really liked this idea, so I de- buildings was that residences are
possible, and the lock was now re- cided to shop for a remote control cheap and buzz with low-voltage ac
programmable through the Internet. deadbolt. The lowest-priced RF when you press the door open but-
The only disadvantage to using the deadbolt I found was a Morning In- ton. In commercial buildings, with
Electric Imp is that if the user does dustry RF-01SN. At the time of this their high-tech access systems, the
not specifically program for it, the writing, it is still selling on Amazon relay and solenoid will click open
lock does not work when the Inter- for US$104 including shipping. I elegantly with dc, making it more
net connection is down. Make sure used this lock in prototypes 3 and pleasant and easier to open the door
you choose a strong password for 4. When I received the lock, I did since the solenoid pin doesnt vibrate
your Electric Imp account. not use the cylinderonly the rear back and forth.

fig3 Prototype 4 with the Electric Imp, MAX232 level-shifter,


Morning Industry RF remote control, and other supporting fig4 Presenting to you...something that will change your life for years
circuitry, all inside the RFID reader. to come. Your very own house key.


IEEE Potentials September/October 2015 n 45
Internet logging
I wanted to have all entries and
No, No exits logged on a server that any of
my roommates could view. For this,
5) Deadbolt I used the Xively, the data-logging
Unlocked, Door service made specifically for Inter-
Yes, No Closed.
5 s Passed? net-of-Things applications. Their
Deadbolt SM
Door Open? value proposition is that your appli-
Yes *,Yes cation can be made very scalable.
4) Deadbolt Alternatively, I could have used a
Unlocked and Yes, No more traditional MySQL database to
No
Door Open. Yes,Yes
Door Open? store the logs. This is what I did at
digitalWrite(UnlockPin, Low) first, but using the Xively API was
3) Locking
2) Unlocking much easier than writing custom
Deadbolt.
No,* Deadbolt. SQL queries and opening PHPMyAd-
2 s Passed?
*,Yes 2 s Passed? No,*
Door Open? min to view my database contents.
Door Open?
digitalWrite(lockPin, LOW) I wrote a small front-end using
accessGrand = 0
digitalWrite(UnlockPin, HIGH) plain HTML at first. The page liter-
1) Deadbolt
Yes, No Locked, Door ally had two lines saying Last card
Closed Yes, No scan and Door last opened with
Access Granted?
Yes, Yes Door Open? no styling. It was completely static.
Gotta start somewhere.
No, No I then added some Javascript to the
page to subscribe to Xively Webhooks
and update the webpage in real time
6) Deadbolt as the door opened and closed. I used
Locked, Door the timeago Javascript plugin to cre-
Open.
ate the dynamic text that reads 12
hours ago. I then imported the open-
source CHAPS timeline Javascript
fig5 A state machine that covers all permutations and all valid transitions.
module to list entry and exit events
(Fig. 6). After styling the font and back-
I wanted the elegant dc click, so I State machine grounds with CSS, I added some but-
used a multimeter to figure out the Its one thing to make imaginary state tons at the bottom of the page to finish
house wiring. I actually slowly de- machines in logic design class, but off the minimal, but dynamic, front
stroyed the multimeter in the pro- its another to actually diagram one end. Throughout the entire session,
cess because I was trying to run con- and translate it into real code. All lock I had the Chrome Developer Console
tinuity tests on a live 24-Vac circuit firmware was essentially inside the displayed to diagnose any Javascript
(33 V peak). I didnt know the mul- state machine that tracked the posi- exceptions and errors.
timeter was being destroyed when tion of the deadbolt and whether the
it was buzzing, but it told me what I door was opened or closed. Conclusion
needed to know. Never run continu- To make your own state ma- I made a working electronic door
ity measurements on a live circuit. chine, start by listing all the states lock prototype that satisfied all of my
I rewired my house by disconnect- and the conditions to move to the criteria, and it eliminated the horrid
ing the transformer supplying the next state. Then draw transitions pain of using metal keys. Along the
way, I learned about
the Electric Imp platform
Its one thing to make imaginary state machines in ac household wiring
logic design class but its another to actually how to use a REST application

diagram one and translate it into real code. program interface with JSON
redundancy technology (e.g.,
Arduino watchdog timer)
24 Vac and connected the solenoid from one state to another based on bit-shifting the readings from the
instead to my 5-Vdc circuit. Now I the conditions. RFID reader
had the nice click. I used LucidChart to make my a real state machine.
When I rewired my home door lock, diagram (Fig. 5). You can use Mi- More pictures, a demonstration,
I gift-wrapped the RFID cards and crosoft PowerPoint or Microsoft Vi- and a video of the entire process may
presented them to my family (Fig. 4). sio as well. be found at http://goo.gl/6QJtHP.

46 n S e p t e m b e r / O c t ober 2015 IEEE Potentials


Bonus tips
For people who want to start a proj-
ect and dont know what to do or
dont have enough motivation, here

03
are some ideas.

Access Granted: Andrew Ong


Identify a need for yourself or
for others. You can make a proj-

02:00
ect because it is cool, but then it

Unlocked
becomes artwork. You want to

Saturday, 15 February 2014


make something that is like insu-
lin to diabetics, not luxuries like

01:00
sugar cookies. Remove the pain,
and you will be both motivated
Door Last Opened

and rewarded.
Take shortcuts. With limited time
12 h Ago

and effort, you must choose what

00:00
you want to learn and what you
want to outsource. Do you want to
learn how to make pancakes from
flour and raw ingredients, or do
23:00

fig6 My front-end with a little bit of styling and the zoomable CHAPS timeline. Complete with live-updating with the Xively API.
you just want pancakes? Hard-
ware platforms like LittleBits allow
Unlocked

31 d you to assemble a working circuit


that connects to the Internet with-
14 d
22:00

in 10 s. The tradeoff is that you


learn almost nothing. The same
5d

applies for MIT App Inventor for


Unlocked

24 h

Android applications.
Access Denied:

21:00
Last 24 h

Remove features. A product with


a bare minimum of functionality is
12 h
Unlocked

called a minimum viable product.


Access Granted:

At this point, you can claim an


6h
Unlocked

accomplishment and build more if


20:00

Show Last:
Access Granted: Andrew Ong

you wish. Dont be stuck with a


huge feature list and no product.
Do not let commercial competi-
Unlocked

Unlocked

tion discourage you. If your pri-


19:00

mary goal is to sell the product,


looking at the competition might
Access Granted: Andrew Ong

actually discourage you because


you are not the first mover. Even if
18:00
Last Card Scan:

you build something exactly the


Unlocked
12 h Ago

same as your competitor, you can


market it at a different time in a
different way and therefore claim
a different audience. If your pri-
17:00

mary goal is to learn, you can pick


Unlocked

Access Granted:

any project regardless of how


Friday, 14 February 2014

many times it has been solved.


Unlocked

16:00
Access Granted:

About the author


Andrew Ong (i.am.andrew.ong@gmail.
com) is a recent electrical engineering
graduate from the University of Califor-
15:00

nia, Riverside. He was formerly


employed at Raytheon. He loves having
his mind bent with radical new tech-
nology like Soylent and Bitcoin. 


IEEE Potentials September/October 2015 n 47

Das könnte Ihnen auch gefallen