RFID,NFC Module(RC522): 두 판 사이의 차이

아두위키 : Arduwiki
(Created page with "{{#seo:|title=아두위키 : 아두이노 RFID, NFC 모듈(RC522) 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, RFID, NFC 모듈(RC522), 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 RFID, NFC 모듈(RC522)을 제어하는 방법(기본정보, 회로, 예제 코드)을 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}} File:RC522.jpg|center|class=co...")
 
잔글편집 요약 없음
4번째 줄: 4번째 줄:


It can be used with Arduino and Raspberry Pi boards.
It can be used with Arduino and Raspberry Pi boards.


== '''Specifications''' ==
== '''Specifications''' ==
11번째 줄: 12번째 줄:
* Interface: SPI
* Interface: SPI
* Operating Frequency: 13.56MHz
* Operating Frequency: 13.56MHz


== '''Hardware''' ==
== '''Hardware''' ==
17번째 줄: 19번째 줄:
* RC522, NFC card/key
* RC522, NFC card/key
* Jumper cables
* Jumper cables


== '''Connection''' ==
== '''Connection''' ==
52번째 줄: 55번째 줄:


=== [[Arduino Libraries]] ===
=== [[Arduino Libraries]] ===


== '''Example Code''' ==
== '''Example Code''' ==
88번째 줄: 92번째 줄:


</syntaxhighlight>
</syntaxhighlight>


=== Execution Result ===
=== Execution Result ===
[[File:RC522 실행결과.png|center|class=coders100]]
[[File:RC522 실행결과.png|center|class=coders100]]

2025년 3월 21일 (금) 16:55 판

This is an RFID reader utilizing NFC communication method.

It can be used with Arduino and Raspberry Pi boards.


Specifications

  • Operating Voltage: 3.3V
  • Operating Current: 13mA ~ 26mA
  • Interface: SPI
  • Operating Frequency: 13.56MHz


Hardware

  • Arduino
  • RC522, NFC card/key
  • Jumper cables


Connection

RC522 Arduino
3.3V 3.3V
RST 9
GND GND
MISO 12
MOSI 11
SCK 13
SDA 10

Libraries

  • MFRC522 (by GithubCommunity)
  • SPI (default included library)

Arduino Libraries

Example Code

Prints the tagged ID value to the serial monitor.

#include <SPI.h>
#include <MFRC522.h>
 
#define RST_PIN   9                            // Reset pin is set to pin 9
#define SS_PIN    10                           // SS pin is set to pin 10
                                               // SS pin is the pin responsible for data exchange (SS = Slave Selector)
 
MFRC522 mfrc(SS_PIN, RST_PIN);                 // Creating the mfrc object to utilize the MFR522
 
void setup() {
  Serial.begin(9600);                          // Serial communication, baud rate is set to 9600
  SPI.begin();                                 // Initializing SPI
                                               // (SPI: Communication method between one master and multiple slaves)
  mfrc.PCD_Init();                             // Initializing MFRC522
}
 
void loop() {
  if (!mfrc.PICC_IsNewCardPresent() || !mfrc.PICC_ReadCardSerial()) {   
                                               // When no tag is detected or ID is not read
    delay(500);                                // 0.5 second delay
    return;                                    // Return
  } 
    
  Serial.print("Card UID:");                   // Printing the tag's ID
  
  for (byte i = 0; i < 4; i++) {               // Loop to print the tag's ID, up to the tag's ID size (4)
    Serial.print(mfrc.uid.uidByte[i]);        // Printing from mfrc.uid.uidByte[0] to mfrc.uid.uidByte[3]
    Serial.print(" ");                         // Printing space between IDs
  }
  Serial.println(); 
}


Execution Result