กลับหน้าหลัก
views
How to Use ESP8266 with RFID RC522 13.56MHz Module
Last updated on

How to Use ESP8266 with RFID RC522 13.56MHz Module


How to Use ESP8266 with RFID RC522 13.56MHz Module

This tutorial covers wiring NodeMCU ESP8266 with the RFID RC522 13.56MHz module to read card UID values. Suitable for door lock systems or attendance tracking projects.

Required Components

  • NodeMCU ESP8266 V2 (CP2102)
  • RFID RC522 13.56MHz module
  • Micro USB cable for computer connection
  • Breadboard 830 points
  • Jumper wires (M-M, M-F, F-F)
  • RFID card or key tag supporting 13.56MHz

Circuit Wiring ESP8266 to RC522

Circuit diagram showing wiring between NodeMCU ESP8266 and RFID RC522 on breadboard

Connect wires according to the table below

ESP8266RC522
3V33V3
GNDGND
D0RST
D8SDA
D7MOSI
D6MISO
D5SCK

Note: RC522 uses SPI communication, so connect ESP8266 SPI pins correctly.

Install MFRC522 Library

  1. Open Arduino IDE
  2. Go to Sketch > Include Library > Manage Libraries
  3. Search for “MFRC522”
  4. Click Install on MFRC522 by GithubCommunity
Arduino IDE Library Manager showing MFRC522 search results

Code to Read RFID Card UID

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

// Define pins connected to RC522
#define SDA_PIN  D8    // GPIO15
#define RST_PIN  D0    // GPIO16

MFRC522 rfid(SDA_PIN, RST_PIN);

void setup() {
  Serial.begin(115200);
  SPI.begin();           // Start SPI communication
  rfid.PCD_Init();       // Initialize RC522
  Serial.println("ESP8266 + RFID RC522 Ready");
  Serial.println("Tap card or key tag to read UID");
}

void loop() {
  // Check for new card presence
  if (!rfid.PICC_IsNewCardPresent()) {
    return;
  }
  
  // Read card data
  if (!rfid.PICC_ReadCardSerial()) {
    return;
  }
  
  // Print UID value
  Serial.print("UID: ");
  for (byte i = 0; i < rfid.uid.size; i++) {
    Serial.print(rfid.uid.uidByte[i], HEX);
    Serial.print(" ");
  }
  Serial.println();
  
  // Stop reading card
  rfid.PICC_HaltA();
}

Upload and Test Steps

  1. Open Serial Monitor in Arduino IDE
  2. Change baud rate to 115200
  3. Place RFID card or key tag near the RC522 module
  4. Observe the UID value displayed on Serial Monitor
Serial Monitor window showing RFID card UID output

Reference Video

Summary

Using ESP8266 with RC522 is straightforward. Just connect SPI pins correctly, install the library, and upload the code. Each card has a unique UID that you can use to build authorized card checking logic for your projects.

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ประเมินราคาอัตโนมัติ + Reference Code

ขอให้ AI ประเมินราคาโปรเจคนี้

กรอกข้อมูลให้ครบ ระบบจะสร้างรหัสอ้างอิงและประเมินราคา/ระยะเวลาคร่าว ๆ จากรายละเอียดงาน แล้วให้กด Add LINE พร้อมพิมพ์รหัสนี้เพื่อคุยต่อ

คำถามให้ AI ประเมินแม่นขึ้น

หลังส่งฟอร์ม ระบบจะโชว์ Reference Code ให้ copy แล้วกด Add LINE เพื่อคุยต่อ ข้อมูลส่วนตัวจะไม่ถูกส่งเข้า GA4

ความคิดเห็น

รีวิวจากคนใช้งานจริง

รีวิวจากลูกค้าและคนที่เคยใช้งาน

ถ้าเคยสั่งงาน เคยอ่านหน้านี้แล้วได้ประโยชน์ หรือมีข้อเสนอแนะ ฝากรีวิวไว้ได้เลย

กำลังโหลดรีวิว...