CODE | Simple RFID Reader - Arduino Project 044

RonWang2 years ago (2024-10-07)电子编程 COD62

Arduino Programming Basic -- Making an RFID Reader

Advanced RFID with Arduino

RFID (Radio Frequency Identification) technology enables wireless communication between a reader and tags for identification and data exchange. Using Arduino with RFID modules like the RC522 allows for building advanced projects such as access control systems, attendance tracking, and inventory management.

Overview of RFID with Arduino

The RFID system consists of a reader (e.g., RC522 module) and tags (passive or active). The RC522 operates at 13.56 MHz and supports SPI, I2C, and UART communication protocols, though SPI is most commonly used with Arduino. Tags store data and transmit it back to the reader when energized by its electromagnetic field.

Key Features of RC522 Module

  • Communication Protocols: SPI (up to 10 Mbps), I2C, UART.

  • Voltage: Operates at 3.3V but has 5V-tolerant pins.

  • Range: Typically 2-5 cm for standard tags.

Applications

 Reading/writing data, UID detection, and authentication.

Project 44 Simple RFID Reader

Arduino RFID RC522

Wiring Diagram Between RC522 and Arduino without voltage regulator

Arduino RFID RC522 Resistor

Wiring Diagram Between RC522 and Arduino with voltage regulator

As Circuit in the wiring diagram above, 1kOhM and 2kOhm pair of resistors are used to regulate 5V to 3.3V. It does not need to adjust the voltage between the Arduino pin and the MISO pin of the RC522 module. However, it is necessary to regulate the voltage between the Arduino pins and the SS, SCK, MOSI, and RST pins of the RC522 module.

// Project 44  Simple RFID Reader   Arduino-RFID-NFC

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 5

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin(); // init SPI bus
  rfid.PCD_Init(); // init MFRC522

  Serial.println("Tap RFID/NFC Tag on 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 NUID 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
    }
  }
}
Share with Friends:

Related Articles

Series and Parallel resistors

Series and Parallel resistors

Two-terminal components and electrical networks can be connected in series or parallel. The resultin…

Electric and Sensor Control System

Electric and Sensor Control System

Since 2022, the founder of Autaba EC deparrment has devoted to the research and development of advan…

CODE | LED Blink - Arduino Project 001

CODE | LED Blink - Arduino Project 001

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 1 LED闪烁,基本的应用Project 3和4红绿灯项目Project 1 …

CODE | LED Traffic Light - Arduino Project 003

CODE | LED Traffic Light - Arduino Project 003

You are now going to create a set of traffic lights that will change from green to red, via amber, a…

Pelles C Install and Debug runtime Enviroment

Pelles C Install and Debug runtime Enviroment

C语言调试运行环境之TurboC一文介绍了在32位Windows系统下安装C语言运行环境之TubroC,但是由于TurobC只能在32位系统下运行,导致现在很多Windows10和Windows 11…

DIY - Monochrome Light Cube Maker Introduction Step by Step

DIY - Monochrome Light Cube Maker Introduction Step by Step

First, let's take a look at the complete welded diagram (the shell needs to be purchased separat…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.