목차
RFID 리더기
저가의 RFID 리더기입니다. MFRC522 칩을 사용한 리더기로 MIFARE RFID 카드를 읽고 쓸수 있습니다.

WAT-Arduino128 예제
부품 목록
| 번호 | 부품명 | 수량 | 기능 | 판매처 |
|---|---|---|---|---|
| 1 | WAT-Arduino128 | 1 | 아두이노 | https://kit128.com/goods/view?no=64 |
| 2 | RFID-RC522 | 1 | RFID 리더기 | https://kit128.com/goods/view?no=83 |
| 3 | RFID TAG | 1 | RFID CARD | https://kit128.com/goods/view?no=84 |
| WAT-Arduino128 | RFID 리더기 | RFID TAG |
|---|---|---|
|
|
|
|
핀 연결
아래와 같이 RFID 리더기와 WAT-Arduino128 핀을 연결합니다.
| RFID 리더기 핀 | WAT-Arduino128 핀 |
|---|---|
| SDA | PB0 (SS) |
| SCK | PB1 (SCK) |
| MOSI | PB2 (MOSI) |
| MISO | PB3 (MISO) |
| GND | GND |
| RESET | PB4 |
| 3.3V | 3.3V |

소스코드
소스코드는 [파일]=>[예제]=>[rfid_master] =>[DumpInfo] 에 있습니다.
/*
RFID-RC522로 받은 데이터를 화면에 출력하는 예제
부품
. WAT-Arduino128 : https://kit128.com/goods/view?no=64
. RFID-RC522 : https://kit128.com/goods/view?no=83
연결
WAT-Arduino128 RFID-RC522
-------------------------------------------------
PB0 SPI SS SDA
PB1 SPI SCK SCK
PB2 SPI MOSI MOSI
PB3 SPI MISO MISO
PB4 SPI RESET RST
*/
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN PB4 //
#define SS_PIN PB0 //
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(115200);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, type, and data blocks..."));
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
void ShowReaderDetails() {
// Get the MFRC522 software version
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print(F("MFRC522 Software Version: 0x"));
Serial.print(v, HEX);
if (v == 0x91)
Serial.print(F(" = v1.0"));
else if (v == 0x92)
Serial.print(F(" = v2.0"));
else
Serial.print(F(" (unknown)"));
Serial.println("");
// When 0x00 or 0xFF is returned, communication probably failed
if ((v == 0x00) || (v == 0xFF)) {
Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
}
}
결과
RFID CARD ID (예: B5 07 F6 07)를 보여주고 1K에 대한 정보를 출력합니다.



