The RFID-RC522 is a highly integrated reader/writer module for contactless communication at 13.56 MHz. This module is based on the MFRC522 integrated circuit and is commonly used for RFID (Radio Frequency Identification) applications such as access control, attendance systems, and asset tracking. It supports ISO/IEC 14443A/MIFARE protocols, making it versatile for a wide range of RFID solutions.
Pin Name | Description |
---|---|
SDA | Serial Data Signal (SPI SS) |
SCK | Serial Clock Signal (SPI SCK) |
MOSI | Master Out Slave In (SPI MOSI) |
MISO | Master In Slave Out (SPI MISO) |
IRQ | Interrupt Request (optional use) |
GND | Ground |
RST | Reset Signal |
3.3V | Supply Voltage |
To use the RFID-RC522 module in a circuit:
#include <SPI.h>
#include <MFRC522.h>
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println(F("Scan PICC to see UID and type..."));
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
delay(50);
return;
}
// Show some details of the PICC (that is: the tag/card)
Serial.print(F("Card UID:"));
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
// Additional card information can be included here
// Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
}
Q: Can the RFID-RC522 module be used with a 5V system? A: The RFID-RC522 operates at 3.3V. A level shifter should be used when interfacing with a 5V system to avoid damaging the module.
Q: How can I increase the read range of the module? A: The read range can be affected by the antenna design, tag type, and environmental factors. Ensure optimal antenna design and placement, and use high-quality tags.
Q: What should I do if the module is not detecting any tags? A: Check the power supply, connections, and ensure that the SPI communication is functioning correctly. Also, verify that the tags are compatible and not damaged.
For further assistance, consult the MFRC522 datasheet and the manufacturer's resources.