Arduino Nano 33 IoT - RFID

This guide shows you how to use the Arduino Nano 33 IoT with the RC522 RFID/NFC reader to get data from an RFID/NFC tag.

Arduino Nano 33 IoT RFID RC522

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×RFID/NFC RC522 Kit (reader + tags)
1×RFID Key Fob
1×RFID Card
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of RFID-RC522 Module

Pinout

RFID-RC522 module Pinout

The RFID-RC522 module has 8 pins. Some pins work for three different communication types: SPI, I2C, and UART. One mode can be used at a time. The pins are:

  • GND pin: Connect this pin to ground (0V).
  • VCC pin: Connect this pin to the power supply (3.3V).
  • RST pin: This pin is used to reset or turn off the device. When the pin is low, the device powers off. When it goes high, the device resets.
  • IRQ pin: This pin sends an alert to the Arduino Nano 33 IoT when an RFID tag comes near.
  • MISO/SCL/TX pin: This pin acts as:
    • MISO if the SPI connection is used.
    • SCL if the I2C connection is used.
    • TX if the UART connection is used.
  • MOSI pin: This pin works as MOSI when using the SPI connection.
  • SCK pin: This pin works as SCK with the SPI connection.
  • SS/SDA/RX pin: This pin works as:
    • SS when the SPI connection is used.
    • SDA when using the I2C connection.
    • RX when using the UART connection.

    ※ NOTE THAT:

    • The order of the pins may be different depending on the manufacturer. Always follow the labels printed on the module. The image above shows the pin layout for modules made by DIYables.
    • The RFID-RC522 module runs on 3.3V. Do not connect its VCC pin to 5V because 5V can damage the module.
    • This guide uses the SPI interface for communication between the Arduino Nano 33 IoT and the RFID-RC522 module.

Wiring Diagram

The wiring diagram between Arduino Nano and 33 IoT RFID RC522

This image is created using Fritzing. Click to enlarge image

The wiring table between RFID/NFC RC522 Module and Arduino Nano 33 IoT

RFID/NFC RC522 Arduino Nano 33 IoT
SS → D10
SCK → D13
MOSI → D11
MISO → D12
IRQ not connected
GNDGND
RST → D5
VCC → 3.3V

Arduino Nano 33 IoT RFID/NFC Code

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-rfid */ #include <SPI.h> #include <MFRC522.h> #define SS_PIN 10 // Arduino Nano 33 IoT pin connected to RC522's SS pin #define RST_PIN 5 // Arduino Nano 33 IoT pin connected to RC522's RST pin MFRC522 rfid(SS_PIN, RST_PIN); void setup() { Serial.begin(9600); SPI.begin(); // init SPI bus rfid.PCD_Init(); // init MFRC522 Serial.println("Tap an RFID/NFC tag on the RFID-RC522 reader"); } void loop() { if (rfid.PICC_IsNewCardPresent()) { // new tag is available if (rfid.PICC_ReadCardSerial()) { // NUID has been readed MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak); Serial.print("RFID/NFC Tag Type: "); Serial.println(rfid.PICC_GetTypeName(piccType)); // print UID in Serial Monitor in the hex format Serial.print("UID:"); for (int i = 0; i < rfid.uid.size; i++) { Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(rfid.uid.uidByte[i], HEX); } Serial.println(); rfid.PICC_HaltA(); // halt PICC rfid.PCD_StopCrypto1(); // stop encryption on PCD } } }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Click the Library Manager icon on the left side of the Arduino IDE screen.
  • Type MFRC522 in the search box and look for the library from GithubCommunity.
  • Click the Install button to add the library.
Arduino Nano 33 IoT MFRC522 library
  • Copy the code above and paste it into the Arduino program.
  • Click the Upload button to check and send the code to your Arduino Nano 33 IoT board.
  • Open the Serial Monitor in the Arduino program to see the output.
How to open serial monitor on Arduino IDE
  • Touch a few RFID or NFC tags on the RFID-RC522 module. Then, look at the Serial Monitor to see the unique tag ID.
COM6
Send
Tap an RFID/NFC tag on the RFID-RC522 reader RFID/NFC tag Type: MIFARE 1KB UID: 2B B8 59 B1 RFID/NFC tag Type: MIFARE Ultralight or Ultralight C UID: 15 75 46 7A 2C 5B 7E
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Video Tutorial

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!