Home / How To's / Using RFID with Raspberry Pi Zero

Using RFID with Raspberry Pi Zero

Using RFID cards and tags is a cool way to switch on anything, wirelessly. For example, you can create an e-lock for your room, check meeting attendance or use cards to control your robot. In this tutorial, we will add RFID functions to a Raspberry Pi Zero.

For this tutorial, I will be using the Mifare RC522 module shown:

The module comes with one RFID card and one tag plus some male headers. I decided to use to bent headers.

This module has eight pins:

As you can see by the names of the pins, this RC522 module can be interfaced using UART, I2C or SPI. I will be using SPI in this tutorial.

Enabling Raspberry Pi SPI

First, you need to enable SPI for your Raspberry Pi Zero. SSH to your Pi or use VNC and open the termina. Go to configuration settings via

Select Interfacing Options then SPI. Select Yes when prompted. After that, reboot your Pi:

Once your Raspberry Pi turns on again, do the following steps if indeed SPI is now on:
Open config.txt

Find this line:

If it’s there, then your SPI interface is on.

Installing RFID Software

Next, install Python 2.7 dev using:

Then download and install the special SPI tool for python:

Lastly, download this handy python library for using the RC522 module:

That’s it! Use this wiring diagram to connect the RC522 to your Raspberry Pi Zero:

Raspberry Pi Zero RFID

Name Pin # Pin name
IRQ None None
GND Any Any Ground
3.3V 1 3V3

To read a card or tag, just use the Read.py script. For example,

Everytime you tap your card or tag, their UID and other information will show on the terminal. Here's what shown on mine:

Raspberry Pi RFID Screenshot

A Mifare card has 1k or 4k EEPROM which means it can store data. For example, a 1k card has 16 sectors with 4 blocks each. Each block can store 16 bytes. For now, we will be only reading the UID for identification.  We can save this unique UID to an sql database and create a login or attendance system.

Check Also

Arduino Relay module

Arduino Relay Module Tutorial

A relay is commonly used to interface a low-current circuit to a higher-current circuit. As …

Leave a Reply

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