Type Here to Get Search Results !

Smart door lock system using Arduino

Hi everyone! Welcome back to another interesting blog of My Tech Studio. Today we're going to create a smart door locking system using Arduino, RFID and servo motor. So today we're going to do a simple keyless door lock. I am all about low-cost electronics projects. So in this video I’m going to show you exactly what I did to put all this together. We’re going to talk very brief about the RFID module and the servo motor because they're both new. Take a quick look at the connections I’ll show you exactly how I connected it to the elegant mega board and we're also going to take a look at the code and see how absolutely  easy this is to set up.

Smart door lock system using Arduino –

Here we have the RFDI rc-522 module right here the RFID module and so this usually comes with a standard blank card right here which I have labelled wrong ID card for what I’m doing. And then it comes with another keychain card right here and I’ve labelled that correct id for what we're doing here. Now your RFID module may or may not come with headers attached if not it's not a big deal you can just solder those in yourself what is RFID well it's an acronym for radio frequency identification its where tags and labels are captured by a reader which is right here and transferred by radio waves. It’s an automatic identification and data capture technology it's also known as aidc it identifies an object it collects the data on that object  and inputs data into a computer file so to speak and it consists of three components usually an  RFID tag or label an RFID reader and an antenna. 

There’s usually an antenna in your reader here that’s activated by electromagnetic field when the id tag is in proximity to a reader it generates an electromagnetic field that activates the tags antenna and powers the chip.

What is RFID door lock system?

So RFID is wildly useful it's useful in inventory management id badges restricted area access personnel tracking counterfeit prevention and we'll be using the RFID rc-522 module and this particular module as you can see has eight pins and so the first pin here is your VCC pin and it is to be connected to a 3.3 volt that is important if you connect it to a 5 volt  you may find yourself buying a new module right here next to your VCC you see an RST pin that  is your reset pin and when this pin goes low. It’ll power down all the internal workings the oscillator the current sinks and the input pins. Right next to that you see the ground pin that's obviously connected to ground and then next to that you see the IRQ pin. The IRQ pin is an interrupt pin and that is a handy one to have as it will alert the microcontroller when the RFID tag comes within the vicinity rather than continually sending out a signal asking if there's a tag in the area or in the vicinity next we have the miso pin and that acts as a serial clock. 

When the i2c interface is enabled or it'll act as a serial data output, when the UART interface is enabled. Now the third one from the left here is the MOS I pin that is the SPI input. The serial peripheral interface input to the RC 522 module second to the last pin. Here is the SCK pin and that accepts the clock pulses and provides that information to arduino and your last pin here on the left is the SDA pin and that pin acts as a signal input. When the serial peripheral interface is enabled the servo motor is a closed loop system that relies on feedback signal to change speed and direction and it provides rotation with precision and efficiency. Now the servo has three wires which you can see the brown one is the ground wire and that’ll go into the ground port on your leg board. The red wire in the middle is your VCC and that should be connected to your five volt port. And the orange one or actually it looks kind of yellowish here that is your signal wire. And that one will go into your digital port whatever digital port you're using this motor contains drive gears a motor a shaft a potentiometer and a microcontroller or specialized servo IC and an encoder which serves as a sensor  providing speed and position feedback with this motor.

How do you make an Arduino based RFID door lock?

You can get the speed and position you're looking for by controlling the length of the pulse and the voltage that's applied to the amplifier and you can see the arm up here on top. It’s you can put a screw right there to hold it in place it does have multiple connection points there are ac servos and dc servo motors and they all have a range of 0 to 180 degrees and in just a moment we'll see how to program a servo motor and work it into what I’m going to call our smart door lock circuit that's what I want to call it. So here's my connection I have my lg mega 2560 board right here I’ve got my  servo motor here and I’ve got my RFID. The RC 522 reader right here I’ve got my two leds right. 

Here I’m going to show you exactly how to set this up. Alright my wiring for my RFID module here we will start from left to right here you got the SDA pin that's my black wire here on the end and that one's connected to digital pin 53 on my board. Next we've got the SDA pin that's my green wire right here and that one's connected to digital pin 52 on my board. Next up we have the MOS I pin that's pin number three here going left to right and that one for me is blue if you can see the blue wire there and that pin is connected to digital pin 51. Next pin up here on my module is the miso pen and for me it's another black wire right here and that one is connected to digital pin 50 on my board. Next up is the IRQ pin there is no connection here I left that one empty. As you can see after that we've got the ground pin that's my orange pin. And I just connected it to the ground wire over here by pen digital pin 53 after that we've got the RST pin and that one's connected to digital pen 5 and it's my purple wire and it keeps coming out. So we'll put that back. Finally our VCC pin or 3.3 volt pin that's the red wire here i connected that to the 3.3 pin here on my board be sure not to connect it to the 5 volt.

How do you make a RFID lock?

What we do need to know for our code is the UID and that is the first four sets of numbers and letters right here in the manufacturer block it's also listed up. Here the card UID this is what you need to know for the code you can either write it down or hold ctrl press c and copy and paste it into the code you can also scan your other card and look at that UID as well. If you want to use both cards and we see that UID right down here in the manufacture block and if we scroll to the top for the second card there that I scanned the white one. We see that manufacturer or the UID is right here. As well you can use both UIDs for both cards in the code to grant access with the RFID scan if that’s what you want to do I’m just using one. Here is the code that I used for the RFID with lock and with the red and green light. 

It’s important that you include the correct pins for your SS pen and your RST pin my SS pen is at 53 and my RSD pin is at pin 5 on my microcontroller. Come down here and include the servo information. It’s going to start at angle 0 and then we come down here and the tag UID is the id that we got from the serial monitor earlier. And if you want another one if you want more than one card you can add it right next to this I believe you just need a comma there and then you can add the other UID as well so  that is important otherwise your card won't work. Down here I set the red and green led as an integer at pin 8 and 9. Down here in the setup I said that my servo is attached to pin 3 on my leg board and this initiates my RFID module this right here sets up the red and green pen as an output and has parameters for going high and low. If you come down here to the loop this is looking for the card it's looking for the card id that you included up here you may have one you may have more in the loop that begins looking for the card it will select one of the cards or card and if the card that you scan matches the id that is in our code you have access. And if that is true the l the green led pin will go high it will turn on then it will delay and it will turn off that's here too I’m not sure that I need that there but  I’m just going to leave it because it's working. Also if this is true and it detects the card with the id that we've included in the code above the servo motor will activate and move 180 degrees it will delay for five seconds and then move back to zero. If you scan a card and the UID does not match what we've put in the code then access is denied and the red led will go high it will light up indicating that that is the wrong card.