How To Connect RFID Reader RC522 To Arduino

Table of contents:

How To Connect RFID Reader RC522 To Arduino
How To Connect RFID Reader RC522 To Arduino

Video: How To Connect RFID Reader RC522 To Arduino

Video: How To Connect RFID Reader RC522 To Arduino
Video: How to use RFID reader RC522 with arduino easy way 2024, May
Anonim

In this article, we will look at the connection of an RC522 RFID card reader and keyfobs operating at a frequency of 13.56 MHz.

RFID reader RC522 with card and key fob
RFID reader RC522 with card and key fob

It is necessary

  • - Arduino;
  • - RFID reader RC522;
  • - wireless RFID tag or regular metro / ground transportation ticket;
  • - a computer;
  • - connecting wires.

Instructions

Step 1

The RFID-RC522 module is based on the NXP MFRC522 chip. This microcircuit provides two-way wireless (up to 6 cm) communication at a frequency of 13.56 MHz. RFID is an abbreviation for "Radio Frequency IDentification" and translates to "radio frequency identification".

The MFRC522 microcircuit supports the following connection interfaces:

- SPI (Serial Peripheral Interface, a serial interface for communication of peripheral devices), provides a data transfer rate of up to 10 Mbit / s;

- two-wire I2C interface, speed up to 3400 kbaud in High-speed mode, up to 400 kbaud in Fast mode;

- serial UART (analogue RS232), speed up to 1228, 8 kbaud.

Using this module, you can write and read data from various RFID tags: key fobs from intercoms, plastic pass cards and tickets for metro and ground transport, as well as the increasingly popular NFC tags.

RFID-RC522 Wireless Module
RFID-RC522 Wireless Module

Step 2

Let's connect the RFID-RC522 module to the Arduino via the SPI interface according to the diagram below.

The module is powered by a voltage from 2, 5 to 3, 3 V. We connect the rest of the pins to the Arduino as follows:

RST D9;

SDA (SS) - D10;

MOSI - D11;

MISO - D12;

SCK - D13.

Also remember that the Arduino has a dedicated ICSP header for SPI operation. Its pinout is also shown in the illustration. You can connect the RST, SCK, MISO, MOSI and GND pins of the RC522 module to the ICSP connector on the Arduino.

RFID-RC522 SPI connection diagram
RFID-RC522 SPI connection diagram

Step 3

The MFRC522 microcircuit has quite extensive functionality. You can get acquainted with all the possibilities by studying her passport (datasheet). To get acquainted with the capabilities of this device, we will use one of the ready-made libraries written for the Arduino to work with the RC522. At the end of the article, you can find a link to one of the libraries called rfid. Download it and unpack it to% Arduino IDE% / libraries / directory.

Installing the library
Installing the library

Step 4

Now let's open the example sketch: File -> Samples -> MFRC522 -> DumpInfo and load it into Arduino memory. This sketch determines the type of device attached to the reader and reads the data written on the RFID tag or card, and then outputs it to the serial port. The text of the sketch is well commented by the developers of the "rfid" library, and a lot of useful information on working with the library is contained in the MFRC522.h file.

Sketch for reading information recorded on an RFID tag
Sketch for reading information recorded on an RFID tag

Step 5

Launch the serial port monitor by pressing Ctrl + Shift + M, through the Tools menu or by clicking the magnifying glass button. Now let's attach a metro ticket or any other RFID tag to the reader. The serial port monitor will show the data recorded on the RFID tag or ticket. For example, in my case, a unique ticket number, date of purchase, expiration date, number of remaining trips, as well as service information are encrypted here. We will analyze in one of the future articles what is written on the maps of the metro and ground transport.

Recommended: