
RFID door lock
Tap a card, the door opens
An Arduino reads RFID cards with an RC522 reader, greets you on an LCD and unlocks a 12 V solenoid lock through a relay. Wrong cards get a red light and a buzz. Great for a room, cupboard or drawer.
Every required part
Rs 4,077
Parts list
19 items
- Every required part in stock
- Wiring and code included
- Cash on delivery
From our reel · 9 Dec 2026Parts list
Everything you need for the rfid door lock
Required parts are ticked. Untick anything you already have; the total updates as you go.
Main parts
- Rs 300RequiredRC522 RFID Reader Module 13.56MHz
Comes with a white card and a blue key tag.
1Rs 300 each - Rs 660RequiredPCF8574T I2C 1602 Blue/green Backlight LCD Display Module For Arduino
Needs only 4 wires thanks to the I2C board on its back.
1Rs 660 each - Rs 1,050Required12V Cabinet Drawer Electric Solenoid Door Lock 54x28x39mm
Locked without power, opens while powered: the door stays locked if the power goes.
1Rs 1,050 each - Rs 3Required1N4007 1000V 1A General Purpose Rectifier Diode
Across the lock, to absorb its voltage spike and protect the relay.
1Rs 3 each
Power
- Rs 40RequiredDC Jack With Wire Female
Takes the adapter's plug and gives you + and − wires.
1Rs 40 each - Rs 30Required2 Point Quick Connector Cable Clamp Terminal Block Spring Connector Wire
Joins the lock's black wire to the adapter's, no soldering.
1Rs 30 each
Wiring & mounting
- Rs 179RequiredHalf Size Breadboard 400 Points For Electronics
For the LEDs, buzzer and shared 5 V / GND.
1Rs 179 each - Rs 130RequiredUSB Cable For Arduino Uno Arduino Mega
Uploads the code, then powers the Arduino from a phone charger.
1Rs 130 each - Rs 170Required20cm Pin To Hole Jumper Wire Dupont Line 40 Pin Male To Female Arduino Jumper Wires1Rs 170 each
- Rs 170Required20cm Pin To Pin Jumper Wire Dupont Line 40 Pin Arduino Male To Male Jumper Wire1Rs 170 each
- Rs 110Optional115mm x 90mm x 53mm ABS Electronics Enclosures Box Project Box
A neat box for the reader side of the door.
1Rs 110 each
Optional upgrades
- Rs 150OptionalArduino 4x4 Keypad Matrix Keypad Membrane Switch
Add a PIN code as a backup to the card.
1Rs 150 each
You also need (most homes have these)
- Phone charger (USB, 5 V)Powers the Arduino, reader and screen.
17 items
Rs 4,077
From our reel
Watch it come together in 12 steps
The reel of this build goes live on 9 Dec 2026, 7 pm. Follow us to watch it:
YouTube Instagram Facebook
1The parts

2Wire the RC522 reader

3Add the relay

4Connect the solenoid lock

5Add the LCD

6Upload the code

7Right tag → green

8Click! Unlocked

9Wrong card → red

10Mount it by the door

11Tap to enter

12Your own smart lock
How it works
What each part does
Every RFID card and tag has its own ID number. When you hold one near the RC522, the reader powers the card by radio and reads that ID, and the Arduino compares it with the list of allowed IDs in the code.
For an allowed card, the Arduino shows “Welcome” on the LCD, lights the green LED and switches the relay on for 3 seconds. The relay connects the 12 V adapter to the solenoid, which pulls its bolt in and the door opens. Any other card gets a red light and a buzz.
The relay keeps the 12 V lock circuit completely separate from the 5 V Arduino, so the two are powered by different supplies.
Wiring
Connect it pin by pin
RC522 reader (SPI)
| From | To | Note |
|---|---|---|
| RC522 SDA | → Arduino D10 | |
| RC522 SCK | → Arduino D13 | |
| RC522 MOSI | → Arduino D11 | |
| RC522 MISO | → Arduino D12 | |
| RC522 RST | → Arduino D9 | |
| RC522 3.3V | → Arduino 3.3VNot 5 V | |
| RC522 GND | → Arduino GNDIRQ is not used |
Screen, relay, LEDs and buzzer
| From | To | Note |
|---|---|---|
| LCD SDA | → Arduino A4 | |
| LCD SCL | → Arduino A5 | |
| LCD VCC / GND | → Arduino 5V / GND | |
| Relay IN | → Arduino D7 | |
| Relay VCC / GND | → Arduino 5V / GND | |
| Green LED (through 470 Ω) | → Arduino D5 | |
| Red LED (through 470 Ω) | → Arduino D6 | |
| Buzzer + | → Arduino D8 |
Lock circuit (12 V)
| From | To | Note |
|---|---|---|
| DC socket red (+12 V) | → Relay COM | |
| Relay NO | → Lock red wire | |
| Lock black wire | → DC socket black (−)Join them in the quick connector | |
| 1N4007 diode | → Across the lock's two wiresStriped end to the red (+) wire |
The code
Ready-to-upload Arduino code
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
MFRC522 rfid(10, 9); // SDA (SS) pin, RST pin
LiquidCrystal_I2C lcd(0x27, 16, 2); // try 0x3F if the screen stays blank
const int RELAY_PIN = 7, GREEN_LED = 5, RED_LED = 6, BUZZER = 8;
const int RELAY_ON = LOW; // most relay modules switch on with LOW
// Card IDs allowed to open the door. Tap a card and read its ID in the Serial Monitor.
const byte ALLOWED[][4] = {
{0xDE, 0xAD, 0xBE, 0xEF},
};
bool allowed(const byte *uid) {
for (auto &card : ALLOWED) {
if (memcmp(card, uid, 4) == 0) return true;
}
return false;
}
void showReady() {
lcd.clear();
lcd.print("Door locked");
lcd.setCursor(0, 1);
lcd.print("Tap your card");
}
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
lcd.init();
lcd.backlight();
digitalWrite(RELAY_PIN, !RELAY_ON); // start locked
pinMode(RELAY_PIN, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
showReady();
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;
Serial.print("Card ID:");
for (byte i = 0; i < rfid.uid.size; i++) {
Serial.print(" 0x");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
lcd.clear();
if (rfid.uid.size == 4 && allowed(rfid.uid.uidByte)) {
lcd.print("Welcome!");
lcd.setCursor(0, 1);
lcd.print("Door open");
digitalWrite(GREEN_LED, HIGH);
digitalWrite(RELAY_PIN, RELAY_ON); // unlock
delay(3000);
digitalWrite(RELAY_PIN, !RELAY_ON); // lock again
digitalWrite(GREEN_LED, LOW);
} else {
lcd.print("Access denied");
digitalWrite(RED_LED, HIGH);
digitalWrite(BUZZER, HIGH);
delay(1000);
digitalWrite(BUZZER, LOW);
digitalWrite(RED_LED, LOW);
}
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
showReady();
}Step by step
Build it
- 1
Wire the reader and screen
Connect the RC522 to the SPI pins and the LCD to A4/A5 as in the tables. Power the RC522 from 3.3 V only.
- 2
Read your cards' IDs
Install the two libraries, upload the code and open the Serial Monitor at 9600 baud. Tap each card: its ID prints as four numbers like 0x5A 0x1F 0x9C 0x3B.
- 3
Allow your cards
Replace 0xDE, 0xAD, 0xBE, 0xEF with your card's four numbers. Add one line per card, then upload again.
- 4
Add the relay, LEDs and buzzer
Wire the relay's IN to D7 and the LEDs and buzzer on the breadboard. Tap the allowed card: you should hear the relay click.
- 5
Connect the lock
Build the 12 V circuit through the relay's COM and NO terminals, with the diode across the lock. Only then plug the 12 V adapter in.
- 6
Fit it to the door
Mount the lock on the inside of the door or drawer, the reader just behind the wood or plastic on the outside (it reads through about 3 cm), and power the Arduino from a phone charger.
Tips & troubleshooting
- If the lock opens all the time and closes on a valid card, change RELAY_ON from LOW to HIGH.
- A blank LCD usually means the wrong I2C address (try 0x3F) or the contrast screw on the back needs turning.
- Never leave the lock powered for long: solenoids heat up. The code opens it for 3 seconds only.
- Keep a mechanical way in: if the power fails, this lock stays locked.
Stuck on wiring or code?
Send us a photo of your build on WhatsApp. We are makers too, and we will help you get it working.
FAQ
Questions people ask
Can I add more cards later?+
Yes. Add one line per card ID to the ALLOWED list and upload again. Extra 13.56 MHz MIFARE cards and key tags work with the same reader.
Can I use it as an attendance system?+
Yes: the same reader and code print every card's ID. Add a real-time clock (DS3231) and an SD card module to log who tapped and when.
Will it work through my door?+
The RC522 reads through about 3 cm of wood or plastic, but not through metal. Mount the reader on the outside surface for metal doors.
Read next
- Arduino Kya Hai? Arduino Meaning in Urdu, Kaunsa Board Lein aur Pehla ProjectArduino kya hai, is se kya ban sakta hai, Uno, Nano ya Mega mein se kaunsa lein, shuru ke parts aur pehla LED blink project: aasaan Roman Urdu mein, Pakistan ki live qeematon ke sath.
- Arduino Price in Pakistan: Uno, Nano, Mega and Which Version to BuyCurrent Arduino prices in Pakistan for the Uno R3 (SMD and DIP), Uno R4, Nano, Pro Mini, Mega 2560, Leonardo and Due, what the differences mean, and which board to buy for your project.
More projects to build
All projects

























