Watch the Video Here
Smart door locks are dang pricey! The cheapest I could find are $100 and those get pretty bad reviews. To get a “good” one, you can expect to pay over $200! Fear not! I made 2 different types of smart locks for less than $25 each.
Thanks to the folks at BangGood who sent me these two magnetic locks to use. The “surface mount” lock, and the “strike” lock. They both work differently. So which one is best for you will totally depend on your situation and how you want to use it. One thing they both have in common is they run on 12 volts. So you’re going to need a source of 12v power. Neither one requires much power. They draw 150 – 250mA each. Pretty much any 12v power supply will work fine. One more thing, they both also work in “fail safe” mode. So if the unit fails, it will be in the “safe” position. In this case that means if the unit loses power it will unlock.
I’ve read a few forums about DIY smart locks and one point that gets brought up a lot is what happens in a fire. I’ll say two things about that. #1 we’re going to have a button that will lock and unlock the door from the inside. So if the house is on fire, and the power is still on, pressing the button will unlock it. Point #2. If the house is on fire and the power in the house is off. No power means no magnet, so the door will be unlocked.
Another point that gets brought up a lot when we’re talking about DIY smart locks is strength. That is, how much force can the lock withstand. It turns out, deadbolt locks (like this) have a grading system. Who knew?! The most common standard deadbolt is Grade 3. Grade 3 is made to withstand 150 lbs of force. The surface mount lock is rated for 64kg, or 140 lbs of force. That’s close enough for me. If someone really wants to get in they could just kick the door. A smart lock or a dumb dead bolt wont stop them.
So these are electronic locks, but by themselves they aren’t “smart” locks. To make them more smarter we need one more thing; a Sonoff. Thanks to __ who recently had a chat with iTead tech support and found out the intended pronunciation is actually S-On-Off. For this project the best option for adding some smartness is the S-On-Off SV. This is the low voltage version of the sonoff basic. You could use the stock firmware (eWeLink app). The setup is easy, the app is decent, and it works with Alexa or Google Home. On the downside, it relies on a connection to iTead’s servers, and it doesn’t provide a way to connect to your own smart home hub (which hopefully you have already, or will have soon). So, as usual, I’m going to replace the stock firmware with Tastmota. And this time, I’ve got a special little treat for you. Instead of using the Arduino IDE, I’m going to show you how to use FlashESP8266.
Full credit here goes to my friend Pete Stothers. He didn’t invent it, but he put out the first video that I saw that explained where to get it and how to use it. If you haven’t seen Pete’s videos go check him out. https://youtu.be/MOEmVYn4I8A
FlashEsp8266 is actually made by the folks that make ESPeasy. It’s a simple little executable file. It comes included in the zip file you can download here:
That zip file has several versions of ESPeasy included. Someday I’ll try ESPeasy, but it is not this day! I’m going to use Tasmota so I grabbed sonoff.bin from the Tasmota github. You can also make your own .bin file with all the settings for your Network and such. This would require using the Arduino IDE, and making sure you have all the right libraries and Tools settings, so if you go this far you might as well just upload it from here, but just to show you what’s possible, it works like this:
When you’ve made the changes to your user_config.h file, make sure your tools settings are all right, then save it, go to Sketch and click Export Compiled Binary. Now to find where that .bin file gets saved, click Show Sketch Folder. Grab that .bin and move it to the folder where you have the FlashESP8266.exe file. Or move that .exe file to this folder, either way.
You still have to use a USB/Serial adapter and get the board in programming mode. When you have the Sonoff connected to your computer and in Programming mode, start FlashESP8266.exe. Select the com port for your Sonoff, and select the .bin file you want to upload, and click “Flash”. That’ll put Tasmota on your sonoff, but you still have to get into it and setup your network connection. This is the part you’d get to skip if you made your own .bin. With Tasmota you can put the board in wifi manager mode by pressing the onboard button 4 times. Here are the other things you can do in Tasmota with on-button presses. If you did the 4 presses correctly the led on the board will flash rapidly. Now go to your available wifi networks and connect to the one that says “sonoff-blah”. This time, I just used my phone. Once you connect to that “sonoff” wifi, you can put in your home network SSID/PW. Now to finish the setup you need the IP address of the sonoff. Open the main page and configure the module type and MQTT, and whatever GPIO pin settings you plan to use. I’m going to use one of these cool, and super cheap capacitive touch modules. You could have some fun and hide this somewhere to make a secret door.
We’ve got our electronic locks, and now we’ve got the brains of our Smart Lock ready, so we’re ready to install it. The surface mount lock comes in 2 parts. One is just a metal plate, the other is the electromagnet. Mount the metal plate to the door and the electromagnet to the door frame. Do the best you can to hide the wires, since cutting those wires would be an easy way for someone to bypass your lock. I used superglue to hide the wires in the corners. I’d paint them if they were in a place where the wife would have to see them. With this lock, alignment is really important. To allow the plate to shift slightly and get into the strongest bonding position, I loosened it just slightly. You may have to get creative in how you line it up so it’s in that best possible position. If it isn’t aligned just right, the bond will be really weak. But, when it’s lined up just right, wow, it’s strong! For us I think this is the kind of lock we’d put on the outside doors of the house. You know, the ones you always can’t remember if you’ve locked once you’re in bed at night. With this lock, we can easily lock all the doors at night, or even set them up to automatically lock with an automation.
The other lock requires some modifications to the door frame. I put this one in the garage so I didn’t need Wife approval. It works by replacing the normal strike plate with this one that can be released and allow the door to open even when the door handle is locked. The install was pretty straight forward. I didn’t kick it to see how much force it can withstand, and I couldn’t find a weight rating on the package or the website. But it feels plenty strong. Again, if someone wants to kick the door down, this thing isn’t going to stop them. This is a good lock to use on a door where you usually have the handle locked but occasionally you want to allow someone in, maybe to make a delivery, or because they forgot their keys.
Now to make these smart locks maximumly useful, we’re going to set them up in… that’s right, Home Assistant! In the configuration.yaml file make a new switch entry for these locks. Mine looks like this:
– platform: mqtt
name: Office Lock
– platform: mqtt
name: Shop Lock
Then in the Customize.yaml:
I tried using the “lock” component in Home Assistant, but it wasn’t working correctly. Not sure what I was doing wrong. But calling it a switch, then changing the icon to a lock works!
Finally to put all your locks together and give yourself one button to lock or unlock them all, go to groups.yaml and add this:
Well, that’s it. I really wanted to make a cheap but still functional smart lock. And I think we did it! There are links to the locks I got from Banggood in the description. I’ll be ordering a few more of those for sure.
As always, thanks for watching, until next time, Adios.
If you can’t wait for shipping…