esp32-NFC-PN532-13-56MHz
Flash to Device
Login required: You need to login or create an account to flash this project.
Source Files (3)
Download AllREADME
PN532 NFC Reader (SPI) โ ESP32
Read NFC / RFID tags via PN532 (13.56 MHz) using SPI and display data in Serial Monitor
This project demonstrates how to use an ESP32 with an PN532 NFC reader in SPI mode to detect NFC / RFID tags and print their UID data to the Serial Monitor.
The PN532 communicates with the ESP32 using MOSI, MISO, SCK and CS pins (SPI), not I2C. The sketch initializes the PN532, verifies the firmware version, and continuously waits for NFC tags in range.
โญ Features
๐ก PN532 NFC reader (13.56 MHz)
๐ SPI communication (MOSI / MISO / SCK / CS)
๐ Reads NFC tag UID
- MIFARE Classic
- MIFARE Ultralight
- NTAG / ISO14443A
๐ฅ Serial Monitor output
โก Works with ESP32 Dev Module
๐งช Firmware detection for easy debugging
๐ฆ Hardware Requirements
- ESP32 (ESP32 Dev Module / ESP32-WROOM)
- PN532 NFC reader module (SPI-capable)
- NFC cards or tags (13.56 MHz)
- Jumper wires
๐ Wiring (SPI)
| PN532 | ESP32 |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SCK | GPIO18 |
| MISO | GPIO19 |
| MOSI | GPIO23 |
| SS / CS | GPIO5 |
โ ๏ธ Important PN532 must be powered with 3.3V when used with ESP32.
๐ง PN532 Interface Selection
The PN532 supports multiple communication modes:
- I2C
- SPI
- HSU (UART)
โ SPI Mode (required)
Most PN532 modules use DIP switches or solder jumpers to select the interface.
Typical configuration for SPI:
SW1 = OFF
SW2 = ON
- Switch UP โ
ON - Switch DOWN โ
OFF
After changing switches, disconnect and reconnect power to the PN532.
๐ง Software Requirements
Arduino IDE
ESP32 board package
Boards Manager โ esp32 by Espressif Systems
Required Libraries
Install via Arduino Library Manager:
Adafruit PN532
Core libraries used:
SPIWiFi(ESP32 core dependency)
๐ Getting Started
Open the sketch in Arduino IDE
Select your board:
ESP32 Dev ModuleSelect the correct COM port
Upload the sketch
Open Serial Monitor
Set baud rate to:
115200
๐ถ Usage
- Power the ESP32 and PN532
- Open the Serial Monitor
- Bring an NFC card or tag close to the reader
- The UID will be printed:
NFC card detected!
UID Length: 4 bytes
UID Value: 04 A1 B2 C3
๐งช Debugging Tips
If nothing appears in Serial Monitor:
- Check baud rate (115200)
- Check COM port
- Verify PN532 is in SPI mode
- Ensure CS pin is HIGH before initialization
- Confirm 3.3V power, not 5V
If firmware version is not detected:
- Recheck DIP switch orientation
- Shorten SPI wires
- Power-cycle PN532
๐ Customization Ideas
You can extend this project by adding:
- ๐ Reading MIFARE Classic blocks
- โ๏ธ Writing data to NFC tags
- ๐งพ JSON output over Serial
- ๐ Sending NFC data over WiFi / MQTT
- ๐ Button-triggered scans
- ๐ Access control systems
๐ License
This project is released under the MIT License.
You are free to use, modify, and distribute it for personal and commercial projects.