from: Medium cavecafe
DIY Smart Door Lock with Apple HomeKit Integration
There are a number of smart door lock in the market. Those smart locks are really convenient especially cold and windy winter season.
When you arrived at your driveway or in front of the door, you just talk to Siri, ‘Hey Siri, Open the door’. Then, you don’t need to insert the key or press the doorbell.
Smart Lock is Great, But …
Here is my problem though. I could not find a smart lock for my storm door that I can attach it to the deadbolt.
The deadbolt is nothing but a simple rotating 90-degree lock from Home Depot. You can either insert the key, rotate 90-degree to open it, or someone turn the knob from inside.
It also does not make sense to spend more money to replace the entire door just because of not being able to put a smart lock for sure.
Open Source Alternatives - DIY
I found a number of YouTube videos — here is one of them. Smart people are playing around Raspberry Pi as Home Bridge to control ESP8266. There is another implementation purely worked as ESP32 however, I found it is not that stable (I’m not sure it is only for me though).
So, my goal is just to build a smart door lock for my storm door with the following requirement.
- One device has all, no bridge ‘within a single device’. So, no additional Wi-Fi connection is required between RPi and other tiny ESP8266. I wasn’t confident about the WiFi security between Raspberry Pi and ESP8266 (There is an article about ESP8266 this year if you are interested).
- Running on the rechargeable battery with a solar cell. The location of the lock doesn’t have any power outlet.
- Manual override button from inside the door. If someone presses my doorbell, I should be able to simply press the button to open the door.
Here is a quick demonstration of proof of concept. And, the source code is in GitHub project cavelock.
Hardware
- Raspberry Pi Zero W (for small form factor)
- A servo (SPEKTRUM A5030)
- A relay
- A 5V solar cell and rechargeable batteries
- Soldering iron and wires
- Multi-meter (if you have)
Software
- Compiler (GCC C++)
- Visual Studio 2019 (for remote debugging)
- Some knowledge on HomeKit (HAP, SRP) would be helpful
- AutoDesk Fusion 360 for 3D modeling of the container
Features
- Run-on Raspberry Pi Zero W in console (or systemd)
- Control a deadbolt from 90 to zero degree with a servo
- A relay shuts down the current once the servo moved to the target angle (it saves power consumption)
- A push-button overrides the control of deadbolt for manual operation
- No need to have Home Bridge as HomeKit Accessary Protocol (HAP) and Secure Remote Password (SRP) are included, you can pair with the iOS Home app directly.
References
- HAP implementation relies on Gera Kazakov with some modifications.
- HomeKit Accessory Protocol from Apple
- Secure Remote Password in Wikipedia
Next Step
- It is still a proof of concept without even cover. But, it is running well more than a week in the test. Hopefully, I can make it 2nd version as a bit smaller than this.