Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Arduino & Microcontrollers

Arduino NFC Reader: PN532 Module RFID and NFC Projects

Arduino NFC Reader: PN532 Module RFID and NFC Projects

March 11, 2026 /Posted byJayesh Jain / 0

Near-Field Communication (NFC) brings contactless magic to your maker projects, and the Arduino PN532 NFC reader module is the most capable and affordable way to add it. The NXP PN532 chip handles the heavy lifting of ISO 14443A/B and ISO 18092 protocols, letting you read Mifare Classic cards, emulate NFC tags, and even do peer-to-peer data exchange — all from a simple Arduino sketch. In this guide you will learn everything from wiring and library installation to real-world projects like access control systems and smart business cards.

  • What Is the PN532 and How Does NFC Work?
  • PN532 Module Variants and Communication Modes
  • Wiring the PN532 to Arduino
  • Library Installation and First Sketch
  • Reading and Writing NFC Cards and Tags
  • Practical Project Ideas
  • Security Considerations
  • Frequently Asked Questions

What Is the PN532 and How Does NFC Work?

NFC (Near-Field Communication) is a short-range wireless technology that operates at 13.56 MHz with a typical range of up to 5 cm. It is a specialised subset of RFID (Radio-Frequency Identification) and underpins contactless payment cards, metro tokens, electronic passports, and smartphone tap-to-pay.

The NXP PN532 is a highly integrated transceiver IC capable of operating in three modes:

  • Reader/Writer mode: The module acts as an RFID reader. It can read from and write to NFC Forum Type 1–4 tags, Mifare Classic 1K/4K cards, Mifare Ultralight, NTAG213/215/216, and FeliCa cards.
  • Card Emulation mode: The module pretends to be an NFC card. An external reader (like a smartphone) sees it as a regular contactless tag.
  • Peer-to-Peer (P2P) mode: Two PN532 modules (or a module and an NFC-enabled smartphone) exchange data bidirectionally, similar to Android Beam.

The key advantage of the PN532 over simpler RFID modules like the RC522 is its ability to do all three modes plus its support for NDEF (NFC Data Exchange Format) records, which is the standard format used by smartphones to encode URLs, text, and contact information on NFC tags.

PN532 Module Variants and Communication Modes

PN532 breakout boards come in two main form factors, distinguished by their on-board DIP switches that select the communication interface:

Standard PN532 Breakout (Adafruit / Elechouse style)

These boards have two DIP switches or solder jumpers. The switch combination selects one of three interfaces:

  • UART (HSU): SW1=OFF, SW2=OFF. Uses two wires (TX, RX) at 115200 baud. Simple but ties up the hardware serial port on a Uno.
  • SPI: SW1=ON, SW2=OFF. Uses four wires (SCK, MISO, MOSI, SS). Fastest option, compatible with hardware SPI.
  • I2C: SW1=OFF, SW2=ON. Uses two wires (SDA, SCL). Easy to daisy-chain with other I2C devices. Default address: 0x24.

PN532 Shield / HAT

These plug directly onto an Arduino Uno or Mega, with the interface pre-wired. Most use UART or SPI. Convenient but less flexible than the standalone breakout.

Wiring the PN532 to Arduino

I2C Wiring (recommended for beginners)

PN532 Pin Arduino Uno Pin
VCC 5 V
GND GND
SDA A4
SCL A5

Set DIP: SW1=OFF, SW2=ON. After wiring, run an I2C scanner sketch to confirm the module appears at address 0x24.

SPI Wiring (recommended for speed-critical projects)

PN532 Pin Arduino Uno Pin
VCC 5 V
GND GND
SCK 13
MISO 12
MOSI 11
SS 10

Set DIP: SW1=ON, SW2=OFF.

Recommended: Arduino Uno R3 Beginners Kit — includes the Arduino Uno, breadboard, and jumper wires needed to prototype PN532 NFC projects quickly.

Library Installation and First Sketch

The most popular library for the PN532 on Arduino is the Adafruit PN532 Library, available in the Arduino IDE Library Manager. It supports all three interface modes.

Installing the Library

  1. Arduino IDE → Sketch → Include Library → Manage Libraries.
  2. Search for Adafruit PN532 and install it.
  3. Also install Adafruit BusIO (a dependency).

First Sketch: Read a Card UID (I2C Mode)

#include <Wire.h>
#include <Adafruit_PN532.h>

#define PN532_IRQ   2
#define PN532_RESET 3

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

void setup() {
  Serial.begin(9600);
  nfc.begin();
  uint32_t versiondata = nfc.getFirmwareVersion();
  if (!versiondata) { Serial.println("PN532 not found!"); while(1); }
  Serial.print("Found PN5"); Serial.println((versiondata >> 24) & 0xFF, HEX);
  nfc.SAMConfig(); // configure to read NFC/RFID tags
}

void loop() {
  uint8_t uid[7]; uint8_t uidLength;
  if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength)) {
    Serial.print("Card UID: ");
    for (uint8_t i = 0; i < uidLength; i++) {
      if (uid[i] < 0x10) Serial.print("0");
      Serial.print(uid[i], HEX); Serial.print(" ");
    }
    Serial.println();
    delay(1000);
  }
}

Upload this sketch and open the Serial Monitor at 9600 baud. Tap any Mifare card or NFC sticker — you will see its UID printed immediately.

Reading and Writing NFC Cards and Tags

Reading a Mifare Classic Block

Mifare Classic cards are divided into 16 sectors (1K) or 40 sectors (4K), each containing 4 blocks of 16 bytes. Access is controlled by two 6-byte keys (Key A and Key B). The default factory key for most cards is 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF.

uint8_t key[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
uint8_t data[16];
if (nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 4, 0, key)) {
  if (nfc.mifareclassic_ReadDataBlock(4, data)) {
    // data[] now contains 16 bytes from block 4
  }
}

Writing NDEF to an NTAG213

NTAG213/215/216 stickers are the easiest to work with for NFC-enabled smartphones. They are formatted as NDEF out of the factory. You can write a URL record like this:

// Using Adafruit PN532 library NdefMessage support
#include <NdefMessage.h>
#include <NdefRecord.h>

NdefMessage message;
message.addUriRecord("https://zbotic.in");
nfc.writeNdefMessage(message);

After writing, any NFC-enabled Android or iOS device tapped to the sticker will automatically open the Zbotic website — useful for product labels, business cards, and interactive displays.

Card Emulation Mode

The PN532 can emulate a Mifare Classic or NDEF tag. This is useful when your project needs to appear as a tag to an existing reader (for example, an office door lock system). The Elechouse PN532 library (a popular alternative to the Adafruit one) has better support for emulation mode. Configure with tgInitAsTarget().

Practical Project Ideas

RFID Access Control System

Store authorised card UIDs in EEPROM (or an SD card for a larger list). On each scan, compare the presented UID against the list. If matched, trigger a relay to unlock a door, activate an LED strip, or buzz a solenoid lock. Add an LCD or TFT display to show access status.

Recommended: 12V Modbus RTU 1-Channel Relay Module for Arduino — opto-isolated relay module to safely switch door locks or solenoids from your Arduino PN532 access control sketch.

NFC Smart Business Card

Write your contact details as a vCard NDEF record onto an NTAG216 sticker. When a colleague taps their smartphone to the sticker, your contact information is automatically offered for saving. Use the PN532 module and an Arduino to re-write the card whenever your details change, without needing a dedicated NFC writer app.

Product Authentication Tag

Write a unique ID and digital signature to NFC tags attached to products. A customer with an NFC phone taps the tag and is directed to a verification URL. A genuine product returns a valid signature; a counterfeit returns nothing or fails. The Arduino PN532 module can be used at the production station to write tags.

Inventory and Asset Tracking

Attach NTAG stickers to tools, equipment, or storage bins. Build a handheld scanner using an Arduino Nano 33 IoT (for Wi-Fi) and a PN532 module. When a tag is scanned, the sketch POST’s the tag ID to a web server or Google Sheet via HTTP, maintaining a real-time asset register.

Recommended: Arduino Nano 33 IoT with Header — compact board with built-in Wi-Fi, ideal for building a wireless NFC scanner that logs scanned tag data to a cloud server.

NFC-Triggered Automation

Place NFC stickers around your home or workshop. Each sticker has a unique NDEF record. When you tap your key fob (acting as an NFC card) on the reader at your desk, the Arduino executes a specific macro: turning on your monitor relay, starting a timer, logging a timestamp. Different tags trigger different actions.

Security Considerations

Mifare Classic Vulnerabilities

Mifare Classic cards use a proprietary encryption algorithm (CRYPTO1) that has been publicly broken. A determined attacker with the right hardware (e.g., a Proxmark) can clone a Mifare Classic card in seconds. For high-security access control, use Mifare DESFire or NTAG 424 DNA cards, which use AES-128 encryption. The PN532 supports these, but the coding is more involved.

Protect Your Keys

Do not use the default Mifare Classic key (FF FF FF FF FF FF) in production. Change both Key A and Key B to unique values and store them securely in your firmware (ideally in the MCU’s flash memory, not in EEPROM which is easier to read out).

Replay Attack Prevention

For payment or high-value access systems, a static UID is vulnerable to replay attacks (cloning the UID). Use a challenge-response protocol: the reader sends a random nonce, the card signs it with its private key, and the reader verifies the signature. This requires DESFire or a similar modern card.

Physical Security

NFC operates at up to 5 cm range, but a powerful reader in a backpack can read cards at up to 1 m. Keep sensitive NFC cards in RFID-blocking sleeves when not in use.

Frequently Asked Questions

What is the difference between the PN532 and the more common RC522?

The RC522 is a simpler, cheaper chip that only supports Mifare Classic in reader mode over SPI. The PN532 is a full NFC controller supporting all NFC Forum tag types, card emulation, and P2P mode, making it far more versatile. Use the RC522 if you only need basic Mifare card reading; use the PN532 for everything else.

Can the PN532 read NFC from an Android or iPhone?

Yes — in P2P mode (Android Beam style) with Android. Apple devices operate in a restricted mode; NFC on iPhone is primarily for reading NDEF tags (Type 2, 3, 4 supported on iPhone 7+) and Apple Pay. You can write NDEF records to an NTAG sticker using a PN532-connected Arduino, and an iPhone will read that tag. Direct P2P with an iPhone is not supported.

How far can the PN532 read a card?

Under normal conditions with the PCB antenna on a standard PN532 module, read range is 3–5 cm. With a larger external antenna coil, this can extend to 8–10 cm. Performance depends heavily on the size and quality of the antenna and any metallic objects nearby (metal blocks RF fields).

Can I use the PN532 with an ESP32 or ESP8266?

Yes. The PN532 works with any microcontroller that supports I2C, SPI, or UART. On an ESP32, use the hardware I2C or SPI bus. The Adafruit PN532 library is compatible with the ESP32 Arduino core.

Why does my PN532 fail to initialise and getFirmwareVersion() returns 0?

The most common causes are: wrong DIP switch setting for the selected interface, insufficient power (the PN532 draws up to 150 mA — make sure your power supply can handle it), incorrect wiring, or a damaged module. Try powering the module from a 5 V 1 A supply directly and re-check your SDA/SCL or SCK/MOSI/MISO wiring.

Explore more Arduino modules and components at Zbotic’s Arduino & Microcontrollers store — same-day dispatch on most items across India.

Tags: access control, arduino NFC, arduino pn532 nfc reader, NFC module, PN532, RFID arduino
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Arduino Debounce: Fix Button B...
blog arduino debounce fix button bounce issues once and for all 594711
blog arduino soil moisture sensor calibration get accurate values 594714
Arduino Soil Moisture Sensor C...

Related posts

Svg%3E
Read more

Arduino Batch Programming: Flash Multiple Boards Quickly

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Based Radar System with Ultrasonic Sensor

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Automatic Plant Monitor: Sunlight, Moisture, Temperature

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Lie Detector: GSR Sensor Polygraph Project

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Metal Detector: Build a Treasure Finder

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now