blog

RFID-MFRC522

RC522

Intro

  Traditional barcode recognition technology is hard to meet the needs.Instead,RFID (Radio Frequency Identification) technology realizes non-contact data interaction through radio waves,providing an efficient, reliable and automated solution for fields such as item management, identity recognition, and logistics tracking. RFID (Radio Frequency Identification) technology plays a vital role. As a core chip in this field, MFRC522 has derived a variety of module products, among which RFID-RC522 and RC522 MINI are favored by developers. Next, let’s take a deep dive into these two products.

RC522

What is RFID?

RFID is the abbreviation of Radio Frequency Identification. Radio frequency identification is a technology that uses radio frequency signals to realize non-contact information transmission and achieve the purpose of identifying targets through the transmitted information. It can complete data exchange without physical contact and is widely used in many fields such as logistics, retail, transportation, and security.

Core components of RFID

RFID system usually consists of four parts:
Tag:Attached to the object to be identified, it contains a chip for storing information and an antenna for receiving/transmitting radio frequency signals.
Reader/Writer:Transmit radio frequency signals through the antenna to communicate with electronic tags (read tag information or write data to tags).
It has data processing and transmission functions, and can upload tag information to the background system through wired (such as USB, Ethernet) or wireless (such as Wi-Fi, Bluetooth) methods.
Antenna:Expand the signal coverage to ensure stable communication between the tag and the reader;
Host:Composed of computers, servers, databases, etc., it is responsible for processing the data transmitted by the reader, and realizing the storage, analysis and management of tag information (such as inventory statistics, path tracking, etc.).

image

RFID working principle

  • The reader sends out radio signals of a specific frequency around it through its antenna.
  • When the electronic tag enters the reader’s signal range, the passive tag gets power through electromagnetic induction and activates. The active tag responds on its own.
  • the tag sends the stored info back to the reader via radio signals through its antenna
  • The reader receives and decodes the signal, then uploads the data to the backend system for processing.
  • If data needs to be written, the reader sends commands and data to the tag via radio signals. The tag updates its internal storage after receiving them.
picture

MFRC522 Working Principle Diagram

WPS图片1

Is RFID the same as NFC?

Not exactly.RFID and NFC are not the same concept. NFC is a specific branch of RFID technology, and they have an inclusive relationship.

  • RFID :It is a broad technical category, referring to the technology that realizes non-contact information transmission and target identification through radio frequency signals, covering various frequencies, protocols and application scenarios.
  • NFC : It is a subset of RFID technology, specifically referring to short-range wireless communication technology that works at 13.56MHz, has an extremely short communication distance (usually 0-10 cm), and follows specific protocols (such as ISO 14443, ISO 18092).

common
Consistent technical foundation: NFC is essentially an extension of high-frequency RFID technology, and its tag part is compatible with high-frequency RFID tags.
The core principle is the same: both realize non-contact data transmission through electromagnetic induction or electromagnetic coupling.

Summary
NFC is a type of RFID, but RFID ≠ NFC.
To put it simply, RFID is a big family that covers various wireless identification technologies with different frequencies and distances; while NFC is a specific member of this family with “short distance and high interactivity”, focusing on short-distance two-way communication, especially widely used in consumer electronics (such as mobile phones).

What is UID?

UID is the abbreviation of User identification. After a user registers, the system will automatically give you a UID value, which means assigning a number to this user.

In IC chips , UID is the unique identification code. It is a globally unique digital code written into the chip during the chip manufacturing process, just like the ID card of the chip, used to distinguish different chip individuals. It is usually a code composed of a string of numbers or a combination of numbers and letters, and its length and format vary according to chip manufacturers and specific application scenarios.

RFID-RC522 Introduction

  MFRC522 is a highly integrated non-contact (13.56MHz) card reading and writing chip. This transmitting module uses the principle of modulation and demodulation, and fully integrates them into various non-contact communication methods and protocols (13.56MHz).

RFID-RC522 Module

When the MFRC522 communicates with a microcontroller via SPI, it follows the master – slave mode. The microcontroller acts as the master, MFRC522 acts as the slave. Data interaction is completed through 4 wires.

Performance Specification Table

Model MFRC522
Operating Voltage 3.3V
Operating Current 13 – 26mA
Operating Frequency 13.56MHZ
Operating Temperature 20 – 80°C
Storage Temperature -40 – 85°C
Relative Humidity 5% – 95%

Pin Function

SDA: SPI port chip selection
SCK: SPI clock
MOSI: SPI port slave input
MISO: SPI port slave output
IRQ: Interrupt
GND: Ground
RST: Reset pin
3.3V: VCC

cover of RC522

Mechanical Size

dimension

Tips

This module does not support RFID cards which operate at 125KHz frequency range. It supports only the cards which operate at 13.56MHz frequency range

RFID-RC522 Arduino

Fritzing circuit

Fritzing circuit

Wiring With Arduino

RC522 PinWiring to Arduino Uno
SDADigital 10
SCKDigital 13
MOSIDigital 11
MISODigital 12
IRQunconnected
GNDGND
RSTDigital 9
3.3V Supply3.3V

Schematic

schematic

Arduino RFID-MFRC522 Code

				
					#include <SPI.h>
#include <MFRC522.h>

// Define SPI interface pins (modify according to actual wiring)
#define SS_PIN 10    // SDA/SS pin
#define RST_PIN 9    // RST pin

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

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();   // Initialize MFRC522 module
  Serial.println("Get the RFID tag close...");
  Serial.println();
}

void loop() {
  // Check if a new card is present
  if (!mfrc522.PICC_IsNewCardPresent())
    return;
  // Verify if NUID is readable
  if (!mfrc522.PICC_ReadCardSerial())
    return;

  Serial.print("UID: ");
  String uidString = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    uidString += String(mfrc522.uid.uidByte[i], HEX);
  }
  Serial.println();

  Serial.print("type: ");
  MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
  Serial.println(mfrc522.PICC_GetTypeName(piccType));

  // Put the card into hibernation to prevent repeated reading
  mfrc522.PICC_HaltA();
  
  // Stop encrypted communication
  mfrc522.PCD_StopCrypto1();
  
  Serial.println("------------------------------");
}
				
			

Reading Data from a RFID Tag

reading data

Put the RFID card/ keychain to the reader

reading all data

This is the information that you can read from the card, including the card UID that is highlighted in red. The information is stored in the memory that is divided into segments and blocks as you can see in the previous picture.

RC522 MINI

RC522 MINI is a mini version of the MFRC522 chip. Its core functions are the same as MFRC522. It supports the 13.56MHz frequency band and protocols such as ISO/IEC 14443 A. Because of its smaller size, it is more suitable for small devices and embedded scenarios with limited space. Performance parameters such as card reading distance and communication mode are similar to the standard version, but may be slightly inferior to the standard version due to antenna design limitations.

MFRC522 mini

FIFO Buffer Introduction

The MFRC522 has a 64×8-bit FIFO buffer. It’s used to buffer the input and output data streams between the host microcontroller and the MFRC522’s internal state machine. So, this FIFO buffer can handle data streams longer than 64 bytes without having to consider timing constraints.

Accessing the FIFO Buffer

The FIFO buffer’s input and output data buses are connected to the FIFODataReg register. When you write to FIFODataReg, it stores a byte of data into the FIFO buffer, and then the internal write pointer of the FIFO buffer goes up by 1. What you read from FIFODataReg is the data at the FIFO buffer’s read pointer, and after that, the read pointer drops by 1. You can get the gap between the read and write pointers of the FIFO buffer by reading FIFOLevelReg.

 

When the microcontroller sends a command, the MFRC522 can access the FIFO buffer as the command requires while executing it. Usually, only one FIFO buffer operation can be done, and this buffer works for both input and output. So the microcontroller has to be careful not to access the FIFO buffer in other ways.

Controlling the FIFO Buffer

Besides reading from and writing to the FIFO buffer, you can also reset the FIFO buffer pointers by setting the FlushBuffer bit in the FIFOLevelReg register. Doing this clears the FIFOLevel bit, clears the BufcrOvi bit in the ErrorReg register, makes the actually stored bytes inaccessible, and lets the FIFO buffer be used to store the next batch of 64-byte data.

FAQs

Can MFRC522 read NFC?

MFRC522 can read NFC tags conforming to the ISO/IEC 14443 A standard and NFC devices in card simulation mode, but does not support NFC peer-to-peer communication.

How to check if a card is RFID or NFC?

You can distinguish by checking the card frequency (RFID includes 125kHz and many others, NFC is only 13.56MHz) and functions (NFC supports device-to-device transmission, ordinary RFID cards do not). You can also try to touch it with the mobile phone’s NFC function. Those that can be identified and interacted with are mostly NFC-related cards, otherwise they may be ordinary RFID cards.

Is MIFARE a NFC or RFID card?

MIFARE is a brand series under RFID (Radio Frequency Identification) technology, owned by NXP Semiconductors. These products run on 13.56MHz frequency . Some MIFARE products meet the relevant standards for NFC, so they can interact with NFC-enabled devices. Basically, they are part of RFID technology.

Can i scan RFID with NFC?

Whether NFC can scan RFID depends on the frequency and standard of RFID

Leave a Reply

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