Home / Tutorials / Arduino Tutorial / Arduino RFID RC522 Tutorial
Arduino RFID RC522

Arduino RFID RC522 Tutorial

RFID technology has been around for quite a while. But it was only recently that hobbyist and makers was able to utilize this technology through the Mifare RC522 RFID module. In this article, I will show you how you can easily use cards as keys for anything, from attendance systems, to electronic locks and even arcade gaming!

Mifare RC522 RFID Module

Upon purchasing the module, you will have the RFID reader board, an RFID card and tag and two eight-pin headers: one straight and one bent to 90 degrees. Obviously, you need to solder any one of those pins into the eight holes on the reader board. The choice as to which header to use depends on your project.

Here is the pinout of the RFID reader board:

If you have been working with embedded and microcontroller systems, you’ll immediately know that this module works with SPI and I2C. The module runs on 3.3V but thankfully don’t consume too much power so you can just connect it to the Arduino’s power pin.

Building an Arduino RFID Reader

Fortunately, even though the module is powered through 3.3V, the rest of the pins are 5V tolerant. This means, we can just connect the RC522 module directly to an Arduino like this:

The wiring I presented above uses SPI communication rather than I2C. If you want to use I2C, you need to modify the module to make the chip go to I2C mode. This is discussed in the last part of this article.

Arduino RFID Library

The most popular RFID library for Arduino is the one by Miguel Balboa. You can download it in his repository.

After installing the library, you’ll get access to a number of examples via File > Examples > MFRC522.


For our first try, we’ll be using the DumpInfo sketch. Upload this sketch into your Arduino board and then tap your RFID card or tag to the reader. This should be what you’ll see on the serial monitor:


Here you’ll see the contents of your RFID card or tag. The card or tag contains a unique UID and 1 KB of storage space (btw, there are also 4 KB cards available for purchase ). The 1 KB of space is divided into 16 sectors. The sectors are further divided into 4 blocks each with 2 bytes of data.

Reading the UID Only of RFID Card

You can use the UID of the card to identify it! You can modify the included ReadNUID sketch so that only the UID will be displayed every time you tap the card or tag to the RFID reader.

The sketch above will be your starting point if you want to build RFID access or locking/unlocking projects. All you have to do is take note of your card’s UID and then check if the tapped card’s UID matches that of the one you noted.

Using the RFID Card Memory

As mentioned above, the included RFID card contains 1 KB of memory space. We can use that memory to write data into the card. The rfid_write_personal_data sketch demonstrates how you can write your name to the card:

Using I2C to Communicate with RFID Reader

As mentioned above, it is possible to use I2C instead of SPI in communicating with the RC522 RFID reader module. To enable I2C, we must cut the connection of the trace on the board to pin 1 on the IC. This can be done by drilling a hole on a board as shown by user Renate-USB of the Arduino community.

After doing this, the RC522 will enter I2C mode with an address of 0x3C.

Since we’re now using I2C, we need to connect the SDA and SCL pins of the RFID module to the I2C pins of the Arduino UNO:

As for the sketch, we can no longer use Miguel Balboa’s library for I2C. We will now be using arozcan’s RFID library. Here is a sketch that uses this library (credits to Manuauto):

The sketch above is similar to the DumpInfo sketch from Miguel Balboa's library.

The obvious advantage of using I2C over SPI is reduced pin usage.

That’s it! Hopefully, I opened the way for you to build cool Arduino RFID RC522 projects. If you did, kindly place your comments below!

Check Also

Sensor attached to Arduino UNO

Using a Fingerprint Sensor

Fingerprint sensors are old technology but it wasn’t readily available to makers until it was …


  1. I want to run this RFID-RC522 module on I2C with a NANO. Is NANO D3 pin equivalent to the UNO 3 pin?

  2. Can you teach me with vedio tutorial for switching spi to i2c interface rc522 rfid module. I really thanks for this.

  3. Hi, I can't identify on your photo where to cut to allow using I2C on the RFID board.
    Can you draw a circle in the photo so we can be sure where to cut?

Leave a Reply

Your email address will not be published. Required fields are marked *