Post Page Advertisement [Top]

tutorial

Interfacing of RFID RC522 with Arduino


RFID means radio-frequency identification. RFID uses electromagnetic fields to transfer data over short distances. RFID is useful to identify people, to make transactions, etc…
You can use an RFID system to open a door. For example, only the person with the right information on his card is allowed to enter. An RFID system uses:
tags- attached to the object to be identified, in this example we have a keychain and an electromagnetic card. Each tag has his own identification (UID).
tags
two-way radio transmitter-receiver, the reader, that send a signal to the tag and read its response.
Image result for rfid rc522
Another benefit of RFID is that it doesn’t require to be in a line of sight to get detected. As in barcode, the reader has to be in the line of sight to the tag and then it can scan but in RFID there’s no such restriction.
Specifications:
1.     Input voltage: 3.3V
2.     Frequency: 13.56MHz

Pin configuration:
There are many different RFID modules available in the market. The RFID module, which I am gonna use in this project, is RFID-RC522. Its quite easy to interface and works pretty fine. This module has total 8 pins as shown in the below figure:
RC522 with arduino,RFID with Arduino,RC522 arduino,Arduino rc522

·         SDA
·         SCK
·         MOSI
·         MISO
·         IRQ
·         GND
·         RST
·         3.3V

Pin Wiring:

Pin
Wiring to Arduino Uno
SDA
Digital 10
SCK
Digital 13
MOSI
Digital 11
MISO
Digital 12
IRQ
unconnected
Gnd
Gnd
RST
Digital 9
3.3V
3.3V

Note: You must power this device to 3.3V!
Library Link:
https://github.com/PaulStoffregen/SPI
Circuit:
Mifare_bb

Code:
#include "SPI.h" // SPI library
#include "MFRC522.h" // RFID library

const int pinRST = 9;
const int pinSDA = 10;
MFRC522 mfrc522(pinSDA, pinRST); // Set up mfrc522 on the Arduino

void setup()
{
  SPI.begin(); // open SPI connection
  mfrc522.PCD_Init(); // Initialize Proximity Coupling Device (PCD)
  Serial.begin(9600); // open serial connection
}

void loop()
{
  if (mfrc522.PICC_IsNewCardPresent()) { // (true, if RFID tag/card is present ) PICC = Proximity Integrated Circuit Card
    if(mfrc522.PICC_ReadCardSerial()) { // true, if RFID tag/card was read
      Serial.print("RFID TAG ID:");
      for (byte i = 0; i < mfrc522.uid.size; ++i) { // read id (in parts)
        Serial.print(mfrc522.uid.uidByte[i], HEX); // print id as hex values
        Serial.print(" "); // add space between hex blocks to increase readability
      }
      Serial.println(); // Print out of id is complete.
    }
  }
}
Output:
You will get the rfid card value in HEX.



No comments:

Post a Comment

Bottom Ad [Post Page]