This project implements NFC (Near Field Communication) functionality using Arduino-compatible boards with PN532 NFC modules. It includes libraries for NDEF (NFC Data Exchange Format) message handling and PN532 communication protocols.
- NDEF message creation, reading, and writing
- Support for MIFARE Classic and Ultralight tags
- Peer-to-peer (P2P) communication
- Tag emulation
- Multiple communication interfaces (HSU, I2C, SPI)
- Arduino-compatible board (e.g., Arduino Uno, ESP32)
- PN532 NFC module
- NFC tags/cards for testing
- PlatformIO IDE or VS Code with PlatformIO extension
- Arduino framework
- Clone or download this repository
- Open the project in PlatformIO
- Build and upload the desired example sketch
The lib/NDEF/examples/ and lib/PN532/examples/ directories contain various example sketches:
ReadTag.ino: Read NDEF messages from NFC tagsWriteTag.ino: Write NDEF messages to NFC tagsP2P_Send.ino/P2P_Receive.ino: Peer-to-peer communicationemulate_tag_ndef.ino: Tag emulation
Include the necessary headers in your Arduino sketch:
#include <NfcAdapter.h>
#include <NdefMessage.h>Initialize the NFC adapter and perform operations as shown in the examples.
The main application in src/main.cpp provides NFC card cloning, reading, and emulation functionality for ESP32.
-
Connect the PN532 module to the ESP32:
- TX -> GPIO 16 (RX2)
- RX -> GPIO 17 (TX2)
- Set DIP switches to OFF - OFF for HSU mode
-
Open the project in PlatformIO and build/upload the sketch.
-
Open the serial monitor (115200 baud) to interact with the device.
-
The application supports:
- Reading MIFARE Classic cards
- Cloning card data
- Emulating tags with NDEF messages
- Peer-to-peer communication via SNEP
Follow the serial prompts to perform operations.
src/: Main source codelib/NDEF/: NDEF library for message handlinglib/PN532/: PN532 driver libraryinclude/: Additional includestest/: Test sketches
Contributions are welcome. Please submit issues and pull requests on the project repository.
This project uses libraries with their respective licenses. Check individual library READMEs for details.