RC522 RFID Module is a 13.56MHz reader and writer, it has SPI communication which allows it to work easily with most microcontrollers. It uses a modulation and demodulation system for all types of 13.56MHz passive RFID devices. The device handles ISO14443-A and supports the Quick CRYPTO1 and MIFARE encryption algorithm. Compatible with Arduino , Pic , Raspberry Pi and more.
SPECIFICATIONS AND FEATURES
Operating frequency: 13.56Mhz
Communication protocol: SPI
Maximum data rate: 10Mbit/s
Supply voltage: 3.3V
Operating current: 13-26mA
Maximum current: 30mA
Reading distance: 0 to 60mm
Supported card types: Mifare1 S50, Mifare1 S70, MIFARE Ultralight, Mifare Pro, Mifare DESFire.
Operating temperature: -20 to 80ºC
Quiescent/stand by current (Isb): 10-13mA at 3.3V
Current in sleep-mode (Ism): <80uA
Includes pins, keychain and card
Dimensions: 40x60mm
Total weight: 20g
RFID Tag Card
Type: RFID Card
Frequency: 13.56 MHz
Protocol: ISO/IEC 14443 Type A
Baud: 106kbps
Read/write range: 0~5cm (approx.)
EEPROM: 1K Bytes
4 Byte Unique Identifier
Reading time: 100ms
Write cycles: 100,000
Dimensions: 86mm x 54mm x 1mm
White color
Material: PVC
RFID Keychain Tag
Type: RFID Tag Keychain
Frequency: 13.56MHz
Material: ABS/PVC
EEPROM: 1K Bytes
Read/Write Range: 0~5cm (Approx. Depends on reader)
Protocol: ISO14443A
4 Byte Unique Identifier
Baud: 106 kbs
What is RFID technology
It is also commonly used as a product identification system, somewhat like a barcode, but instead of using an image and an RFID scanner it uses radio frequency waves to communicate data and can store more information than a barcode and also increases its security because it is not easy to duplicate.
How does the SPI communication protocol work
The acronym comes from Serial Peripherial Interface (SPI) is a synchronous serial communication protocol, meaning that the two devices share a clock signal that allows them to synchronize their reading and writing of messages to avoid errors in data reception.
Each device connected to the bus can act as a transmitter and receiver at the same time, so this type of serial communication is full duplex.
In this communication protocol, the devices take one of the following two roles, Master or Slave, and if necessary, a master can connect more than one Slave to its data bus.
This protocol makes use of two shift registers, one that contains the data to be transmitted/received and one that stores it.
Communication occurs through 4 logical lines
MOSI (Master Out Slave In): Takes the bits that come from the master to the slave.
MISO (Master In Slave Out): Takes the bits that come from the slave to the master.
CLK (Clock): Clock signal from the master and is responsible for synchronizing the devices.
SS (Slave Select): Line responsible for selecting and enabling a slave
(The slave is activated only when this line is selected, generally a line is dedicated for each slave)
A) INSTALLATION OF THE BOOKCASE
For the following program, the SPI libraries are used for communication, and MFRC522, which contains specific processes of the RDFI-RC55 module, which you can install by entering the Tools tab, selecting Manage Libraries, and then Library Manager, where you can search by name the library and it will give you the status of the library, if it is not installed, the install option will appear on the right side.
B) CODE
Below we present a simple code that obtains and displays the ID code of the Card or Tag on the serial port when it is detected.
//Libraries to be able to use the RDFI-RC522 and the SP I communication protocol #include < SPI .h> #include < MFRC522 .h> #defineRST_PIN 5// RDFI-RC522 pin to Pin 5 #defineSS_PIN 10/ / RDFI-RC522 Pin to Pin 10
MFRC522
mfrc522(SS_PIN, RST_PIN); // Creating instance for RFID byte i; //variable, array element for reading data by the reader byte datoUID[4]; //array to store values returned by the detector void setup () { Serial .begin (9600); // Initialize SPI serial communication .begin (); // Initiation of communication via SPI mfrc522 bus. PCD_Init (); // initialization of MFRC522 Serial .println (F( "Place card to scan" )); //message to user } } void loop () { if (! mfrc522. PICC_IsNewCardPresent ()) // We check if new cards are present return; if (! mfrc522. PICC_ReadCardSerial ()) // Read the value of the presented ID return; Serial.print ( " UID:" ); //The ID data is saved for ( byte i = 0; i < mfrc522.uid.size; i++) { if (mfrc522.uid.uidByte[i] < 0x10) { //limiting the reading of the values in the 10-digit hexadecimal array Serial .print ("0"); } else { Serial .print (""); } //prints in Monitor Serial, the value read by the detector Serial.print (mfrc522.uid.uidByte[i], HEX ); dataUID[i]= mfrc522.uid.uidByte[i]; //The values are saved in the UID data variable } mfrc522. PICC_HaltA (); //RFID library command to end the current reading }