Hi Friends welcome to Akshit Innovation Lab.This blog we are going to see. How to make a RFID Door Lock. Now lets start the blog
Things Needed
Led and Buzzer
CLICKHERE: SUBSCRIBE
CONNECTION PARTStep 1:
Connect RFID pins to jumpers
Step 2:
Connect jumpers to the first four pins. Leave the RTU pin and connect the last three pins again
Step 3:
Take the RFID SDO pin and connect it to the 10th pin of Arduino
Step 4:
Take the RFID SEK pin and connect it to the 13th pin of Arduino
Step 5:
Take the RFID MOSIMI pin and connect it to the 11th pin of Arduino
Step 6:
Take the RFID SOI pin and connect it to the 12th pin of Arduino
Step 7:
Now leave the RQ pin
Step 8:
Connect RFID ground to Arduino Ground
Step 9:
Take the RFID RST pin and connect it to the 9th pin of Arduino
Step 10:
Connect RFID 3.3 volt pin to the Arduino 3.3 volt
Step 11:
Ok now we have to provide the relay connections
Step 12:
Connect relay module's IN1 to the Arduino 3rd pin
Step 13:
Connect relay ground to Arduino ground
Step 14:
Connect relay +5 volt to +5 volt of Arduino
Step 15:
Now get the 12v door lock
Step 16:
Connect the positive wire of 12v door lock to the center pin of the relay
Step 17
Post connecting, tighten the screw in the relay (in the connected area). So that the wire wouldn't slip
Step 18:
Hope you have seen how I tightened the screw after fixing the wire
Step 19:
Now take the 12v female jack. Connect its positive to the NC
Step 20:
Exactly right side to the center pin which we connected in the previous step
Step 21:
Please note the screw of the right side one has to be opened, before the wire is connected
Step 22:
Now you can see the 12 v black wire from adapter. Which is the negative. Connect that negative to the door lock negative (use jumpers as appropriate)
Step 23:
Now we are going to create the security system
Step 24:
Connect Green and Red LED as appropriate
Step 25:
Now connect Red LED negative to the Arduino ground
Step 26:
Now move the pin in bread board a bit. Connect the pin exactly in the same line where Led is connected
Step 27:
Now connect the other end of the pin to the ground of the buzzer which is connected to bread board
Step 28:
Now connect the pin which is available in the backside gap of buzzer to the green led negative
Step 29:
Now the negative side of the power supply is done
Step 30:
Now connect the Arudino 4th pin to the positive of the Red LED
Step 31:
Now connect the Arudino 2nd pin to positive of the buzzer
Step 32:
Now connect the Arudino 5th pin to the positive of the Green LED
Circuit Diagram
Step1:
Now let's go to the coding part
Step 2:
Install Arduino IDE app
Step 3:
Copy paste the code provided in my website into the IDE
Step 4:
Now we need to connect to the right Arduino board
Step 5:
Go to tools menu and select Arduino Uno (as the board)
Step 6:
select tools menu and go to port. Connect to the port which is enclosed in
parenthesis (port number is dynamic)
Step 7:
Now upload the code
Step 8:
The upload process ensures the code is uploaded to the Arduino board
Now you have to understand, for the purpose of demonstrating we have to
enable the tag or card to access the door
When you open the serial monitor, you will be prompted to show the tag/card.
I'm showing the tag. On showing the tag, a code will be shown
Step 9:
Copy that code and overwrite it in the denoted area of the code (in the portion where it is mentioned as change)
Step 10:
After changing click on upload
Remember, since we wanted to enable the card to access the door lock, we have undergone these steps.If you want card to access door, then we need to do these steps in card
Step 11:
Now it is uploaded (see done uploading in the status bar)
Code
//AKSHIT INNOVATION LAB https://www.youtube.com/c/AKSHITSINNOVATIONLAB
//RFID Door Lock
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 5 //define green LED pin
#define LED_R 4 //define red LED
#define RELAY 3 //relay pin
#define BUZZER 2 //buzzer pin
#define ACCESS_DELAY 2000
#define DENIED_DELAY 1000
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
pinMode(LED_G, OUTPUT);
pinMode(LED_R, OUTPUT);
pinMode(RELAY, OUTPUT);
pinMode(BUZZER, OUTPUT);
noTone(BUZZER);
digitalWrite(RELAY, LOW);
Serial.println("Put your card to the reader...");
Serial.println();
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "89 B6 64 A3") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println();
delay(500);
digitalWrite(RELAY, HIGH);
digitalWrite(LED_G, HIGH);
delay(ACCESS_DELAY);
digitalWrite(RELAY, LOW);
digitalWrite(LED_G, LOW);
}
else {
Serial.println(" Access denied");
digitalWrite(LED_R, HIGH);
tone(BUZZER, 300);
delay(DENIED_DELAY);
digitalWrite(LED_R, LOW);
noTone(BUZZER);
}
}
Comments