DIY Smart Doorlock

Aditya Mhatre
2 min readOct 23, 2019

--

The last apartment I was renting in had this fancy door lock facility which used a key fob. I believe it was RFID based but I am not sure how that worked. Never bothered to look it up. In hindsight, I regret that 🙁

So when I moved to a new apartment, I was back to using the old fashioned physical turn-your-key key. But by now, I have been keeping my car keys and other keys in my bag and now I had to reach out in my bag pack and get the key and unlock the door manually 😓

Being a tinkerer, I decided I was going to make an automated door lock. I used a Raspberry Pi Model 3B+ for this and with my trusty 3D printer, printed out some parts that helped me finish this thing. Following are instructions on how I did it.

Hardware:
1. RPi 3B+
2. Stepper Motor (https://www.amazon.com/gp/product/B00PNEQ79Q/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1)
3. L298N Driver https://www.amazon.com/gp/product/B01H6VMEFY/ref=ppx_yo_dt_b_asin_title_o06_s00?ie=UTF8&psc=1
4. GT2 Timing Pulley and Belt

Circuit Diagram:

Schematics

After the electronics was done, it was the physical parts now. I 3D printed a jacket for the door knob that turns when the key is rotated and made a groove in it by design so that it can include a timing belt in it. I plan to use the timing belt and motor to rotate this “jacket” which in turn would rotate the actual doorknob 🤩

So after connecting everything up as above, it was time to write the code !
It was a trial-error process to figure out by how much I needed to turn the motor in order to perform a lock or unlock by rotating the door lock knob using the timing motor and belt.

I’ll include the code in a GitHub repo here. But basically I made a web server on the Pi that listens on my local network (duh) and made another app for my phone that communicates with the server to lock or unlock the door.

Now, if the Pi powers down due to some reason(☹️) or any error in the software occurs, fret not ! We can still use our backup physical key to unlock the door using the old-fashioned way 😇

Here is the demonstration video

This is still in place waiting for my phone to lock/unlock the door 😃

--

--