Module – RC522 – RFID/NFC transciever



Informatie (ENG)

The RC522 RFID module based on MFRC522 IC from NXP is one of the most inexpensive RFID options that you can get online for less than four dollars. It usually comes with a RFID card tag and key fob tag having 1KB memory. And best of all, it can write a tag, so you can store your some sort of secret message in it.

The RC522 RFID Reader module is designed to create a 13.56MHz electromagnetic field that it uses to communicate with the RFID tags (ISO 14443A standard tags). The reader can communicate with a microcontroller over a 4-pin Serial Peripheral Interface (SPI) with a maximum data rate of 10Mbps. It also supports communication over I2C and UART protocols.

The module comes with an interrupt pin. It is handy because instead of constantly asking the RFID module “is there a card in view yet? “, the module will alert us when a tag comes into its vicinity.

The operating voltage of the module is from 2.5 to 3.3V, but the good news is that the logic pins are 5-volt tolerant, so we can easily connect it to an Arduino or any 5V logic microcontroller without using any logic level converter.

Here are complete specifications:

Frequency Range 13.56 MHz ISM Band
Host Interface SPI / I2C / UART
Operating Supply Voltage 2.5 V to 3.3 V
Max. Operating Current 13-26mA
Min. Current(Power down) 10µA
Logic Inputs 5V Tolerant
Read Range 5 cm


VCC supplies power for the module. This can be anywhere from 2.5 to 3.3 volts. You can connect it to 3.3V output from your Arduino. Remember connecting it to 5V pin will likely destroy your module!

RST is an input for Reset and power-down. When this pin goes low, hard power-down is enabled. This turns off all internal current sinks including the oscillator and the input pins are disconnected from the outside world. On the rising edge, the module is reset.

GND is the Ground Pin and needs to be connected to GND pin on the Arduino.

IRQ is an interrupt pin that can alert the microcontroller when RFID tag comes into its vicinity.

MISO / SCL / Tx pin acts as Master-In-Slave-Out when SPI interface is enabled, acts as serial clock when I2C interface is enabled and acts as serial data output when UART interface is enabled.

MOSI (Master Out Slave In) is SPI input to the RC522 module.

SCK (Serial Clock) accepts clock pulses provided by the SPI bus Master i.e. Arduino.

SS / SDA / Rx pin acts as Signal input when SPI interface is enabled, acts as serial data when I2C interface is enabled and acts as serial data input when UART interface is enabled. This pin is usually marked by encasing the pin in a square so it can be used as a reference for identifying the other pins.


Sluit de module aan volgens onderstaand overzicht:

Pin Wiring to Arduino Uno
SDA Digital 10
SCK Digital 13
MOSI Digital 11
MISO Digital 12
IRQ unconnected
RST Digital 9
3.3V 3.3V

Script met bibliotheek

Wat heb je nodig?

1) RFID library here created by miguelbalboa

Example script from the library

Het resultaat NTAG chip

Het resultaat Mifare chip 1KB

Script with specific UID access


Arduino Library

Installatie van Arduino IDE libraries: Arduino info

Arduino library for MFRC522 and other RFID RC522 based modules.

Read and write different types of Radio-Frequency IDentification (RFID) cards on your Arduino using a RC522 based reader connected via the Serial Peripheral Interface (SPI) interface.

What works and not?

  • Works
    1. Communication (Crypto1) with MIFARE Classic (1k, 4k, Mini).
    2. Communication (Crypto1) with MIFARE Classic compatible PICCs.
    3. Firmware self check of MFRC522.
    4. Set the UID, write to sector 0, and unbrick Chinese UID changeable MIFARE cards.
    5. Manage the SPI chip select pin (aka SS, SDA)
  • Works partially
    1. Communication with MIFARE Ultralight.
    2. Other PICCs (Ntag216).
    3. More than 2 modules, require a multiplexer #191.
  • Doesn’t work
    1. MIFARE DESFire, MIFARE DESFire EV1/EV2, not supported by software.
    2. Communication with 3DES or AES, not supported by software.
    3. Peer-to-peer (ISO/IEC 18092), not supported by hardware.
    4. Communication with smart phone, not supported by hardware.
    5. Card emulation, not supported by hardware.
    6. Use of IRQ pin. But there is a proof-of-concept example.
    7. With Intel Galileo (Gen2) see #310, not supported by software.
    8. Power reduction modes #269, not supported by software.
    9. I2C instead of SPI #240, not supported by software.
    10. UART instead of SPI #281, not supported by software.
  • Need more?
    1. If software: code it and make a pull request.
    2. If hardware: buy a more expensive like PN532 (supports NFC and many more, but costs about $15 and not usable with this library).


There are three hardware components involved:

  1. Micro Controller:
  • An Arduino or compatible executing the Sketch using this library.
  • Prices vary from USD 7 for clones, to USD 75 for “starter kits” (which might be a good choice if this is your first exposure to Arduino; check if such kit already includes the Arduino, Reader, and some Tags).
  1. Proximity Coupling Device (PCD):
  • The PCD is the actual RFID Reader based on the NXP MFRC522 Contactless Reader Integrated Circuit.
  • Readers can be found on eBay for around USD 5: search for “rc522”.
  • You can also find them on several web stores. They are often included in “starter kits”, so check your favourite electronics provider as well.
  1. Proximity Integrated Circuit Card (PICC):
  • The PICC is the RFID Card or Tag using the ISO/IEC 14443A interface, for example Mifare or NTAG203.
  • One or two might be included with the Reader or “starter kit” already.


  1. The micro controller and the reader use SPI for communication.
  • The protocol is described in the NXP MFRC522 datasheet.
  • See the Pin Layout section for details on connecting the pins.
  1. The reader and the tags communicate using a 13.56 MHz electromagnetic field.
  • The protocol is defined in ISO/IEC 14443-3:2011 Part 3 Type A.
    • Details are found in chapter 6 “Type A – Initialization and anticollision”.
    • See for a free version of the final draft (which might be outdated in some areas).
    • The reader does not support ISO/IEC 14443-3 Type B.


  • The UID of a card can not be used as an unique identification for security related projects. Some Chinese cards allow to change the UID which means you can easily clone a card. For projects like access controldoor opener or payment systems you must implement an additional security mechanism like a password or normal key.
  • This library only supports crypto1-encrypted communication. Crypto1 has been known as broken for a few years, so it does NOT offer ANY security, it is virtually unencrypted communication. Do not use it for any security related applications!
  • This library does not offer 3DES or AES authentication used by cards like the Mifare DESFire, it may be possible to be implemented because the datasheet says there is support. We hope for pull requests :).

Download bibliotheek @


Raspberry Pi

Sluit de module aan volgens onderstaand overzicht:

RFID pin RPI pin Functie Kabel
SDA 24 CE0 Groen
SCK 23 SCLK Blauw
Gnd 6 Gnd Zwart
RST 22 GPIO 25 Bruin
3.3V 1 3.3V Rood

SPI activeren

Voor de communicatie met de RFID lezer maken we gebruik we de SPI interface, deze dien je via raspi-config te activeren.

Ga in het menu naar ‘Advanced Options’, selecteer de optie ‘SPI’ en activeer de interface.

Herstart hierna je Raspberry Pi:

SPI Python libraries

Voordat Python met de SPI interface en RFID lezer kan communiceren hebben we een aantal Python libraries nodig, alleerst de Python Developer library.

Hierna gaan we SPI-Py downloaden vanaf GitHub:

Nadat library is gecloond vanaf GitHub moeten we SPI-Py toevoegen aan Python:

Python script voor de RC522 RFID lezer

We hebben nu via Python toegang tot de SPI interface. Als laatste hebben we een script nodig dat de tags kan uitlezen, hiervoor maken we gebruik van MFRC522-python. Download het script vanaf GitHub:

Ga naar de map (MFRC522-python) waarin de GitHub bestanden zijn geplaatst:

Gebruikt het script om de tags te lezen:


Raspberry Pi Library

SPI-Py: Hardware SPI as a C Extension for Python

COPYRIGHT (C) 2012 Louis Thiery. All rights reserved. Further work by Connor Wolf.

Forked in 2019 by Nathan Leefer to fix memory handling in the C extension.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License V2 as published by the Free Software Foundation.

This program is distributed for educational purposes only and is no way suitable for any particular application, especially commercial. There is no implied suitability so use at your own risk!


  1. Clone or download this repository, navigate to the SPI-Py directory, and install the library using the following command. Use python3 if installing for Python 3.

  1. Make sure the SPI interface is enabled for your Raspberry Pi. This can be done using the raspi-config utility.

  1. This module provides three functions for communicating with SPI devices:

The next section covers these in detail.

Example usage

The below commands can be found in the file.

After installing the library, import the spi module to your Python code via :

Open the file descriptor to the SPI device with one of two chip selects:

The device keyword can be either “/dev/spidev0.0” or “/dev/spidev0.1”. The difference refers to which chip select pin is used by the SPI device driver. The mode keyword can be 0,1,2, or 3, and many SPI devices can operate up to 8000000 Hz speed, however it is recommended to check your data sheet. See the Raspberry Pi docs for a detailed explanation of these and other parameters.

Use the returned device handle to conduct an SPI transaction

The above would write the 3 bytes contained in data_out and copy the received data to data_in. Note that data_in will always be a tuple the same length as data_out, and will simply reflect the state of the MISO pin throughout the transaction. It is up to the user to understand the device behavior connected to the SPI pins.

To verify that this works connect GPIO 10 (MOSI, physical pin 19) to GPIO 9 (MISO, physical pin 21) in a loop back. You should see that data_out now equals data_in.

Close the file descriptor for your SPI device

Memory leak

The script continuously executes a simple transaction on /dev/spidev0.0. There does not appear to be a memory leak in this use case.

Download @