Interfacing of RFID RC522 with Arduino UNO

In this tutorial we will learn How to interface Arduino UNO with RC522 RF ID Reader using Arduino library for MFRC522 and other RFID RC522 based modules.

This library read and write different types of Radio-Frequency IDentification (RFID) cards on your Arduino or NodeMCU using a RC522 based reader connected via the Serial Peripheral Interface (SPI) interface. Before we move to actual code lets know more about RF ID.

RF ID Reader MFRC-522
RF ID Reader

What is RFID?

Radio-Frequency Identification (RFID) is the use of radio waves to read and capture information stored on a tag attached to an object. A tag can be read from up to several feet away and does not need to be within direct line-of-sight of the reader to be tracked. This is the advantage over Bar-code.

A RFID reader is a device used to gather information from an RFID tag, which is used to track individual objects. Radio waves are used to transfer data from the tag to a reader.

A passive tag is an RFID tag that does not contain a battery, the power is supplied by the reader. When radio waves from the reader are encountered by a passive rfid tag, the coiled antenna within the tag forms a magnetic field. The tag draws power from it, energizing the circuits in the tag.

What are the RC52 RF ID Reader Specifications?

RC522 – RFID Reader / Writer 13.56MHz with Cards Kit includes a 13.56MHz RF reader cum writer module that uses an RC522 IC and two S50 RFID cards. The MF RC522 is a highly integrated transmission module for contact-less communication at 13.56 MHz. RC522 supports ISO 14443A/MIFARE mode.

RC522 – RFID Reader features an outstanding modulation and demodulation algorithm to serve effortless RF communication at 13.56 MHz. The S50 RFID Cards will ease up the process helping you to learn and add the 13.56 MHz RF transition to your project.

The module uses SPI to communicate with microcontrollers. The open-hardware community already has a lot of projects exploiting the RC522 – RFID Communication, using Arduino.

RC522 – RFID Reader / Writer Features:

  • Integrated MF RC522
  • 13.56MHz contactless communication card chip.
  • Low-voltage, low-cost, small size of the non-contact card chip to read and write.
  • Suitable for Smart meters and portable handheld devices.
  • Advanced modulation and demodulation concept completely integrated in all types of 13.56MHz passive contactless communication methods and protocols.
  • 14443A compatible transponder signals.
  • ISO14443A frames and error detection.
  • Supports rapid CRYPTO1 encryption algorithm, terminology validation MIFARE products.
  • MFRC522 support MIFARE series of high-speed non-contact communication, two-way data transmission rate up to 424kbit/s.
  • Low cost, and ideal for user equipment development.
  • The reader and RF card terminal design meets advanced applications development and production needs.
  • Can be directly loaded into the various reader molds, very convenient.

RC522 – RFID Reader / Writer Specifications:

  • Operating Current :13-26mA / DC 3.3V
  • Idle Current :10-13mA / DC 3.3V
  • Sleep Current: < 80uA
  • Peak Current: < 30mA
  • Operating Frequency: 13.56MHz
  • Supported card types: mifare1 S50, mifare1 S70 MIFARE Ultralight, mifare Pro, MIFARE DESFire
  • Environmental Operating Temperature: -20 – 80 degrees Celsius
  • Environmental Storage Temperature: -40 – 85 degrees Celsius
  • Relative humidity: relative humidity 5% – 95%
  • Reader Distance: ≥ 50mm / 1.95″ (mifare 1)
  • Module Size: 40mm × 60mm
  • Module interface: SPI
  • Data transfer rate: Maximum 10Mbit/s

Hardware Components

  • Arduino UNO
  • MFRC522 RFID Reader
  • RFID Tags ( 13.56 MHz )
  • Bread Board
  • Jumper Wires
  • Micro USB Cable

Software Components

  • Arduino IDE

Connections of MFRC522 RF ID Reader With Arduino UNO

RF ID Reader Arduino Interface
Circuit Diagram

Arduino Code for MFRC522 RF ID Reader

For this program we need RF ID Library Download it from here.rfid-master

Upload Sketch to NodeMCU and test it.

Results and Testing

Open serial monitor with baud rate settings of 9600. and move card near to the card Reader module. Observe serial monitor. It will show UID for that card.

RC522 NodeMCU Reader

Additional resources

Troubleshooting

 

  • I don’t get input from reader or WARNING: Communication failure, is the MFRC522 properly connected?
    1. Check your physical connection.
    2. Check your pin settings/variables in the code, see Pin Layout .
    3. Check your pin header soldering. Maybe you have cold solder joints.
    4. Check voltage. Most breakouts work with 3.3V.
    5. SPI only works with 3.3V, most breakouts seem 5V tollerant, but try a level shifter.
    6. SPI does not like long connections. Try shorter connections.
    7. SPI does not like prototyping boards. Try soldered connections.
  • Sometimes I get timeouts or sometimes tag/card does not work.
    1. Try the other side of the antenna.
    2. Try to decrease the distance between the MFRC522 and your tag.
    3. Increase the antenna gain per firmware: mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);
    4. Use better power supply.
    5. Hardware may be corrupted, most products are from china and sometimes the quality is really poor. Contact your seller.
  • My tag/card doesn’t work.
    1. Distance between antenna and token too large (>1cm).
    2. You got the wrong type PICC. Is it really 13.56 MHz? Is it really a Mifare Type A?
    3. NFC tokens are not supported. Some may work.
    4. Animal RFID tags are not supported. They use a different frequency (125 kHz).
    5. Hardware may be corrupted, most products are from china and sometimes the quality is really poor. Contact your seller.
    6. Some boards bought from chinese manufactures do not use the best components and this can affect the detection of different types of tag/card. In some of these boards, the L1 and L2 inductors do not have a high enough current so the signal generated is not enough to get Ultralight C and NTAG203 tags to work, replacing those with same inductance (2.2uH) but higher operating current inductors should make things work smoothly. Also, in some of those boards the harmonic and matching circuit needs to be tuned, for this replace C4 and C5 with 33pf capacitors and you are all set.
  • My mobile phone doesn’t recognize the MFRC522 or my MFRC522 can’t read data from other MFRC522
    1. Card simmulation is not supported.
    2. Communication with mobile phones is not supported.
    3. Peer to peer communication is not supported.
  • I can only read the card UID.
    1. Maybe the AccessBits have been accidentally set and now an unknown password is set. This can not be reverted.
    2. Probably the card is encrypted. Especially official cards like public transport, university or library cards. There is no way to get access with this library.

 

Leave a Reply