top of page
Writer's pictureRamesh G

IoT Based RFID Access Control using Blynk app



Here to learn how to make an IoT based RFID smart door lock system using NodeMCU ESP8266, RFID MF-RC522 Module, servomotor, and Blynk application. With the help of this project, You can remotely monitor your door access from anywhere in the world with your phone through internet.


Circuit Diagram

Components Required

RC522 RFID Module - 1no

ESP8266 12E- 1 no

Servo 9G - 1 no

Buzzer - 1no


RC522 RFID Module

The RC522 is a 13.56MHz RFID module that is based on the MFRC522 controller from NXP semiconductors. The module can supports I2C, SPI and UART and normally is shipped with a RFID card and key fob. It is commonly used in attendance systems and other person/object identification applications.


Pin Configuration

PIN PIN

NAME NUMBER DESCRIPTION

1 Vcc Used to Power the module, typically 3.3V is used

2 RST Reset pin – used to reset or power down the module

3 Ground Connected to Ground of system

4 IRQ Used to wake up the module when a device comes into range

5 MISO/SCL/Tx MISO pin when used for SPI, acts as SCL for I2c and Tx for UART.

6 MOSI Master out slave in pin for SPI communication

7 SCK Serial Clock pin – used to provide clock source

8 SS/SDA/Rx Acts as Serial input (SS) for SPI, SDA for IIC and Rx during UART


RC522 Features

  • 13.56MHz RFID module

  • Operating voltage: 2.5V to 3.3V

  • Communication : SPI, I2C protocol, UART

  • Maximum Data Rate: 10Mbps

  • Read Range: 5cm

  • Current Consumption: 13-26mA

  • Power down mode consumption: 10uA (min)

Where to use RC522 RFID Module

The RC522 is a RF Module that consists of a RFID reader, RFID card and a key chain. The module operates 13.56MHz which is industrial (ISM) band and hence can be used without any license problem. The module operates at 3.3V typically and hence commonly used in 3.3V designs. It is normally used in application where certain person/object has to be identified with a unique ID.


The keychain has 1kB memory in it which can be used to stored unique data. The RC522 reader module can both read and write data into these memory elements. The reader can read data only form passive tags that operate on 13.56MHz.


How to use RC522 RFID Module

The RC522 has an operating voltage between 2.5V to 3.3V and hence is normally powered by 3.3V and should be used with 3.3V communication lines. But, the communication pins of this module are 5V tolerant and hence it can be used with 5V microcontrollers also like Arduino without any additional hardware. The module supports SPI, IIC and UART communication but out of these SPI is often used since it is the fasted with a maximum data rate of 10Mbps.

Since in application, most of the time reader module will be waiting for the tag to come into proximity. The Reader can be put into power down mode to save power in battery operated applications. This can be achieved by using the IRQ pin on the module. The minimum current consumed by the module during power down mode will be 10uA only. The module can be easily used with Arduino because of its readily available RC522 RFID Arduino library from Miguel Balboa. You can visit his GitHub page for more details on how to use it with Arduino.


Applications

Automatic billing systems

Attendance systems

Verification/Identification system

Access control systems


Blynk


Here I have added two tabs. One for virtual monitor for user swipes a card log. And another tab is used for access control open and close.

Configure Blynk App for IoT based RFID smart door lock.

First, log in to your Blynk account. If you don’t have an account then signup with your Gmail.

  • Open the app and create a new project, with the name IoT RFID.

  • Click on the select device and Select NodeMCU.

  • Set the connection Type to WiFi.

  • Finally, click on the create button, an authentication token will be sent to your email. We need this token later.

  • Click on the screen and search for tabs. We are going to add two tabs with the Name Live Monitoring and Remote Access Control.

  • Now click on the live monitoring tab and tap anywhere in the blank space. add the terminal widget. set the terminal widget Virtual pin V2 and set the New Line to Yes.

  • Now Select the Remote Access Control tab. Click on empty space and add three buttons.

  • Click on the First Button, set the Name, and select the virtual Pin V3. Set the button Mode as Switch. You can also set the fonts as per your requirements.

  • Now click on the second button. Set the name, select virtual pin V4, and select button mode as a switch.

  • Similarly, do the same for the third button and set the virtual pin to v5.


Installing the arduino Library

Download RFID Library.

BlynkDownload - Blynk Library can connect any hardware over Ethernet, WiFi, or GSM, 2G, 3G, LTE, etc.


After downloading the .zip files, add the libraries in Arduino IDE by clicking on


To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.


Subscribe and download code.


Arduino Code:

#include <SPI.h>

#include <MFRC522.h>

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#define SS_PIN 4

#define RST_PIN 5

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

char auth[] ="xxxxxxxxxxxxxxxxxxxxxxxxxxx"; //replace with your Auth code here


const char* ssid = "xxxxxxxxxx"; // replace with Your SSID

const char* password = "xxxxxxxxxxx"; //replace with your wifi Password

#include <Servo.h>

Servo myServo; //define servo name

#define BUZZER 15 //buzzer pin


SimpleTimer timer;

int fflag = 0;

int eflag = 0;

int jflag = 0;

WidgetTerminal terminal(V2);


void setup()

{

Serial.begin(9600); // Initiate a serial communication

Blynk.begin(auth, ssid, password);

SPI.begin(); // Initiate SPI bus

myServo.attach(2); //servo pin D4

myServo.write(0); //servo start position

pinMode(BUZZER, OUTPUT);

noTone(BUZZER);

mfrc522.PCD_Init(); // Initiate MFRC522

Serial.println("Put your card to the reader...");

Serial.println();

timer.setInterval(1000L, iot_rfid);


}

void loop()

{


timer.run(); // Initiates SimpleTimer

Blynk.run();

}



void iot_rfid(){


// 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], DEC);

content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));

content.concat(String(mfrc522.uid.uidByte[i], DEC));

}

Serial.println();

if( (content.substring(1) == "185 48 97 193") && (fflag == 1))

{

Serial.println("User A");

Blynk.virtualWrite(V2, "USER A" );

digitalWrite(BUZZER, HIGH);

delay(250);

digitalWrite(BUZZER, LOW);

myServo.write(180);

delay(3000);

myServo.write(0);


}

if( (content.substring(1) == "41 80 176 178") && (eflag == 1))

{

Serial.println("User B");

Blynk.virtualWrite(V2, "USER B" );

digitalWrite(BUZZER, HIGH);

delay(250);

digitalWrite(BUZZER, LOW);

myServo.write(180);

delay(3000);

myServo.write(0);

}

if( (content.substring(1) == "121 014 172 178") && (jflag == 1))

{

Serial.println("User C");

Blynk.virtualWrite(V2, "USER C" );

digitalWrite(BUZZER, HIGH);

delay(250);

digitalWrite(BUZZER, LOW);

myServo.write(180);

delay(3000);

myServo.write(0);

}

else

Serial.println("unregistered user");

digitalWrite(BUZZER, HIGH);

delay(1500);

digitalWrite(BUZZER, LOW);

}


// in Blynk app writes values to the Virtual Pin 3

BLYNK_WRITE(V3)

{

fflag = param.asInt(); // assigning incoming value from pin V3 to a variable

// Blynk.virtualWrite(V2, fflag );

}

// in Blynk app writes values to the Virtual Pin 4

BLYNK_WRITE(V4)

{

eflag = param.asInt(); // assigning incoming value from pin V4 to a variable

}

BLYNK_WRITE(V5)

{

jflag = param.asInt(); // assigning incoming value from pin V5 to a variable

}




2,819 views0 comments

Comentários


bottom of page