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
3.3v VCC Power
GND GND The holy ground, do not miss this!

MFRC522 with ExploreM3.jpg

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.,

#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 5 // Configurable, see typical pin layout above
#define SS_PIN 13 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
// delay(5000);
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
Serial.println("in setup");
SPI.begin(); // Init SPI bus
Serial.print("spi intialized");
mfrc522.PCD_Init(); // Init MFRC522
Serial.print("card intialized intialized");
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

Demo

RRID ExploreM3.jpg

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.

Explore M3 Introduction

Explore M3 is a feature rich ARM Cortex M3 development board. It can help you prototype ideas faster with Arduino/mbed and take them be beyond with bare metal programming, RTOS support and lower power...

Arduino Setup for Explore M3

In this tutorial we will look at the basic setups of setting up the ExploreM3 on Arduino and installing DFU and Vcom drivers on Windows, Linux and MAC. Finally we will flash a simple led-blink example...

Led Blink with Explore M3

Blinking an LED is fun for a newbie, a setup test for a Embedded Developer and for this tutorial it getting started with Explore M3 and answering some basic questions like, where did it come from...

Explore M3 Arduino Libraries

Arduino libraries need no introduction. There are numerous devices and peripherals that work with Arduino. This page lists all the libraries that have been tested or ported to Explore M3. ...