ESP32 + RFID RC522 + OLED Project

ESP32 + RFID RC522 + OLED Project | Smart Access System for Kids
Kids' Robotics Lab

Build a Smart RFID Tap-to-Unlock System

Tap a card near the reader and watch the OLED screen say hello. This project uses an ESP32, an RC522 RFID reader, and a tiny OLED screen to build your very own smart access-card system.

RC522
CARD
UID: 3F A2 9C 10 ✔ ACCESS OK

Mission Overview

How does an RFID access system work?

Every RFID card has a tiny chip and antenna hidden inside it. When you hold the card near the reader, they "talk" to each other using radio waves — no wires, no touching contacts needed.

💳Tap card
Hold the card close to the RC522 reader.
📡Reader reads UID
RC522 picks up the card's unique ID number.
🧠ESP32 checks it
Compares the UID to your list of allowed cards.
🖥️OLED shows result
Displays the UID and "Access Granted" or "Denied."

Shopping List

Parts you'll need

This is a compact, beginner-friendly build with just three main modules.

1
ESP32 dev boardThe brain of the project — reads the card and controls the screen.
2
RC522 RFID reader moduleDetects nearby RFID cards or key-tags over radio waves.
3
0.96" OLED display (SSD1306, I2C)Shows the card's UID and whether access is granted.
4
RFID cards or key-tagsComes with most RC522 kits — used to test scanning.
5
Breadboard + jumper wiresFor connecting everything without soldering.
6
Micro-USB cablePowers the ESP32 and uploads your code.

Wiring Guide

Circuit connections

The RC522 talks to the ESP32 over SPI and the OLED talks over I2C — two different, but both very common, communication styles.

RC522 PinESP32 PinPurpose
SDA (SS)GPIO 5Chip select
SCKGPIO 18Clock signal
MOSIGPIO 23Data to reader
MISOGPIO 19Data from reader
RSTGPIO 4Reset line
3.3V3.3VPower (never use 5V!)
GNDGNDCommon ground
OLED PinESP32 PinPurpose
VCC3.3VPower
GNDGNDCommon ground
SCLGPIO 22I2C clock
SDAGPIO 21I2C data
ESP32 GPIO5 → RC522 SDA GPIO18 → RC522 SCK GPIO23 → RC522 MOSI GPIO19 → RC522 MISO GPIO4 → RC522 RST GPIO21/22 → OLED SDA/SCL 3.3V / GND → Power both RC522 (SPI) SDA · SCK · MOSI MISO · RST 3.3V only — no 5V! OLED (I2C) SDA · SCL VCC 3.3V · GND Micro-USB 5V power in

The ESP32 talks to the RC522 over SPI and to the OLED over I2C at the same time — two separate buses, one microcontroller.

Build Log

Step-by-step build instructions

Set up your breadboard

Place the ESP32 on one side of the breadboard so you have room to wire the RC522 and OLED next to it.

Wire the RC522 reader

Connect SDA, SCK, MOSI, MISO, and RST to the ESP32 pins shown in the wiring table, then power it from 3.3V — never 5V, or you may damage the module.

Wire the OLED display

Connect SDA and SCL to GPIO 21 and GPIO 22, then power it from 3.3V and GND, sharing the same ground as the RC522.

Install the libraries

In the Arduino IDE, install MFRC522, Adafruit_GFX, and Adafruit_SSD1306 from the Library Manager.

Upload the code

Copy the sketch from the next section, select your ESP32 board, and upload it over USB.

Scan a card

Open the Serial Monitor, hold a card near the reader, and note down the UID it prints — you'll add this to your "allowed" list.

Test access granted / denied

Scan the same card again to see "Access Granted" on the OLED, then try a different card to see "Access Denied."

Code Room

Arduino code for ESP32 + RC522 + OLED

This sketch reads a card's UID, shows it on the OLED, and checks it against one allowed UID stored in the code.

rfid_oled.ino
// Smart RFID Access System — ESP32 + RC522 + OLED
// Libraries: MFRC522, Adafruit_GFX, Adafruit_SSD1306

#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// ---- RC522 pins ----
#define SS_PIN   5
#define RST_PIN  4
MFRC522 rfid(SS_PIN, RST_PIN);

// ---- OLED setup ----
#define SCREEN_WIDTH  128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// ---- One allowed card UID (change to your own!) ----
String allowedUID = "3FA29C10";

void setup() {
  Serial.begin(115200);
  SPI.begin();
  rfid.PCD_Init();

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0, 20);
  display.println("Tap your card...");
  display.display();
}

void loop() {
  // wait for a new card
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
    return;
  }

  // build the UID string, e.g. "3FA29C10"
  String uid = "";
  for (byte i = 0; i < rfid.uid.size; i++) {
    if (rfid.uid.uidByte[i] < 0x10) uid += "0";
    uid += String(rfid.uid.uidByte[i], HEX);
  }
  uid.toUpperCase();
  Serial.println("Card UID: " + uid);

  // show the result on the OLED
  display.clearDisplay();
  display.setCursor(0, 0);
  display.print("UID: ");
  display.println(uid);

  display.setCursor(0, 30);
  if (uid == allowedUID) {
    display.println("ACCESS GRANTED");
  } else {
    display.println("ACCESS DENIED");
  }
  display.display();

  rfid.PICC_HaltA();
  delay(1500);
}

Tip: run the sketch once, scan your card, and copy the UID printed in the Serial Monitor into the allowedUID line — that's how you "register" a new card.

Important Notes

Safety and good practice

Adult supervision recommended. Wiring, uploading code, and using a breadboard are safe for kids, but it's good to build alongside a parent, teacher, or mentor, especially the first time.

Watch the voltage. The RC522 module runs on 3.3V only — connecting it to 5V can permanently damage it, so always double-check your wiring before powering on.

Use it responsibly. This project is great for learning how real access-card systems work, like at school gates or office doors — build and test it on your own devices and never try to scan or copy someone else's card without permission.

Quick Answers

Frequently asked questions

What is RFID and how does it work?

RFID stands for Radio-Frequency Identification. A small chip and antenna inside the card wake up when they get close to a reader's radio field, then send back a unique ID number — all without any physical contact.

What's the difference between SPI and I2C?

Both are ways for a microcontroller to talk to small chips. SPI (used by the RC522) uses four wires and is very fast. I2C (used by the OLED) uses just two wires and can connect several devices on the same two lines.

Is this project okay for beginners?

Yes! It only needs a breadboard and jumper wires — no soldering required — and the libraries handle the tricky parts of talking to the RFID reader and the screen.

Can I store more than one allowed card?

Yes. Once you're comfortable with the basic code, you can replace the single allowedUID with a small list (an array) of UID strings and check the scanned card against all of them.

What else can I build with an RC522 and OLED?

The same parts make a great school attendance tracker, a library book check-out system, a locker access system, or a simple vending-machine style "credit" counter.

Built for curious young makers 🛠️ — Kids' Robotics Lab
Always build and test with an adult. Have fun and stay safe!

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course