Hello everyone!
Today I am going to explain you about making another version of my door lock system. I have already taught you about making three versions of door lock system, and this version will have two layers of security - RFID system and Keypad.
Please refer to the links below to learn about the previous versions of my Door lock system.
- Door Lock system V1.0 - Using RFID
- Door Lock system V2.0 - Using IR remote
- Door Lock system V3.0 - Using RF 433Hz transmitter and receiver
Hardware components used in this project
- Arduino Uno
- USB Type A/ B cable (for Arduino Uno)
- Solderless Breadboard - Half+
- Breadboard Power supply module - 3.3/ 5 V
- MFRC522 RFID reader
- RFID tags - Card tag and Key tag
- Keypad matrix - 4x4
- LCD display module with I2C interface - 16x2
- Relay module - 5V single channel
- Solenoid door lock - 12V
- Male-to-Male Jumper wires
- Female-to-Male Jumper wires
- Voltage Regulator/ 12V DC power adapter
Setup
Your hardware setup must look somewhat similar to those in the photos above.
Connections
Keypad matrix - 4x4
- Row1 - A0
- Row2 - A1
- Row3 - D7
- Row4 - D6
- Column1 - D5
- Column2 - D4
- Column3 - D3
- Column4 - D2
MFRC522 RFID reader
- SDA/ SS - D10
- SCK - D13
- MOSI - D11
- MISO - D12
- IRQ - Not connected
- GND - Ground
- RST/ RESET - D9
- 3.3V - 3.3V
LCD display module with I2C interface - 16x2
- GND - Ground
- VCC - 5V
- SDA - A4
- SCL - A5
Relay module - 5V single channel
- S - D8
- (+) - 5V
- (-) - Ground
Coding
For this project, you will be needing the following libraries:
- MFRC522 by miguelbalboa - https://github.com/miguelbalboa/rfid
- Keypad by Mark Stanley and Alexander Brevig - https://playground.arduino.cc/Code/Keypad/
- LiquidCrystal_I2C by fdebrabander - https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
- SPI - In-built library
Open the 'DumpInfo' example sketch from the MFRC522 library and upload it to your Arduino microcontroller board to scan the UID of your RFID tags.
Create MFRC522 instance and set the LCD address to 0x27 for 16 chars and 2 line display. You can use the I2C scanner to get the address of your LCD display module. Create variable to store your PIN. You will need to use the char data type to create this variable, and create another variable to store the PIN entered. Create a variable using the 'int' data type to store the number of counts, and a global variable for the relay module. Define the number of rows and columns in your keypad by using the 'const byte' data type.
const byte rows = 4;
const byte columns = 4;
char hexaKeys[rows][columns] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte row[rows] = {A0, A1, 7, 6};
byte column[columns] = {5,4,3,2};
Keypad key = Keypad( makeKeymap(hexaKeys), row, column, rows, columns);
Within void setup( ), use the pinMode( ) function to configure the relay pin as OUTPUT. Initiate SPI bus, MFRC522 and LCD display.
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
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 the authorised tag is placed, the LCD display module must show that the tag is identified and then ask you to enter the PIN. Afterwards, you must type in the PIN using the Keypad matrix and during this process, the LCD display module will show '*" in places of these characters. If the correct PIN is entered, the relay module will be switched on and the LCD will show that the Access is granted.
If the unauthorised tag or incorrect PIN is entered, the relay module won't be switched on and the Access will be denied.
If anyone has any questions with the coding, please feel free to comment below or send me an email at arduinoprojectsbyr@gmail.com.
Final Look
If anyone has any questions, or suggestions, about this project, please feel free to comment below or send me an email at arduinoprojectsbyr@gmail.com.
ms can you send me the full code pls..
ReplyDeleteOk. Send me an email at arduinoprojectsbyr@gmail.com.
Delete