The RFID Module MIFARE RC522 is an easy to use and low cost RFID Module perfect to pair up with Arduino and any microcontroller. Using RFID you can create automatic ID system door lock, attendance logging, data transaction and many others.
RFID stands for Radio-Frequency-Identification. It uses radio frequency carrier to send and receive data from the reader and the RFID-tag with special ID code (for RFID: UID codes). This RFID uses the SPI communication protocol. It operates at 13.56 MHz and the kit includes 2 kinds of ID tags in card and keychain form. Each tag represents its own unique UID codes which we use to represent any object or person to represent.
- Module Name: MF522-ED
- Working current：13—26mA/ DC 3.3V
- Standby current：10-13mA/DC 3.3V
- sleeping current：<80uA
- peak current：<30mA
- Working frequency：13.56MHz
- Card reading distance ：0～60mm（mifare1 card）
- data communication speed：Maximum 10Mbit/s
- Card types supported：mifare1 S50, mifare1 S70, mifare UltraLight,mifare Pro, mifare Desfire
- Working temperature：-20—80 degree
- Storage temperature：-40—85 degree
- Humidity：relevant humidity 5%—95%
- Max SPI speed: 10Mbit/s
For this quickstart guide, we will need the following materials:
The image below shows the pin assignment of the RFID module.
Preparing the Arduino Circuit
The RFID Module comes withmale headers but unsoldered into the PCB, you may need to solder the male header first and connect the wires with the Arduino.
Now connect the RFID module and Arduino with the wiring below.
The Arduino and the RFID module connects together with the SPI pins and uses SPI communication protocol. Review your connection from below.
Arduino Reset PIN 9 to RFID Module PIN RST
Arduino SPI PIN SS 10 to RFID Module PIN SDA
Arduino SPI PIN MOSI 11 to RFID Module PIN MOSI
Arduino SPI PIN MISO 12 to RFID Module PIN MISO
Arduino SPI PIN SCK 13 to RFID Module PIN SCK
Arduino PIN VCC (3.3V) to RFID Module PIN VCC (3.3V)
Arduino PIN GND to RFID Module PIN GND
Arduino connected to RFID RC522 Module
Project Circuit with Arduino, RFID Module and RFID key card and keychain tags
Download the rfid Arduino library, un-zip/extract the folder rfid and paste it to your Arduino libraries folder.
In our case our Arduino software files and libraries are in Disk C:/arduino-1.6.9/libraries/”paste_library_here”. Close and reopen your Arduino IDE in order for the new Arduino library rfid be used.
Now the needed Arduino rfid library source code are installed let’s run an example code in reading RFID key tags
Download the Arduino RFID MiFARERC522 Example Code. Unzip/extract the folder rfid-mifarerc522 and find the Arduino code file rfid-mifarerc522.ino. Open the file and copy the code to your Arduino IDE which you placed the rfid library earlier. If you have multiple Arduino IDE versions make sure to use the correct version where you placed the rfid folder. (Example: if you are using Arduino IDE 1.8.8 to code, the rfid folder earlier should be pasted in the Program Files/…/Arduino/libraries/rfid or arduino-1.8.8/libraries/rfid“)
An overview of the Arduino code below.
Now your circuit and your code is ready. Compile and upload the Arduino code above to your Arduino board. Let’s take a look out the output in the next page.
When done uploading open your Arduino Serial Monitor. Check that you are at 9600 baud rate. When you open the Serial Monitor you will be prompt to approximate/place your RFID tags near the RFID reader module.
We still don’t know the RFID code of each key card/tag you have. To know the code place each rfid tag/card near the RFID board.
a) You will get a UID tag code – this is the code of the RFID tag that you placed.
b) You will also get a Message: Access denied. That’s okay since for now we only need to get the RFID tag code
Now we know the code of each rfid tags we have. You can add more tags if you like. Also you may attach a tape and label for you to know the code of each tags.
Example: here we have 4 different RFID tags: 2 key cards and 2 coin key chain. The 4 have different Unique ID codes. The MiFare RFID module comes with 1 keycoin tag and one white plastic ID tag. You may get other color of keycoin like yellow and red and more RFID keycard tag.
In our code we assigned the code 6D 8F 30 5B to “Authorized Access” and all other RFID tags with different ID’s will go to “Access Denied”. One of the white key cards above holds the ID 6D 8F 30 5B.
Our Arduino code will read all the RFID tags that will be placed in the reader and will display the tag’s ID code in the Serial Monitor. It will also display if the RFID tag you placed is Authorized access or Access denied.
Placing first the 3 tags with different ID code will display its individual tag codes and will display an “Access denied” message.
Placing the 4th and correct key tag in the RFID reader module will display it’s tag ID code: 6D 8F 30 5B and an “Authorized access” message.
Now you may integrate this RFID circuit example you have for your existing project. From here start creating an attendance or logging system for your home or in your hackerspace or school. You may also use it for hobby door lock RFID security access system and try to add some additional security or backup feature. You may also try and integrate a keypad feature or a door sensor which you can also get these parts in the shop.
Here are some project links you can use for implementing the RFID module:
Applications and References
07172019 – additional and updated content