RC522 are cheap RFID modules that can be used to read and write data on Mifare tags. The microcontroller and the module uses SPI for communication. The modules (card reader) and the RFID tags communicate using a 13.56MHz electromagnetic field. In this post, we are going to show you how to read RFID tags with an Arduino and RC522 module.
We need a few things to build our system:
- Arduino Nano (We bought a cheap one from eBay)
- RC522 RFID reader with 2 tag off GearBest for £1.89
- Dupont Wire Jumper Cables
- LCD screen
Software Setup and Arduino Code
To get started, we could write our own library for the RC522 module based on the command specified in the RC522 datasheet. However, Bjarte Johansen has kindly written and publicly distributed an Arduino library for the RC522 available at: https://github.com/ljos/MFRC522
To install the library in the Arduino IDE, place the MFRC522 folder from ljos GitHub in the Arduino IDE library, located in the IDE installation location. The MFRC522 folder should contain MFRC522.cpp, MFRC522.h and the example folder. More example code based on Bjarte Johansen library can be found at: https://github.com/miguelbalboa/rfid
The examples in the RC522 library should be visible the Arduino IDE if you have installed it properly.
To get started, hookup your RC522 to the Arduino as shown in the figure below and upload Bjarte Johansen “auth_read_write.ino” code.
Open Serial Monitor and wave a tag over the reader. You should see the Tag serial no and the content of the tag’s blocks:
We modified the code to display the Tag’s serial number on the LCD:
The modified code can be downloaded here: auth_read_write_rfid_mod
Thanks for reading this post and watch out for our next post on how to write data to the RFID Tag. Email us at firstname.lastname@example.org for comments and questions.