EasyManuals Logo

Freenove RFID-RC522 User Manual

Freenove RFID-RC522
11 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #7 background imageLoading...
Page #7 background image
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("");
}

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove RFID-RC522 and is the answer not in the manual?

Freenove RFID-RC522 Specifications

General IconGeneral
BrandFreenove
ModelRFID-RC522
CategoryRfid Systems
LanguageEnglish