Arduino Projects

RFID Based Solenoid Door lock using Arduino

Hello everybody, in today’s project, you will learn to make your own RFID-based solenoid door lock system using Arduino. You will learn to interface and control the solenoid lock with Arduino and RFID MF-RC522 module.

RFID (Radio Frequency Identification) is a cheap and accessible technology. It can be used in many applications such as access control, security, asset tracking, person tracking, etc. You may have seen RFID door lock systems in hotels, offices, and many other places. Basically, they provide you a card and you have to just place the card near the RFID reader, within a second and the door will open.

This RFID Solenoid door lock can be easily made at home just following this tutorial. Previously, we have also used the same technology on our RFID and IoT based projects.

Wiring of RFID Based Solenoid Door Lock Using Arduino

Here in this project, we are using Arduino and Relay to trigger the solenoid door lock. While RFID MF-RC522 is used to authenticate users so that your RFID tag acts as the key. If you place the wrong RFID card close to the RFID reader, a buzzer will beep to alert you about the wrong card.

Demonstration of RFID Based Solenoid Door Lock Using Arduino

Components Required

The following are the components required for RFID Based Contactless Door Lock Using Arduino.

  • Arduino Uno
  • RFID-RC522 Module
  • 12v/9v Solenoid Lock
  • Relay Module
  • RED and Green LED
  • Buzzer
  • Jumper Wires

Circuit Diagram for RFID Solenoid Door lock using Arduino

The Circuit Diagram for RFID Based Solenoid Door lock using Arduino project is provided below.

Circuit Diagram RFID Based Solenoid Door Lock Using Arduino
Circuit Diagram of RFID Based Solenoid Door Lock Using Arduino

Connections between Arduino and RFID are given in the table below. The positive pin of the buzzer is connected to digital pin 2 of Arduino, and the GND pin is connected to the ground pin of Arduino. The solenoid lock is connected to Arduino through the relay module.

RFID PinArduino Uno Pin  
SDADigital 10
SCKDigital 13
MOSIDigital 11
MISODigital 12
RSTDigital 9
Relay PinArduino Uno Pin  

Green LED Positive pin is connected to the digital pin 5 of Arduino and Negative pin to the GND. Similarly, RED LED Positive pin is interfaced with digital pin 4 and Negative pin to the GND.

Program Code

Let’s start coding by including all the required libraries. Here, this program only requires two libraries, one for SPI communication between Arduino and RFID, and the second for the RFID module. Both the libraries can be downloaded from the links provided below:

//RFID Based Solenoid Door lock using Arduino
//The IoT Projects

#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);
  digitalWrite(RELAY, LOW);
  Serial.println("Put your card to the reader...");

void loop() 
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  //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.print("Message : ");
  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");
    digitalWrite(RELAY, HIGH);
    digitalWrite(LED_G, HIGH);
    digitalWrite(RELAY, LOW);
    digitalWrite(LED_G, LOW);
 else   {
    Serial.println(" Access denied");
    digitalWrite(LED_R, HIGH);
    tone(BUZZER, 300);
    digitalWrite(LED_R, LOW);

Now copy the above Arduino Program code for RFID Based Solenoid Door lock using Arduino Project. Paste the copied code in your Arduino IDE. Here, you need to choose the correct Arduino Board and Its com port from Tools Menu. Basically, you need to compile the code before uploading the code to the Arduino to check any errors in the code.

After the successful upload of the code, open the serial monitor at the baud rate of 9600. Scan your RFID card, Now copy the UID from the serial monitor and paste it to the program code in the following lines.

if (content.substring(1) == "83 23 38 BB") //change here the UID of the card/cards that you want to give access

Video Demonstration of RFID Based Solenoid Door lock using Arduino

Here, is a complete video demonstration of RFID Based Solenoid Door lock using the Arduino Project. I hope you will enjoy watching this video. If you did, then don’t forget to hit that like button. Share it with your friends and subscribe to this channel for more awesome content like this.


So, that’s pretty much for this session. I hope you enjoyed making this RFID Based Solenoid Door lock using Arduino project. If you did, don’t forget to share this article with your friends. If you have any doubts regarding this weather station project then do let me know them in the comment section below.

Recommended Readings:

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button