The Adafruit PN532 Breakout Board is a versatile and user-friendly NFC/RFID controller that enables wireless communication for a variety of applications. Based on the widely-used PN532 chip, this breakout board is designed to read and write NFC tags, interface with NFC-enabled devices, and facilitate secure transactions. With an onboard 3.3V regulator and level shifting, it is compatible with a broad range of microcontrollers, including both 3.3V and 5V systems, such as the Arduino UNO.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (3.3V-5V) |
2 | GND | Ground connection |
3 | SDA | I2C Data / SPI MOSI |
4 | SCL | I2C Clock / SPI Clock |
5 | MISO | SPI MISO (not used in I2C mode) |
6 | IRQ | Interrupt pin (active low) |
7 | RSTO | Reset output from PN532 |
8 | RSTPD_N | Reset input to PN532 (active low) |
#include <Wire.h>
#include <Adafruit_PN532.h>
// If using the I2C interface, define SDA and SCL pins
#define SDA_PIN 2
#define SCL_PIN 3
// Create an instance of the Adafruit_PN532 class
Adafruit_PN532 nfc(SDA_PIN, SCL_PIN);
void setup(void) {
Serial.begin(115200);
Serial.println("Hello! Scan a NFC tag!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (!versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// Configure board to read RFID tags
nfc.SAMConfig();
}
void loop(void) {
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type card (Mifare, etc.). When one is found, 'uid' will be populated
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
// Display some basic information about the card
Serial.println("Found an ISO14443A card");
Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print("UID Value: ");
for (uint8_t i=0; i < uidLength; i++) {
Serial.print(" 0x");Serial.print(uid[i], HEX);
}
Serial.println("");
// Wait 1 second before continuing
delay(1000);
}
}
Q: Can the Adafruit PN532 Breakout Board be used with a 5V microcontroller like an Arduino UNO?
A: Yes, the board has a built-in level shifter and regulator, making it compatible with 5V systems.
Q: What is the maximum range of the NFC communication?
A: The maximum range is up to 7cm, but this can vary based on antenna design and environmental factors.
Q: How do I know if the board is powered and functioning correctly?
A: Upon powering up, the board's firmware version can be read as a basic check. If the firmware version is returned, the board is functioning correctly.
Q: Can the board read all types of NFC tags?
A: The board supports a wide range of NFC tags, including ISO/IEC 14443 Type A and B, FeliCa, and MIFARE cards. However, compatibility with all NFC tag types is not guaranteed.