← All parts

Adafruit PN532 NFC/RFID

AdafruitPN532

The PN532 is an NFC and RFID module used for contactless communication. It supports various protocols like TTL serial, I2C, and SPI.

In stock

Specifications

2
Operating Voltage
3.3V or 5V Volts
Logic Level
TTL compatible

Pinout

12
PinNameFunctionsNotes
1GND
GND
Ground
2VCC
POWER
Power supply, typically 3.3V or 5V.
3SDA
I2C
I2C data line
4SCL
I2C
I2C clock line
5TX
UART
Transmit data for serial communication.
6RX
UART
Receive data for serial communication.
7GND
GND
Ground
8VCC
POWER
Power supply, typically 3.3V or 5V.
9SCK
SPI
Serial clock for SPI communication
10MOSI
SPI
Master Out/Slave In for SPI.
11MISO
SPI
Master In/Slave Out for SPI.
12CS
SPI
Chip select line for SPI

Interactive pinout

Highlight:
PN532

Click a pin to copy its name · tap a tag above to spotlight a bus.

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

Arduino library: Adafruit PN532

arduino
// PN532 NFC/RFID reader (I2C) — community starter example
#include <Wire.h>
#include <Adafruit_PN532.h>

#if defined(ESP32)
  #define PN532_IRQ 4
  #define PN532_RST 5
#else
  #define PN532_IRQ 2
  #define PN532_RST 3
#endif

Adafruit_PN532 nfc(PN532_IRQ, PN532_RST);   // I2C mode

void setup() {
  Serial.begin(115200);
  nfc.begin();
  if (!nfc.getFirmwareVersion()) { Serial.println("PN532 not found"); while (1) delay(10); }
  nfc.SAMConfig();
  Serial.println("Tap an NFC tag...");
}

void loop() {
  uint8_t uid[7]; uint8_t uidLen;
  if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLen)) {
    Serial.print("UID bytes: "); Serial.println(uidLen);
  }
  delay(500);
}

MicroPython

MicroPython library: pn532 (a PN532 MicroPython port)

python
# PN532 NFC (ESP32, I2C) — community starter example
# lib: a PN532 MicroPython driver (e.g. Carglglz/NFC_PN532)
from machine import Pin, I2C
from pn532 import PN532_I2C
import time

i2c = I2C(0, scl=Pin(22), sda=Pin(21))
nfc = PN532_I2C(i2c)
nfc.SAM_configuration()

while True:
    uid = nfc.read_passive_target(timeout=0.5)
    if uid:
        print("UID", [hex(b) for b in uid])
    time.sleep(0.2)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VCC+5V3V3Logic 3.3-5 V
GNDGNDGND
SDAA4/SDAGPIO21I2C data (set the board's mode switch to I2C)
SCLA5/SCLGPIO22I2C clock
RSTPDND3GPIO5Reset
IRQD2GPIO4Interrupt

Typical uses

  • NFC / RFID read & write (13.56 MHz)
  • Card emulation and peer-to-peer NFC

Related parts

6