background image

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. 

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

(

""

);

 

    

}

 

Summary of Contents for RFID-RC522

Page 1: ...munication 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 ...

Page 2: ...he 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 I...

Page 3: ...lobal 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 contain...

Page 4: ...ontrol 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 ...

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

Page 6: ... 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 ...

Page 7: ... 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 ente...

Page 8: ...NO 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 ...

Page 9: ...es 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 inten...

Page 10: ...r 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 Mo...

Page 11: ...é 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...

Reviews: