Voice Controlled Door Lock Using Alexa and Arduino
by jithinsanal1610 in Circuits > Arduino
396 Views, 5 Favorites, 0 Comments
Voice Controlled Door Lock Using Alexa and Arduino
![Door Lock 1.png](/proxy/?url=https://content.instructables.com/FMV/AQD8/L5MH1AHM/FMVAQD8L5MH1AHM.png&filename=Door Lock 1.png)
![Voice Controlled Door Lock System using Arduino and Alexa | [Easier than you Think]](/proxy/?url=https://content.instructables.com/FS0/H6PM/L5MH1AIH/FS0H6PML5MH1AIH.jpg&filename=Voice Controlled Door Lock System using Arduino and Alexa | [Easier than you Think])
Voice Controlled Door Lock: An Overview
Hey, everyone! Welcome back. In this video, we'll make an Alexa-controlled door locking system that lets us lock and unlock a door with our voices. This lock is easy to design, make, install, and use. Not only do they make your home safer and more convenient, but they also make it easier to install and use locks in general.
Let's get started! So let's begin with the circuit! I drew the circuit and made the PCB with the help of the Altium designer. Here we are in Altium designer. Here, I'll be using a Solenoid door lock that works on 12 V, so I'll connect a 12 V DC adapter. A 7805 regulator is linked to the power source. The 7805 is a 5V regulator that can turn a 7-32V input voltage into a steady 5V DC supply. There are LEDs at different places to help you figure out what's wrong.
Supplies
![Door Lock 2.png](/proxy/?url=https://content.instructables.com/FQ3/ZP30/L5MH1AHZ/FQ3ZP30L5MH1AHZ.png&filename=Door Lock 2.png)
- Arduino Nano RP 2040
- Relay
- MOSFET
- BJT
- LED
- Resistor
- Soldering Iron
Alexa Door Lock Circuit
![Voice Door Lock Circuit.png](/proxy/?url=https://content.instructables.com/FUY/89J1/L5MH1AI3/FUY89J1L5MH1AI3.png&filename=Voice Door Lock Circuit.png)
![Voice Door Lock PCB.png](/proxy/?url=https://content.instructables.com/FDZ/E6ST/L5MH1AI4/FDZE6STL5MH1AI4.png&filename=Voice Door Lock PCB.png)
There are two switches here. One is a Relay that is turned on by a transistor BC547, whose base is connected to Digital Pin 3, and then there is a MOSFET that is connected to digital pin 5 of the Arduino. Here, you should also see a buzzer that this transistor turns on and off. The digital pin 6 of the Arduino is linked to this transistor.
You can connect the lock to either the MOSFET or the Relay, both of which can be programmed to turn on and off. I decide to connect the Lock to the MOSFET so that I can use the relay to connect something else, like a light bulb. You can connect extra things, like a lamp or a motor, to the other switch to open the door, like a motor or a lamp.
This is just my idea. As I said before, I'll put the plans in the description so you can redesign the whole thing, change it, and then make your own version. Or you can make it like my version. Before you do anything else, you should try it out on a breadboard. Once you have the output, you can either use it as is or use it to make your PCB.
I made the decision to go with the PCB. I made a PCB layout where you can easily mount your Arduino Nano RP 2040, relays, MOSFETs, and other components. This way, you don't have to use wires and cables that are all over the place. And making your own PCBs for your project is cool, right? The board is small and easy to carry. Depending on the Solenoid Lock voltage, it can be powered by a 9V battery or a 9–12 V power adapter.
Getting the PCBs Done
![screenshot-www.pcbway.com-2021.11.25-17_09_33.png](/proxy/?url=https://content.instructables.com/FRN/3U4S/L5MH1AI1/FRN3U4SL5MH1AI1.png&filename=screenshot-www.pcbway.com-2021.11.25-17_09_33.png)
![screenshot-www.pcbway.com-2021.11.25-17_10_17.png](/proxy/?url=https://content.instructables.com/FAW/N3Z1/L5MH1AI2/FAWN3Z1L5MH1AI2.png&filename=screenshot-www.pcbway.com-2021.11.25-17_10_17.png)
I ordered PCB from PCBWay. PCBWay is a PCB manufacturer specializing in PCB prototyping, low-volume production, and neat and tidy PCB assembly. If you are interested in making your own PCBs for your project, check out the link below. You can get a 5-dollar discount when you sign up using the link below and get an additional 5-dollar discount at the checkout by providing the coupon code PCBWayLab.
To order your PCB from PCBWay, go to the PCBWay website and fill in the basic board details in the instant order form. From there you will be directed to a form where you can provide more elaborate board details. Update your board information in the PCB specification screen. On the next screen, you should be able to upload your Gerber file and submit it for review. Once the review is completed, all that is left is to add to the cart, make payment, and wait for your PCBs to arrive.
Once you get all the components and the PCB, it’s time for you to solder them together. Solder all the components onto the board and make sure to check the polarity of the components. After soldering the PCB looks like this.
Using the Arduino Cloud to Program a Door Lock
![Arduino IoT Cloud Lock.png](/proxy/?url=https://content.instructables.com/FGL/TPAT/L5MH1AHX/FGLTPATL5MH1AHX.png&filename=Arduino IoT Cloud Lock.png)
Let's talk about the software now. Here, I'll use Arduino IoT Cloud to write code for the board. Here, we've made a new project or "thing" for our voice door lock and made a switching variable that works with Alexa devices. Then, an Arduino Nano RP2040 Board was added.
This page will show you everything you need to know about your project. Here, you'll find all the information about your project, such as the attached board, variables, network, sketch, etc.
Coding Our Door Lock So That Alexa Can Use It
When you use the Arduino IoT cloud, once you set up your thing and all the variables, it will automatically create a skeleton code that includes all the variables and critical functions that are needed to run the code. All we need to do is add more variables and functions.
#include "thingProperties.h" void setup() { Serial.begin(9600); delay(1500); pinMode(LED_BUILTIN, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); initProperties(); ArduinoCloud.begin(ArduinoIoTPreferredConnection); setDebugMessageLevel(2); ArduinoCloud.printDebugInfo(); } void loop() { ArduinoCloud.update(); } void onDoorLockChange() { if (doorLock == 1) { beeper(); beeper(); beeper(); beeper(); digitalWrite(LED_BUILTIN, HIGH); digitalWrite(5, HIGH); } else if (doorLock == 0) { beeper(); beeper(); digitalWrite(LED_BUILTIN, LOW); digitalWrite(5, LOW); } } void beeper() { digitalWrite(LED_BUILTIN, HIGH); digitalWrite(6, HIGH); delay(100); digitalWrite(LED_BUILTIN, LOW); digitalWrite(6, LOW); delay(100); }
Now, I'll get rid of all the comments that don't add anything, so they'll look neet. And here's our last code, guys. Let's look at it in more detail.
In the setup function, we will set up serial communication and communication with the Arduino cloud. We will also set the pin mode and get the carrier ready to run the rest of the code.
This function will run whenever the variables change. The function will be run when the value changes. So, when Alexa tells us to lock the door, all we do is flip the pin that is connected to the lock. I've also put in some beeping functions here. That wasn't hard at all, right?
Add Your Alexa Lock
![Door Lock 1.png](/proxy/?url=https://content.instructables.com/F8G/V5IH/L5MH1AHY/F8GV5IHL5MH1AHY.png&filename=Door Lock 1.png)
Now, get your phone out and open the Alexa app. Go ahead and link your account and the Arduino Skill for Alexa.
Now, click on find devices. It will start looking for any IoT devices that work with Alexa. Once the scan is done, the variable we made earlier will be shown as an Alexa device. Just add the thing. Guys, that's it.
Testing
![Voice Controlled Door Lock System using Arduino and Alexa | [Easier than you Think]](/proxy/?url=https://content.instructables.com/FS0/H6PM/L5MH1AIH/FS0H6PML5MH1AIH.jpg&filename=Voice Controlled Door Lock System using Arduino and Alexa | [Easier than you Think])
Now, you should be able to use your voice to control the lock through Alexa. You can talk to Alexa and control these devices through the Amazon app on your phone and Amazon devices like Echo Dot. If you like this project and really want to build cool DIY projects, make sure you subscribe to our channel by clicking the "Subscribe" button here.