MFRC5C522 is a combined reader and writer for RFID tags that comply with ISO/IEC 14443 like A/MIFARE and NTAG. The commonly available inexpensive boards have an SPI interface, we will make it talk with Explore M3 in this tutorial.
Hookup
The default SPI interface for Explore M3 is mapped to SPI1 of the controller. It simply means whenever you're interfacing an SPI device you used use these pins and functions like SPI.begin() will use these pins.
Explore M3 | MFRC522 Breakout | Description | |
---|---|---|---|
10 | MOSI | Master Out Slave In | |
11 | MISO | Master In Slave Out | |
12 | SCK | Serial Clock | |
13 | SDA | This is wrongly labelled, this should have been SS | |
5 | RESET | SPI reset signal |
Code
The Card that came with the board had 1KB of memory. It was divided into 16 blocks of 64 bytes of memory. Each block is in-turn arranged as 4 locations of 64 bytes. We will use the Arduino RFID Library for MFRC522 which has all the functions you'll ever need. The code reads the card and dumps the memory map. There are several other examples that come with the library to read/write the card etc.,
Demo
Credits
A big thanks to Miguel for writing beautiful library with various examples right from dumping card info to reading and writing data to it.