|
NanoArduino
|
x 1 | |
|
RFID Tags ( 13.56 MHz ) |
x 1 | |
|
Bread Board |
x 1 | |
|
Jumper Wires |
x 1 | |
|
Micro USB Cable |
x 1 | |
|
MFRC522 RFID ReaderNXP
|
x 1 |
![]() |
arduino IDEArduino
|
Using Arduino to Build a Smart RFID Door Lock System
In this project, we will be using an Arduino board to control an RFID door lock. The lock will be activated when the correct RFID tag is presented to the reader, and will stay locked until the tag is removed.
Specifications
Input voltage: 3.3v
Frequency: 13.56MHz
That’s all guys let’s get into the Connections & Coding part.
RFID With Arduino
now let’s see how we can use RFID with Arduino and build our own RFID door lock. We will be using tags based on the MIFARE protocol and the MFRC522 RFID reader, which cost only a couple of dollars.
These tags have 1kb of memory and have a microchip that can perform arithmetic operations. Its operating frequency is 13.56 MHz and the operating distance is up to 10 cm depending on the geometry of the antenna. If we bring one of these labels closer to a light source, we can see the antenna and microchip we discussed earlier.
Step 1: Circuit Diagram
The RFID reader module uses the SPI protocol for communication with the Arduino board and this is how we must connect them. Note that we need to connect the VCC of the module to 3.3V and as for the other pins we don’t have to worry as they are 5V tolerant.
Check the schematic and pin configuration to make connections.
Connect the pins with the following :
– MOSI —> PIN 11
– MISO —> PIN 12
– SCK —> PIN 13
– SS/SDA —> PIN 10
– RST —> PIN 9
– LED —> PIN 4,5& GND
– Relay / Output power —
– GND connect to GND pins,
Step 2: Library Download
Before you download the library you need Arduino IDE to get started.
Here’s the library you need for this project:
Download the RFID library and created by miguelbalboa.
Unzip the RFID library.
Install the RFID library in your Arduino IDE.
Restart your Arduino IDE
Step 3: Reading Data From a RFID Tag
After having the circuit ready
Go to File > Examples > MFRC522 > DumpInfo > Upload the code.
This code will be displayed in your Arduino IDE (after installing the RFID library). Then, open the serial monitor.
Write down your UID card ( ” Card UID: xx xx xx xx ” )
Step 4: Arduino Program
The Arduino code for the RFID door lock can be copied below.
Upload the code. Attach the Arduino, battery, and lock valve on the inside of the door. And attach the RFID reader to the outside of the door. This way the RFID tag can be used to open the door easily.
#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) == "83 23 38 BB") //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); } }
Using Arduino to Build a Smart RFID Door Lock System

Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW
ESP32-S3 4.3inch Capacitive Touch Display Development Board, 800×480, 5-point Touch, 32-bit LX7 Dual-core Processor
BUY NOW
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(0)
- Likes(0)

- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Hetao Liu
-
Commodore 64 1541-II Floppy Disk Drive C64 Power Supply Unit USB-C 5V 12V DIN connector 5.25
74 0 2 -
Easy to print simple stacking organizer with drawers
33 0 0 -
-
-
-
Modifying a Hotplate to a Reflow Solder Station
1070 1 6 -
MPL3115A2 Barometric Pressure, Altitude, and Temperature Sensor
587 0 1 -
-
Nintendo 64DD Replacement Shell
472 0 2 -
V2 Commodore AMIGA USB-C Power Sink Delivery High Efficiency Supply Triple Output 5V ±12V OLED display ATARI compatible shark 100W
1352 4 3