The NFC RFID PN532 is a module that lets an Arduino scan NFC cards or tags. NFC means Near Field Communication, and RFID stands for Radio Frequency Identification. This module reads cards wirelessly when placed close to the sensor. Many projects use it for identification, access control, or automation with a simple card tap.
When a user taps an NFC card on the PN532, it reads the card’s unique ID (UID). The UID can trigger different actions. You can show it on an LCD screen, log it for attendance, or activate a device. The system responds instantly, making it perfect for contactless control.
The PN532 adds smart, interactive features to your project. Instead of using buttons, users only need to tap a card. It connects easily to Arduino and works well for school projects, home automation, or hobby builds.
Components:

- NFC RFID Module PN532
- NFC Card Tag
- Arduino MEGA
- LCD Display I2C 20×4 Blue
- Breadboard 400
- Jumper Wires
- Cable Type B
Connection:

Before connecting the PN532 module, you need to make sure it’s properly configured for I2C mode.
From the image:
- SET0 = H (switch is ON)
- SET1 = L (switch is OFF)
PN532 must be in I2C mode:
- SDA → Mega pin 20
- SCL → Mega pin 21
- 5V → Mega 5V
- GND → Mega GND
LCD to Mega:
- SDA → Pin 20
- SCL → Pin 21
- VCC → 3.3v
- GND → GND
Notes:
- Both LCD and PN532 must share the same SDA/SCL lines — use a breadboard to split them.
- Don’t connect anything to IRQ or RESET physically — they’re only needed in the constructor.
- Install the Adafruit PN532 by Adafruit and LiquidCrystal I2C by Frank de Brabander.
Code:
This Arduino code is designed to use a PN532 NFC module and a 20×4 I2C LCD to detect and display the UID of scanned RFID or NFC cards. When a card is tapped, the loop()
function reads the card’s UID, displays it on the LCD, and also prints it to the Serial Monitor. The IRQ and RESET pins defined in the code are not physically required when using I2C mode. They are only placeholders for the Adafruit library constructor. This is because, in I2C communication, all data exchange occurs through the SDA and SCL lines, making IRQ and RESET unnecessary.
#include <Wire.h>
#include <Adafruit_PN532.h>
#include <LiquidCrystal_I2C.h>
// PN532 setup (dummy IRQ/RESET for I2C)
#define PN532_IRQ 2
#define PN532_RESET 3
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET, &Wire);
// LCD setup: change 0x27 to 0x3F if needed
LiquidCrystal_I2C lcd(0x27, 20, 4); // address, columns, rows
void setup() {
Serial.begin(115200);
// LCD init
lcd.begin(20, 4);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("PN532 + LCD Ready");
// PN532 init
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (!versiondata) {
lcd.setCursor(0, 1);
lcd.print("PN532 not found!");
Serial.println("PN532 not found");
while (1);
}
nfc.SAMConfig();
lcd.setCursor(0, 1);
lcd.print("Scan a card...");
}
void loop() {
uint8_t uid[7]; // UID buffer
uint8_t uidLength;
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength)) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Card UID:");
String uidString = "";
for (uint8_t i = 0; i < uidLength; i++) {
if (uid[i] < 0x10) uidString += "0";
uidString += String(uid[i], HEX);
}
uidString.toUpperCase();
lcd.setCursor(0, 1);
lcd.print(uidString);
Serial.print("Card UID: ");
Serial.println(uidString);
delay(2000);
lcd.setCursor(0, 2);
lcd.print("Scan next card...");
}
}