Datasheet
Arduino Library
Which Library?
In the past there were two separate Arduino libraries for using the Adafruit NFC boards. One library supported the
breakout over a SPI connection, and the other library supported the breakout or shield over an I2C connection.
However both of these libraries have been merged into a single Arduino library, Adafruit-PN532 (https://adafru.it/eHi).
The Adafruit PN532 library has the ability to read MiFare cards, including the hard-coded ID numbers, as well as
authenticate and read/write EEPROM chunks. It can work with both the breakout and shield using either a SPI or I2C
connection.
Library Installation
Download the Adafruit PN532 library from github (https://adafru.it/aSX). Uncompress the folder and rename the folder
Adafruit_PN532. Inside the folder you should see the Adafruit_PN532.cpp and Adafruit_PN532.h files. Install the
Adafruit_PN532 library foler by placing it in your
arduinosketchfolder
/libraries folder. You may have to create the
libraries subfolder if this is your first library. You can read more about installing libraries in our
tutorial (https://adafru.it/aYG).
Restart the Arduino IDE. You should now be able to select File > Examples > Adafruit_PN532 > readMifare sketch.
If you're using the NFC breakout with a SPI connection that uses the wiring shown on previous pages you can
immediately upload the sketch to the Arduino and skip down to the Testing MiFare (https://adafru.it/kAc) section.
If you're using the NFC shield, or are using the breakout with an I2C connection then you must make a small change
to configure the example for I2C. Scroll down to these lines near the top of the sketch:
Change them so the second line is uncommented and the first line is commented. This will configure the sketch to
make the library use I2C for communication with the NFC shield or breakout. The modified code should look like:
// Uncomment just _one_ line below depending on how your breakout or shield
// is connected to the Arduino:
// Use this line for a breakout with a SPI connection:
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
// Use this line for a breakout with a hardware SPI connection. Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
//Adafruit_PN532 nfc(PN532_SS);
// Or use this line for a breakout or shield with an I2C connection:
//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
© Adafruit Industries https://learn.adafruit.com/adafruit-pn532-rfid-nfc Page 12 of 42










