Freenove RFID-RC522 User manual

1RFID█www.freenove.com
RFID Freenove RFID-RC522 Module
Now, we will learn to use the RFID (Radio Frequency Identification) wireless communication technology.
Project 1 Read UID
In this project, we will read the unique ID number (UID) of the RFID card, recognize the type of the RFID card
and display the information through serial port.
Component List
Freenove UNO x1 RC522 RFID Module x1
Mifare1 S50 Standard card x1 Mifare1 S50 Non-standard card x1
USB able x1 Jumper F/M x7

2
RFID www.freenove.com █
Circuit knowledge
RFID
RFID (Radio Frequency Identification) is a wireless communication technology. A complete RFID system is
generally composed of the responder and reader. Generally, we use tags as responders, and each tag has a
unique code, which is attached to the object to identify the target object. The reader is a device for reading
(or writing) tag information.
Products derived from RFID technology can be divided into three categories: passive RFID products, active
RFID products and semi active RFID products. And Passive RFID products are the earliest, the most mature
and most widely used products in the market among others. It can be seen everywhere in our daily life such
as, the bus card, dining card, bank card, hotel access cards, etc., and all of these belong to close-range contact
recognition. The main operating frequency of Passive RFID products are: 125KHZ (low frequency), 13.56MHZ
(high frequency), 433MHZ (ultrahigh frequency), 915MHZ (ultrahigh frequency). Active and semi active RFID
products work at higher frequencies.
The RFID module we use is a passive RFID product with the operating frequency of 13.56MHz.
Component Knowledge
MFRC522 RFID Module
The MFRC522 is a highly integrated reader/writer IC for contactless communication at 13.56MHz.
The MFRC522's internal transmitter is able to drive a reader/writer antenna designed to communicate with
ISO/IEC 14443 A/MIFARE cards and transponders without additional active circuitry. The receiver module
provides a robust and efficient implementation for demodulating and decoding signals from ISO/IEC 14443
A/MIFARE compatible cards and transponders. The digital module manages the complete ISO/IEC 14443A
framing and error detection (parity and CRC) functionality.
This RFID Module uses MFRC522 as the control chip, and SPI (Peripheral Interface Serial) as the reserved
interface.

3
RFID█www.freenove.com
RC522 RFID Module Technical specs:
Working Voltage
3.3V
Working current
13 ~ 26mA
Idle current
10 ~ 13mA
Sleep current
< 80uA
Peak current
< 30mA
Working frequency
13.56MHz
Supported Card type
Mifare1 S50, Mifare1 S70, Mifare UltraLight, Mifare Pro, Mifare Desfire
Operating temperature
-20 ~ 80 degrees Celsius
Storage temperature
-40 ~ 85 degrees Celsius
Relative humidity
5% ~ 95%
Module interface
SPI
Data transmission speed
10M bit/s at maximum
Length
60 mm
Width
40 mm
Weight
20 g
Mifare1 S50 Card
Mifare1 S50 is often called Mifare Standard with the capacity of 1K bytes. And each card has a 4-bytes global
unique identifier number (USN/UID), which can be rewritten 100 thousand times and read infinite times. Its
storage period can last for 10 years. The ordinary Mifare1 S50 Card and non-standard Mifare1 S50 Card
equipped for this kit are shown below.
Mifare1 S50 Standard card Mifare1 S50 Non-standard card
The Mifare1 S50 capacity (1K byte) is divided into 16 sectors (Sector0-Sector15). Each sector contains 4 data
block (Block0-Block3. 64 blocks of 16 sectors will be numbered according absolute address, from 0 to 63).
And each block contains 16 bytes (Byte0-Byte15), 64*16=1024. As is shown in the following table:
Sector No.
Block No.
Storage area
Block type
Absolute block No.
sector 0
block 0
vendor code
vendor block
0
block 1
data block
1
block 2
data block
2
block 3
Password A-access control-password B
control block
3

4
RFID www.freenove.com █
sector 1
block 0
data block
4
block 1
data block
5
block 2
data block
6
block 3
Password A-access control-password B
control block
7
……
……
……
……
sector 0
block 0
data block
60
block 1
data block
61
block 2
data block
62
block 3
Password A-access control-password B
control block
63
Each sector has a set of independent password and access control which are put in the last block of each
sector, and the block is also known as sector trailer, that is Block 3 in each sector. Sector 0, block 0 (namely
absolute address 0) of S50 is used to store the vendor code, which has been solidified and can ’t be changed,
and the card serial number is stored here. In addition to the manufacturer and the control block, the rest of
the cards are data blocks, which can be used to store data. Data block can be used for two kinds of applications:
(1) used as general data storage and can be operated for reading and writing.
(2) used as data value, and can be operated for initializing the value, adding value, subtracting and reading
the value.
The sector trailer block in each sector is the control block, including a 6-byte password A, 4-byte access
control and 6-byte password B. For example, the control block of a brand new card is as follows:
A0 A1 A2 A3 A4 A5
FF 07 80 69
B0 B1 B2 B3 B4 B5
password A
access control
password B
The default password of a brand new card is generally A0A1A2A3A4A5 for password A, B0B1B2B3B4B5 for
password B, or both the password A and password B are 6 FF. Access control is used to set the access
conditions for each block (including the control block itself) in a sector.
Blocks of S50 are divided into data blocks and control blocks. There are four operations, "read", "write", "add
value", "subtract value (including transmission and storage)" for data blocks, and there are two operations,
"read" and "write" for control blocks.
For more details about how to set data blocks and control blocks, please refer to Datasheet.
By default, after verifying password A or password B, we can do reading or writing operation to data blocks.
And after verifying password A, we can do reading or writing operation to control blocks. But password A can
never be read. If you choose to verify password A and then you forget the password A, the block will never
be able to read again. It is highly recommended that beginners should not try to change the contents of
control blocks.

5
RFID█www.freenove.com
Circuit
The connection of Freenove UNO board and RFID module is shown below.
Schematic diagram
Hardware connection

6
RFID www.freenove.com █
Sketch
Sketch 1
Before writing the code, we need import the library RFID.zip first.
This sketch will read the unique ID number (UID) of the card, recognize the type of the card and display the
information through serial port.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <SPI.h>
#include <RFID.h>
//D10:pin of card reader SDA. D9:pin of card reader RST
RFID rfid(10,9);
unsigned char status;
unsigned char str[MAX_LEN]; //MAX_LEN is 16: size of the array
void setup()
{
Serial.begin(9600);
SPI.begin();
rfid.init(); //initialization
Serial.println("Please put the card to the induction area...");
}
void loop()
{
//Search card, return card types
if (rfid.findCard(PICC_REQIDL,str)== MI_OK){
Serial.println("Find the card!");
// Show card type
ShowCardType(str);
//Anti-collision detection, read card serial number
if (rfid.anticoll(str)== MI_OK){
Serial.print("The card's number is : ");
//Display card serial number
for (int i =0;i <4;i++) {
Serial.print(0x0F &(str[i]>> 4), HEX);
Serial.print(0x0F &str[i], HEX);
}
Serial.println("");
}
//card selection (lock card to prevent redundant read, removing the line will make
the sketch read cards continually)
rfid.selectTag(str);
}

7
RFID█www.freenove.com
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
rfid.halt(); // command the card to enter sleeping state
}
void ShowCardType(unsigned char *type)
{
Serial.print("Card type: ");
if (type[0]== 0x04 && type[1]== 0x00)
Serial.println("MFOne-S50");
else if (type[0]== 0x02 && type[1]== 0x00)
Serial.println("MFOne-S70");
else if (type[0]== 0x44 && type[1]== 0x00)
Serial.println("MF-UltraLight");
else if (type[0]== 0x08 && type[1]== 0x00)
Serial.println("MF-Pro");
else if (type[0]== 0x44 && type[1]== 0x03)
Serial.println("MF Desire");
else
Serial.println("Unknown");
}
After including the RFID library, we need to construct a RFID class object before using the function in RFID
library. Its constructor needs to be written to two pins, respectively to the SDA pin and the RST pin.
5
RFID rfid(10,9);
In setup, initialize the serial port, SPI and RFID.
11
12
13
Serial.begin(9600);
SPI.begin();
rfid.init(); //initialization
In loop (), use .findCard () waiting for the card approaching. Once it detects card contact, this function will
return MI_OK and save the card type data in parameter str. Then enter the if statement.
20
if (rfid.findCard(PICC_REQIDL,str)== MI_OK){
After entering if statement, call the sub function ShowCardType(). Then determine the type of the card
according to the content of STR and print the type out through the serial port.
23
ShowCardType(str);
Then use the.anticoll() to read UID of the card and use serial port to print it out.
25
26
27
28
29
30
31
32
33
if (rfid.anticoll(str)== MI_OK){
Serial.print("The card's number is : ");
//Display card serial number
for (int i =0;i <4;i++) {
Serial.print(0x0F &(str[i]>> 4), HEX);
Serial.print(0x0F &str[i], HEX);
}
Serial.println("");
}

8
RFID www.freenove.com █
After verifying and uploading the code to UNO, open the serial port monitor and make a card approach the
sensing area of RFID module. Then serial port monitoring window will display the displacement ID number
and the type of the card. If the induction time is too short, it may lead to incomplete-information display.

FCC Statement
This device complies with part 15 of the FCC rules. Operation is subject to the following two conditions: (1) thi
s device may not cause harmful interference, and (2) this device must accept any interference received, incl
uding interference that may cause undesired operation.
Changes or modifications not expressly approved by the party responsible for compliance could void the user’
s authority to operate the equipment.
NOTE: This equipment has been tested and found to comply with the limits for a Class B digital device, pursua
nt to part 15 of the FCC Rules. These limits are designed to provide reasonable protection against harmful inte
rference in a residential installation. This equipment generates uses and can radiate radio frequency energy a
nd, if not installed and used in accordance with the instructions, may cause harmful interference to radio com
munications. However, there is no guarantee that interference will not occur in a particular installation. If this
equipment does cause harmful interference to radio or television reception, which can be determined by turn
ing the equipment off and on, the user is encouraged to try to correct the interference by one or more of the
following measures:
‐Reorient or relocate the receivingantenna.
‐Increase the separation between the equipment andreceiver.
‐Connect the equipment into an outlet on a circuit different from that to which the receiver is connected.
‐Consult the dealer or an experienced radio/TV technician for help important announcement
Important Note:
Radiation Exposure Statement
This equipment complies with FCC radiation exposure limits set forth for an uncontrolled environment. This
equipment should be installed and operated with minimum distance 0cm between the radiator and your
body.
This transmitter must not be co-located or operating in conjunction with any other antenna or transmitter.
Country Code selection feature to be disabled for products marketed to the US/Canada.
This device is intended only for OEM integrators under the following conditions:
1. The antenna must be installed such that 0 cm is maintained between the antenna and users,and
2. The transmitter module may not be co-located with any other transmitter orantenna,
As long as the three conditions above are met, further transmitter testing will not be required. However, the
OEM integrator is still responsible for testing their end-product for any additional compliance requirements
required with this module installed.
Important Note:
In the event that these conditions cannot be met (for example certain laptop configurations or co-location
with another transmitter), then the FCC authorization is no longer considered valid and the FCC ID cannot be
used on the final product. In these circumstances, the OEM integrator will be responsible for re-evaluating the
end product (including the transmitter) and obtaining a separate FCC authorization.
End Product Labeling
The final end product must be labeled in a visible area with the following" Contains FCC ID: 2A4TN-FN-RFID-
RC522"
Manual Information to the End User
The OEM integrator has to be aware not to provide information to the end user regarding how to install or
remove this RF module in the user’s manual of the end product which integrates this module.
The end user manual shall include all required regulatory information/warning as show in this manual.

Integration instructions for host product manufacturers according to KDB 996369 D03 OEM
Manual v01
2.2
List of applicable FCC rules
CFR 47 FCC PART 15 SUBPART C has been investigated. It is applicable to the modular transmitter
2.3
Specific operational use conditions
This module is stand-alone modular. If the end product will involve the Multiple simultaneously transmitting condition or different
operational conditions for a stand-alone modular transmitter in a host, host manufacturer have to consult with module manufacturer
for the installation method in end system.
2.4
Limited module procedures
Not applicable
2.5
Trace antenna designs
Not applicable
2.6
RF exposure considerations
This equipment complies with FCC radiation exposure limits set forth for an uncontrolled environment. This equipment should be
installed and operated with minimum distance 20cm between the radiator & your body.
2.7
Antennas
This radio transmitter FCC ID:2A4TN-FN-RFID-RC522 has been approved by Federal Communications Commission to operate
with the
antenna types listed below, with the maximum permissible gain indicated. Antenna types not included in this list that have a gain
greater than the maximum gain indicated for any type listed are strictly prohibited for use with this device.
Antenna No.
Model No. of
antenna:
Type of antenna:
Gain of the antenna (Max.)
Frequency range:
NFC
/
Loop Antenna
0dBi for 13.56MHz;
2.8
Label and compliance information
The final end product must be labeled in a visible area with the following" Contains FCC ID: 2A4TN-FN-RFID-RC522".
2.9
Information on test modes and additional testing requirements
Host manufacturer is strongly recommended to confirm compliance with FCC requirements for the transmitter when the module is
installed in the host.
2.10
Additional testing, Part 15 Subpart B disclaimer
Host manufacturer is responsible for compliance of the host system with module installed with all other applicable requirements for
the system such as Part 15 B.

ISED Statement
‐English: This device complies with Industry Canada license‐exempt RSS standard(s).
Operation is subject to the following two conditions: (1) This device may not cause interference, a
nd (2) This device must accept any interference, including interference that may cause undesired
operation of the device.
The digital apparatus complies with Canadian CAN ICES‐3 (B)/NMB‐3(B).
‐French: Le présentappareilestconforme aux CNR d'Industrie Canada applicables aux appareils
radio exempts de licence. L'exploitationestautorisée aux deux conditions suivantes: (1) l'appareil
ne doit pas produire de brouillage, et (2) l'utilisateur de l'appareildoit accepter tout brouillageradi
oélectriquesubi, mêmesi le brouillageest susceptible d'encompromettre le fonctionnement.
l'appareil numérique du ciem conforme canadien peut ‐ 3 (b) / nmb ‐ 3 (b).
This device meets the exemption from the routine evaluation limits in section 2.5 of RSS 102 and
compliance with RSS 102 RF exposure, users can obtain Canadian information on RF exposure
and compliance.
cet appareil est conforme à l'exemption des limites d'évaluation courante dans la section 2.5 du
cnr - 102 et conformité avec rss 102 de l'exposition aux rf, les utilisateurs peuvent obtenir des
données canadiennes sur l'exposition aux champs rf et la conformité.
This equipment complies with Canada radiation exposure limits set forth for an uncontrolled
environment.
Cet équipement est conforme Canada limites d'exposition aux radiations dans un environnement
non contrôlé.
This equipment should be installed and operated with minimum distance 0cm between the
radiator & your body.
Cet équipementdoit être installé et utilisé à une distance minimale de 0 cm entre le radiateur et
votre corps.
ISED Modular Usage Statement
NOTE 1: When the ISED certification number is not visible when the module is installed inside
another device, then the outside of the device into which the module is installed must also
display a label referring to the enclosed module. This exterior label can use the
wording ”Contains transmitter module IC: 28247-FNRFIDRC522” or “Contains IC: 28247-
FNRFIDRC522”.
NOTE 1: Lorsque le numéro de certification ISED n'est pas visible lorsque le module est installé
dans un autre appareil, l'extérieur de l'appareil dans lequel le module est installé doit également
afficher une étiquette faisant référence au module inclus. Cette étiquetteextérieure peut être
libellée Contient le module émetteur IC: 28247-FNRFIDRC522 ou Contient IC: 28247-FNRFIDRC522.
Table of contents