PN532 Arduino Guide: Read NFC Tags, Write NDEF, Build a Door Lock
PN532 Arduino tutorial: I2C, SPI and HSU modes via DIP switch, reading MIFARE and NTAG tags, writing NDEF URLs for phones, RC522 comparison and an ESP32 lock.
Pairing a PN532 with an Arduino is the most versatile way to read NFC tags and RFID cards, write data to them and interact with a smartphone. NXP's PN532 chip understands almost every 13.56 MHz card you will meet: MIFARE Classic office and campus badges, the NTAG213 stickers that phones read, blue key fobs and even some transit cards. Unlike the cheap RC522, the same module talks over I2C, SPI or UART (HSU), and it supports real NFC features such as NDEF messages, card emulation and peer-to-peer mode.
In this guide you will set the mode on the common red PN532 V3 board with its DIP switch, wire it to an Arduino Uno, an ESP32 and a Raspberry Pi Pico, read card UIDs, read MIFARE Classic blocks, write an NDEF URL that a phone opens on tap and build a door lock that unlocks with an NFC tag. A PN532 vs RC522 comparison table helps you pick the right reader for your project.
What is the PN532 and how does it work?
The PN532 is an NFC controller with an 80C51 microcontroller core and a radio front end inside. The copper antenna on the board creates a 13.56 MHz magnetic field; when a card enters that field, its coil harvests energy and the card's chip wakes up. Cards have no battery: they are powered by the reader's field and answer by modulating it. Your Arduino only sends high-level commands such as "find a card", "read this block" or "write this page", while the PN532 handles all radio timing and protocol work. That is why even an Uno with 2 KB of RAM drives it comfortably.
| Feature | Value |
|---|---|
| Chip | NXP PN532 |
| Frequency | 13.56 MHz |
| Card types | ISO 14443A (MIFARE Classic, Ultralight, NTAG2xx, DESFire), ISO 14443B, FeliCa |
| NFC modes | Reader/writer, card emulation, peer-to-peer (ISO 18092) |
| Read range | About 5–7 cm (2–3 cm with small tags) |
| Supply | 3.3–5 V (regulator on the V3 board) |
| Current | About 100–150 mA with RF on |
| Interfaces | I2C (address 0x24), SPI (up to 5 MHz), HSU (115200 baud) |
PN532 vs RC522: which NFC reader should you buy?
| Feature | PN532 | RC522 |
|---|---|---|
| Chip | NXP PN532 | NXP MFRC522 |
| Interface | I2C, SPI, HSU (DIP switch) | SPI only on the module |
| Supply | 3.3–5 V (V3 board) | 3.3 V only |
| Card types | ISO 14443A/B, MIFARE, NTAG, FeliCa | ISO 14443A, MIFARE, NTAG |
| NFC features | NDEF, card emulation, peer-to-peer | None, read/write only |
| Read range | About 5–7 cm | About 2–5 cm |
| Current | 100–150 mA | 13–26 mA |
| Library | Adafruit PN532, Elechouse PN532 + NDEF | MFRC522 |
| Price | Higher | Very cheap |

In short: if all you need is "is this card on my list?", the RC522 is cheap and good enough, and our RFID RC522 guide covers it in detail. If you want phone interaction, NDEF tag writing, a direct I2C connection to a 5 V Arduino, a longer read range or just four wires, the PN532 is clearly the better buy. It can also tell apart up to two cards in the field at once and reads FeliCa cards, which are common in Japan.
Selecting I2C, SPI or HSU with the DIP switch
The two tiny DIP switches in the corner of the PN532 V3 board decide which interface the chip uses. The chip only reads them at power-up, so after changing them you must cut and restore power. If you are new to this, start with I2C: four wires are enough, and the same bus can also carry an OLED display or an RTC.
| Mode | Switch 1 | Switch 2 | When to use it |
|---|---|---|---|
| HSU (UART) | OFF (0) | OFF (0) | Boards with a spare hardware serial port, like ESP32 or Mega |
| I2C | ON (1) | OFF (0) | Easiest: 4 wires, shares the bus with other I2C devices |
| SPI | OFF (0) | ON (1) | Fastest and most robust link, 6 wires |
PN532 wiring: Arduino Uno, ESP32 and Pico
In I2C mode the PN532 address is 0x24 (0x48 in 8-bit notation). It works without the IRQ and RSTO pins connected; the library just asks for two pin numbers in code. RSTO is an output, so never wire it to an Arduino output pin.
| PN532 (I2C) | Arduino Uno | ESP32 | Raspberry Pi Pico |
|---|---|---|---|
| VCC | 5V | 3V3 | 3V3 (pin 36) |
| GND | GND | GND | GND |
| SDA | A4 | GPIO 21 | GP4 |
| SCL | A5 | GPIO 22 | GP5 |
| IRQ (optional) | D2 | GPIO 4 | Not connected |
| RSTO | Not connected | Not connected | Not connected |
| PN532 (SPI / HSU) | Arduino Uno | ESP32 | Raspberry Pi Pico |
|---|---|---|---|
| SCK | D13 | GPIO 18 | GP18 |
| MISO | D12 | GPIO 19 | GP16 |
| MOSI | D11 | GPIO 23 | GP19 |
| SS (NSS) | D10 | GPIO 5 | GP17 |
| HSU: TXD | Not recommended (Mega: RX1 19) | GPIO 16 (RX2) | GP1 (UART0 RX) |
| HSU: RXD | Not recommended (Mega: TX1 18) | GPIO 17 (TX2) | GP0 (UART0 TX) |
SPI is the fastest and most robust option, and the first thing to try if I2C gives you trouble on an ESP32. HSU (UART) mode needs an unused hardware serial port: the Uno's only port is taken by USB, so skip HSU there, but it is ideal on the ESP32's Serial2 or the Mega's Serial1. In HSU the board's TXD goes to the microcontroller's RX and RXD to TX. The differences between the buses are explained in our I2C, SPI and UART guides.
Installing the library and reading a card UID
- Set the DIP switch to I2C (1: ON, 2: OFF) and wire the module as in the table above.
- In the Arduino IDE open the Library Manager, search for Adafruit PN532 and install it; accept Adafruit BusIO when it asks about dependencies.
- Upload the sketch below and open the Serial Monitor at 115200 baud.
- You should see PN532 and a firmware version (usually 1.6); then hold a card over the centre of the antenna.
1#include <Wire.h>
2#include <Adafruit_PN532.h>
3
4#define PN532_IRQ 2 // bağlanması şart değil / optional wire
5#define PN532_RESET 3 // boş kalabilir, RSTO'ya bağlama / may stay unconnected, do not wire to RSTO
6
7Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET); // I2C modu (A4 SDA, A5 SCL) / I2C mode
8
9void setup() {
10 Serial.begin(115200);
11 nfc.begin();
12 uint32_t version = nfc.getFirmwareVersion();
13 if (!version) {
14 Serial.println(F("PN532 bulunamadi / PN532 not found"));
15 while (1) delay(10);
16 }
17 Serial.print(F("Yonga / Chip: PN5"));
18 Serial.println((version >> 24) & 0xFF, HEX);
19 Serial.print(F("Yazilim / Firmware: "));
20 Serial.print((version >> 16) & 0xFF);
21 Serial.print('.');
22 Serial.println((version >> 8) & 0xFF);
23 nfc.SAMConfig(); // normal okuma modu / normal reader mode
24 Serial.println(F("Karti yaklastir / Tap a card"));
25}
26
27void loop() {
28 uint8_t uid[7];
29 uint8_t uidLength;
30 // 500 ms kart ara, sonsuza dek bekleme / search for 500 ms, never block forever
31 if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 500)) {
32 Serial.print(F("UID ("));
33 Serial.print(uidLength);
34 Serial.print(F(" bayt / bytes): "));
35 for (uint8_t i = 0; i < uidLength; i++) {
36 if (uid[i] < 0x10) Serial.print('0');
37 Serial.print(uid[i], HEX);
38 Serial.print(' ');
39 }
40 Serial.println();
41 if (uidLength == 4) Serial.println(F("MIFARE Classic olabilir / likely MIFARE Classic"));
42 else Serial.println(F("NTAG / Ultralight olabilir / likely NTAG / Ultralight"));
43 delay(1000);
44 }
45}readPassiveTargetID searches for a card for 500 ms and, if one appears, fills in its UID and length. A 4-byte UID usually means MIFARE Classic, while 7 bytes points to NTAG or Ultralight tags. Without a timeout the call blocks until a card shows up and everything else in loop stops, so always pass a short timeout in real projects. Wrapping fixed strings in F() saves the Uno's limited RAM.
MIFARE Classic vs NTAG: what is inside the card?
| Card | User memory | UID | Notes |
|---|---|---|---|
| MIFARE Classic 1K | 752 bytes (16 sectors × 4 blocks × 16 bytes) | 4 bytes | Sectors protected by keys; white cards and blue fobs |
| MIFARE Ultralight | 48 bytes | 7 bytes | No keys, 4-byte pages |
| NTAG213 | 144 bytes | 7 bytes | The tag phones read most easily |
| NTAG215 | 504 bytes | 7 bytes | Common in gaming figure cards |
| NTAG216 | 888 bytes | 7 bytes | Long text and business cards |
| MIFARE DESFire EV2/EV3 | 2–8 KB | 7 bytes | AES encrypted, secure access control |
A MIFARE Classic 1K card is split into 16 sectors of four 16-byte blocks. The last block of each sector (the sector trailer) holds keys A and B plus the access bits, and block 0 stores the UID and manufacturer data. You must authenticate with the sector key before reading a block; on new cards the factory key is FF FF FF FF FF FF. NTAG tags have no keys: memory is made of 4-byte pages and user data starts at page 4. The sketch below reads block 4 of a MIFARE Classic card with the factory key and prints it as hex and ASCII:
1#include <Wire.h>
2#include <Adafruit_PN532.h>
3
4Adafruit_PN532 nfc(2, 3); // IRQ, RESET (I2C)
5uint8_t keyA[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // fabrika anahtarı / factory key
6
7void setup() {
8 Serial.begin(115200);
9 nfc.begin();
10 nfc.SAMConfig();
11}
12
13void loop() {
14 uint8_t uid[7], uidLength, data[16];
15 if (!nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 500)) return;
16 if (uidLength != 4) {
17 Serial.println(F("MIFARE Classic degil / not MIFARE Classic"));
18 delay(1000);
19 return;
20 }
21 // blok 4'e A anahtarıyla giriş (0 = A, 1 = B) / authenticate block 4 with key A
22 if (nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 4, 0, keyA)) {
23 if (nfc.mifareclassic_ReadDataBlock(4, data)) {
24 Serial.print(F("Blok 4 / Block 4: "));
25 nfc.PrintHexChar(data, 16); // hex + ASCII
26 }
27 } else {
28 Serial.println(F("Kimlik dogrulama basarisiz / authentication failed"));
29 }
30 delay(1500);
31}Writing an NDEF message: a tag that opens a URL on the phone
NDEF (NFC Data Exchange Format) is the common tag format phones understand. Once you write an NDEF URL record to a tag, an unlocked Android phone or an iPhone XS or newer shows a notification the moment it touches the tag, with no app needed, and opens the link in the browser. To save space, prefixes such as "https://" are stored as a single byte (0x04), so an NTAG213's 144 bytes hold a URL of about 130 characters.
1#include <Wire.h>
2#include <Adafruit_PN532.h>
3
4Adafruit_PN532 nfc(2, 3);
5char url[] = "bluegrays.com"; // "https://" öneki tek baytla eklenir / prefix is stored as one byte
6
7void setup() {
8 Serial.begin(115200);
9 nfc.begin();
10 nfc.SAMConfig();
11 Serial.println(F("NTAG etiketi yaklastir / Tap an NTAG tag"));
12}
13
14void loop() {
15 uint8_t uid[7], uidLength, page[4];
16 if (!nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 500)) return;
17 // sayfa 3 = yetenek kabı, 0xE1 ise NDEF biçimli / page 3 = capability container, 0xE1 means NDEF
18 if (uidLength != 7 || !nfc.ntag2xx_ReadPage(3, page) || page[0] != 0xE1) {
19 Serial.println(F("NDEF bicimli NTAG degil / not an NDEF formatted NTAG"));
20 delay(1500);
21 return;
22 }
23 uint16_t size = page[2] * 8; // NTAG213: 0x12 * 8 = 144 bayt / bytes
24 uint8_t dataLength = size > 255 ? 255 : size;
25 if (nfc.ntag2xx_WriteNDEFURI(NDEF_URIPREFIX_HTTPS, url, dataLength)) {
26 Serial.println(F("URL yazildi, telefonla dene / URL written, test it with a phone"));
27 } else {
28 Serial.println(F("Yazma hatasi / write error"));
29 }
30 while (1) delay(10); // bir kez yaz ve dur / write once, then stop
31}The sketch first reads the capability container on page 3: if the first byte is 0xE1 the tag is NDEF formatted, and the third byte times 8 gives the size of the data area. Most blank NTAG213 tags ship already NDEF formatted. You can also write a URL to MIFARE Classic cards with mifareclassic_FormatNDEF and mifareclassic_WriteNDEFURI, but iPhones and some Android phones without an NXP chip cannot read MIFARE Classic, so pick NTAG213 for anything meant for phones.
PN532 and smartphones: what actually works?
- The phone reads your tag: every NFC phone reads NDEF tags written by the PN532 (URL, text, phone number). This is the most reliable path.
- The phone writes, the PN532 reads: write a tag with an app such as NFC Tools and process it on the Arduino.
- Using the phone as a card: Android's host card emulation (HCE) sends a random UID on every tap, and iPhones do not open card emulation to regular apps. A lock based on the phone's UID will not work; exchanging data needs a custom Android app with HCE.
- Peer-to-peer: Android Beam was removed in Android 10, so the PN532's P2P mode is now mostly useful between two PN532 boards.
- The PN532 acting as a tag: the library's AsTarget function makes the PN532 look like a card, a good start for advanced experiments.
ESP32 NFC door lock with the PN532
The ESP32's default I2C pins are GPIO 21 (SDA) and GPIO 22 (SCL), so the same Adafruit library works unchanged. The sketch below energises a relay for 3 seconds and lights a green LED when a tag from the allow list is read; an unknown card lights the red LED and prints its UID to the Serial Monitor. Use the first sketch to find your own cards' UIDs and put them in the ALLOWED list.
1#include <Wire.h>
2#include <Adafruit_PN532.h>
3
4#define PN532_IRQ 4 // bağlanmasa da olur / may stay unconnected
5#define PN532_RESET 32 // boş pin, RSTO'ya bağlama / spare pin, do not wire to RSTO
6#define RELAY_PIN 26 // röle ya da MOSFET girişi / relay or MOSFET input
7#define GREEN_LED 25
8#define RED_LED 27
9
10Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET); // SDA GPIO 21, SCL GPIO 22
11
12const uint8_t ALLOWED[][7] = { // izinli UID'ler / allowed UIDs
13 { 0x04, 0xA2, 0x3B, 0x1A, 0x6F, 0x61, 0x80 }, // NTAG213 anahtarlık / key fob
14 { 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00 } // 4 baytlık kart / 4-byte card
15};
16const uint8_t ALLOWED_LEN[] = { 7, 4 };
17const uint8_t ALLOWED_COUNT = sizeof(ALLOWED_LEN);
18
19bool isAllowed(const uint8_t *uid, uint8_t len) {
20 for (uint8_t i = 0; i < ALLOWED_COUNT; i++) {
21 if (len == ALLOWED_LEN[i] && memcmp(uid, ALLOWED[i], len) == 0) return true;
22 }
23 return false;
24}
25
26void setup() {
27 Serial.begin(115200);
28 pinMode(RELAY_PIN, OUTPUT);
29 pinMode(GREEN_LED, OUTPUT);
30 pinMode(RED_LED, OUTPUT);
31 digitalWrite(RELAY_PIN, LOW); // kilit kapalı başlar / lock starts closed
32 nfc.begin();
33 if (!nfc.getFirmwareVersion()) {
34 Serial.println("PN532 yok / PN532 missing");
35 while (true) delay(10);
36 }
37 nfc.SAMConfig();
38}
39
40void loop() {
41 uint8_t uid[7], uidLength;
42 if (!nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 300)) return;
43 if (isAllowed(uid, uidLength)) {
44 Serial.println("Kapi acildi / door unlocked");
45 digitalWrite(GREEN_LED, HIGH);
46 digitalWrite(RELAY_PIN, HIGH); // kilit 3 sn açık / lock open for 3 s
47 delay(3000);
48 digitalWrite(RELAY_PIN, LOW);
49 digitalWrite(GREEN_LED, LOW);
50 } else {
51 Serial.print("Tanimsiz kart / unknown card: ");
52 for (uint8_t i = 0; i < uidLength; i++) Serial.printf("%02X ", uid[i]);
53 Serial.println();
54 digitalWrite(RED_LED, HIGH);
55 delay(1000);
56 digitalWrite(RED_LED, LOW);
57 }
58}Many relay modules switch on with LOW; if yours does, swap HIGH and LOW in the code. To drive a 12 V lock, follow the wiring in our solenoid lock and relay module guides and always put a flyback diode across the coil. The ESP32's 3.3 V output cannot reliably drive some 5 V relay boards; a transistor or MOSFET stage solves that.
PN532 with Raspberry Pi Pico and MicroPython
MicroPython has no official PN532 driver, but the chip's frame format is simple enough to read cards with a short script. Every command is sent in a frame that starts with 0x00 0x00 0xFF; the PN532 replies with a short ACK and then the answer, and over I2C the first byte of every read is 0x01 when the chip is ready. Put the module in I2C mode and wire it to GP4 (SDA) and GP5 (SCL):
1from machine import Pin, I2C
2import time
3
4ADDR = 0x24 # PN532 I2C adresi / I2C address
5i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=100000)
6
7def wait_ready(timeout_ms=1000):
8 t0 = time.ticks_ms()
9 while time.ticks_diff(time.ticks_ms(), t0) < timeout_ms:
10 try:
11 if i2c.readfrom(ADDR, 1)[0] == 0x01: # 0x01 = hazır / ready
12 return True
13 except OSError: # uykudayken NACK / NACK while asleep
14 pass
15 time.sleep_ms(5)
16 return False
17
18def command(cmd, params=b"", n=32):
19 data = bytes([0xD4, cmd]) + params # 0xD4 = Pico -> PN532
20 ln = len(data)
21 frame = bytes([0x00, 0x00, 0xFF, ln, (-ln) & 0xFF]) + data
22 frame += bytes([(-sum(data)) & 0xFF, 0x00]) # sağlama + son bayt / checksum + postamble
23 for _ in range(3): # ilk komut yongayı uyandırır / first try wakes the chip
24 try:
25 i2c.writeto(ADDR, frame)
26 break
27 except OSError:
28 time.sleep_ms(10)
29 if not wait_ready():
30 return None
31 i2c.readfrom(ADDR, 7) # durum + ACK çerçevesi / status + ACK frame
32 if not wait_ready():
33 return None
34 r = i2c.readfrom(ADDR, n + 8)
35 if r[6] != 0xD5 or r[7] != cmd + 1:
36 return None
37 return r[8:8 + r[4] - 2] # yalnız veri baytları / data bytes only
38
39command(0x14, bytes([0x01, 0x14, 0x01])) # SAMConfiguration: normal mod / normal mode
40fw = command(0x02) # GetFirmwareVersion
41if fw:
42 print("PN5{:02X} yazilim / firmware {}.{}".format(fw[0], fw[1], fw[2]))
43command(0x32, bytes([0x05, 0xFF, 0x01, 0x10])) # RFConfiguration: sınırlı deneme / limited retries
44
45while True:
46 r = command(0x4A, bytes([0x01, 0x00])) # InListPassiveTarget, 106 kbps tip A / type A
47 if r and r[0] == 1: # bir kart bulundu / one card found
48 uid = r[6:6 + r[5]]
49 print("UID:", " ".join("{:02X}".format(b) for b in uid))
50 time.sleep_ms(1000)
51 time.sleep_ms(300)The RFConfiguration command limits the number of search retries, so the PN532 does not wait forever when no card is present and the loop simply tries again every 300 ms. With a Pico W you can send each UID over Wi-Fi to a server and build a card-based attendance system.
PN532 project ideas
- NFC door lock: a door that opens with a key fob; add a keypad for two-factor entry with card plus PIN.
- Card attendance: timestamp each UID with NTP time and log it to a Google Sheets spreadsheet.
- Smart home scenes: tap a tag on the nightstand to send an MQTT command that switches off every light.
- Inventory tracking: stick NTAG labels on boxes and tools to track loans and stock.
- Interactive game cards: play a sound or a story with a DFPlayer when a card is tapped.
- Info tag: an NDEF tag on a device that opens its manual on the phone.
PN532 troubleshooting: common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| "Didn't find PN53x board" | DIP switch in the wrong mode, SDA and SCL swapped | Set I2C (1 ON, 2 OFF), power-cycle, check the wiring |
| Changed the mode, nothing changed | The PN532 reads the mode only at power-up | Cut the power completely and restore it |
| ESP32 loses the PN532 now and then | I2C clock stretching, long wires | Shorten the wires, try Wire.setClock(100000) or switch to SPI |
| UID reads, blocks do not | Wrong key or a sector trailer | Try the factory key and read data blocks only |
| Phone ignores the tag | MIFARE Classic tag or not NDEF formatted | Use NTAG213, turn NFC on, unlock the screen |
| Very short read range | Metal surface or weak supply | Use on-metal tags and a supply that gives at least 150 mA |
The PN532 is worth learning because it packs almost everything NFC can do, from reading cards to talking to phones, into one module. Start with UID reading, move on to NDEF writing and then build the door lock. In the BlueGrays app you will find RFID card reading, card authentication and ESP32 RFID door lock projects with step-by-step wiring diagrams and ready-to-use code, and you can adapt the same setup to the PN532 in minutes.
Frequently asked questions
What is the difference between PN532 and RC522?
Both read 13.56 MHz cards, but the PN532 offers I2C, SPI and UART, a 3.3–5 V supply, a longer read range and NFC features such as NDEF and card emulation. The RC522 only does SPI at 3.3 V, costs less and is fine for simple UID reading. If you want to interact with phones, choose the PN532.
What is the read range of the PN532?
The red V3 module usually reads credit-card-sized cards from 5–7 cm. With small key fobs and sticker tags the range drops to 2–3 cm. Metal surfaces and a weak power supply shorten it noticeably.
Can the PN532 read a phone's NFC?
The PN532 works fine with tags that a phone writes or reads. Reading the phone itself as a card is limited: Android sends a random UID on every tap, and iPhones do not open card emulation to regular apps. To exchange data with a phone you need a custom Android app that uses HCE.
Does the PN532 work with 5V?
The red V3 module accepts a 3.3–5 V supply, and its I2C and HSU lines are 5 V TTL compatible, so it connects directly to an Arduino Uno over I2C. Its SPI lines are specified at 3.3 V, so a level shifter is recommended for SPI on an Uno. On ESP32 and Pico, power it from 3V3.
What is the PN532 I2C address and why is it not found?
The PN532's 7-bit I2C address is 0x24; some documents list the 8-bit form, 0x48. If the module is not found, the DIP switch is usually not set to I2C, SDA and SCL are swapped, or the power was not cycled after changing the mode. A sleeping PN532 may not show up in an I2C scanner, which is normal.
Can the PN532 write NFC tags?
Yes. You can write raw pages or an NDEF URL that phones open to NTAG213, NTAG215 and NTAG216 tags, and you can write blocks to MIFARE Classic cards after authentication. Just be careful with sector trailers and lock bytes, because a wrong write locks the card for good.
Projects to build after reading this
See all projects
RFID Value Reading
Your building key fob or access card hides a secret ID number, and this project reads it. Hold the card near the RFID reader and the Arduino writes the card's number to your computer screen.

RFID Authentication
Just like the card entry at an apartment door: you hold your card near the RFID reader, and the Arduino compares its number with the one it has saved.

ESP32 RFID RC522 Card Reader (with LCD)
In this project, we will connect the MFRC522-based RC522 RFID module to the ESP32 via SPI and read the card/tag UID. This forms the basis for applications such as door locks, membership systems, and access control. We will display the read UID on an LCD screen; this version does not compare it with an authorized card list. WARNING: The RC522 operates only at 3.3V; supplying 5V will burn out the module!

ESP32 RFID Door Lock (RC522 + Servo + OLED + Buzzer + LED)
We build a smart door lock with an ESP32, an RC522 RFID module, an SG90 servo, an SSD1306 OLED display, an active buzzer and 2 LEDs. When a card is scanned, its UID is checked against the authorized cards defined in the code; if it matches, the servo unlocks (green LED + 2 short beeps) and locks again after 5 seconds. An unknown card lights the red LED, gives 3 quick beeps and shows its UID on the OLED.

Smart Electronic Safe
A small safe for your valuables that opens with a code. You type your four-digit code on the keypad; if it is right, the servo motor opens the lock, the green light comes on and the screen shows the…

Password Lock with 4x4 Keypad and LCD
A small electronic door lock that keeps out anyone who doesn't know the code. You press the hash key and type the code on the keypad; if it is right, the screen says access granted, the green LED…

Reed Switch Door Sensor
Tell whether your door is open or closed just by looking at a light. You attach a small magnet to the door and a magnet-sensing switch to the frame; when the door is closed they sit side by side and…

ESP32 I2C LCD Display (16x2)
In this project we connect a 16x2 character LCD to the ESP32 over I2C and display text. With I2C, just 2 data pins (SDA and SCL) control the screen, instead of the 6+ pins a classic parallel connection wastes. The code prints a fixed message on the first line and a counter that goes up every second on the second. At startup an I2C scanner also prints the display's address to the Serial Monitor (usually 0x27 or 0x3F).
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

