Page last edited November 29, 2012
Text editor powered by tinymce.
Page last edited November 29, 2012
Text editor powered by tinymce.
On the breakout board
Also connect 4050 pin #1 to 3.3V and pin #8 to ground.
Click to see a larger image. The red power wire should be connected to the 3.3v pin on the Arduino!
Page last edited November 29, 2012
Text editor powered by tinymce.
Page last edited November 29, 2012
Text editor powered by tinymce.
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.
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.
Download the Adafruit PN532 library from github. 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.
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 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:
// 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);
// 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);
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);
// 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);
Then upload the example to the Arduino and continue on. Note that you need to make a similar change to pick the interface for any other NFC example from the library.
Page last edited November 29, 2012
Text editor powered by tinymce.
It's easy to use the PN532 breakout and shield with Python and CircuitPython, and the Adafruit CircuitPython PN532 module. This module allows you to easily write Python code that reads and writes data from and to RFID/NFC tags.
You can use this breakout with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.
First assemble a PN532 breakout or shield exactly as shown on the previous pages.
Here's an example of wiring a Feather M0 to the breakout with I2C:
I2C requires external pull ups on SCL and SDA!
You must set the jumpers to enable I2C on your PN532! For I2C:
Here's an example of wiring a Feather M0 to the breakout using SPI:
You must set the jumpers to enable SPI on your PN532! For SPI:
Here's an example of wiring a Feather M0 to the breakout using UART:
You must set the jumpers to enable UART on your PN532! For UART:
Here's an example of wiring a Metro M0 to the shield using I2C:
Assemble the shield as shown in the previous pages, and plug into your Metro M0.
You must set the jumpers to enable I2C on your PN532! For I2C:
Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.
Here's the Raspberry Pi wired with SPI:
You must set the jumpers to enable SPI on your PN532! For SPI:
We don't recommand using I2C, but here's the Raspberry Pi wired with I2C:
You must set the jumpers to enable I2C on your PN532! For I2C:
We don't recommand using UART, but here's the Raspberry Pi wired with UART:
You must set the jumpers to enable UART on your PN532! For UART:
Next you'll need to install the Adafruit CircuitPython PN532 library on your CircuitPython board.
First make sure you are running the latest version of Adafruit CircuitPython for your board.
Next you'll need to install the necessary libraries to use the hardware--carefully follow the steps to find and install these libraries from Adafruit's CircuitPython library bundle. Our introduction guide has a great page on how to install the library bundle for both express and non-express boards.
Remember for non-express boards like the, you'll need to manually install the necessary libraries from the bundle:
Before continuing make sure your board's lib folder or root filesystem has the adafruit_pn532.mpy, and adafruit_bus_device files and folders copied over.
Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!
Once that's done, from your command line run the following command:
sudo pip3 install adafruit-circuitpython-pn532
If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!
To demonstrate the usage of the breakout we'll initialize it and read the ID from a tag using the board's Python REPL.
Run the following code to import the necessary modules and assign the reset pin to a digital pin on your board. We've used D6:
import board import busio from digitalio import DigitalInOut from adafruit_pn532.i2c import PN532_I2C reset_pin = DigitalInOut(board.D6)
import board import busio from digitalio import DigitalInOut from adafruit_pn532.i2c import PN532_I2C reset_pin = DigitalInOut(board.D6)
On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware wakeup. This avoids I2C clock stretching.
Initialise the I2C object:
i2c = busio.I2C(board.SCL, board.SDA) pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
i2c = busio.I2C(board.SCL, board.SDA) pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
Now we can start interacting with NFC/RFID tags using the following functions:
firmware_version
- Get the latest firmware version.SAM_configuration
- configure the PN532 to read MiFare cards.read_passive_target
- Wait for a MiFare card to be available and return its UID when found.call_function
- Send specified command to the PN532 and expect up to response_length
bytes back in a response.mifare_classic_authenticate_block
- Authenticate specified block number for a MiFare classic card.mifare_classic_read_block
- Read a block of data from the card.mifare_classic_write_block
- Write a block of data to the card.ntag2xx_read_block
- Read a block of data from the card.ntag2xx_write_block
- Write a block of data to the card.First, we'll verify the PN532 is connected and check the firmware.
ic, ver, rev, support = pn532.firmware_version print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
ic, ver, rev, support = pn532.firmware_version print('Found PN532 with firmware version: {0}.{1}'.format(ver, rev))
Now we're going to configure the PN532 to read MiFare cards. Then we'll wait for a card to be available and print the UID.
First we check to see if a card is available. While we're waiting we'll print .
to the serial output so we know it's still looking. If no card is found, we continue looking. When a card is found, we print the UID.
pn532.SAM_configuration() while True: uid = pn532.read_passive_target(timeout=0.5) print('.', end="", flush=True) if uid is None: continue print('Found card with UID:', [hex(i) for i in uid])
pn532.SAM_configuration() while True: uid = pn532.read_passive_target(timeout=0.5) print('.', end="", flush=True) if uid is None: continue print('Found card with UID:', [hex(i) for i in uid])
Touch a MiFare card to the breakout!
That's all there is to reading the UID from a card with CircuitPython and the PN532! For more information, check out the documentation.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT """ This example shows connecting to the PN532 with I2C (requires clock stretching support), SPI, or UART. SPI is best, it uses the most pins but is the most reliable and universally supported. After initialization, try waving various 13.56MHz RFID cards over it! """ import board import busio from digitalio import DigitalInOut # # NOTE: pick the import that matches the interface being used # from adafruit_pn532.i2c import PN532_I2C # from adafruit_pn532.spi import PN532_SPI # from adafruit_pn532.uart import PN532_UART # I2C connection: i2c = busio.I2C(board.SCL, board.SDA) # Non-hardware # pn532 = PN532_I2C(i2c, debug=False) # With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual # harware reset reset_pin = DigitalInOut(board.D6) # On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware # wakeup! this means we don't need to do the I2C clock-stretch thing req_pin = DigitalInOut(board.D12) pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) # SPI connection: # spi = busio.SPI(board.SCK, board.MOSI, board.MISO) # cs_pin = DigitalInOut(board.D5) # pn532 = PN532_SPI(spi, cs_pin, debug=False) # UART connection # uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1) # pn532 = PN532_UART(uart, debug=False) ic, ver, rev, support = pn532.firmware_version print("Found PN532 with firmware version: {0}.{1}".format(ver, rev)) # Configure PN532 to communicate with MiFare cards pn532.SAM_configuration() print("Waiting for RFID/NFC card...") while True: # Check if a card is available to read uid = pn532.read_passive_target(timeout=0.5) print(".", end="") # Try again if no card is available. if uid is None: continue print("Found card with UID:", [hex(i) for i in uid])
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT """ This example shows connecting to the PN532 with I2C (requires clock stretching support), SPI, or UART. SPI is best, it uses the most pins but is the most reliable and universally supported. After initialization, try waving various 13.56MHz RFID cards over it! """ import board import busio from digitalio import DigitalInOut # # NOTE: pick the import that matches the interface being used # from adafruit_pn532.i2c import PN532_I2C # from adafruit_pn532.spi import PN532_SPI # from adafruit_pn532.uart import PN532_UART # I2C connection: i2c = busio.I2C(board.SCL, board.SDA) # Non-hardware # pn532 = PN532_I2C(i2c, debug=False) # With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual # harware reset reset_pin = DigitalInOut(board.D6) # On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware # wakeup! this means we don't need to do the I2C clock-stretch thing req_pin = DigitalInOut(board.D12) pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin) # SPI connection: # spi = busio.SPI(board.SCK, board.MOSI, board.MISO) # cs_pin = DigitalInOut(board.D5) # pn532 = PN532_SPI(spi, cs_pin, debug=False) # UART connection # uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1) # pn532 = PN532_UART(uart, debug=False) ic, ver, rev, support = pn532.firmware_version print("Found PN532 with firmware version: {0}.{1}".format(ver, rev)) # Configure PN532 to communicate with MiFare cards pn532.SAM_configuration() print("Waiting for RFID/NFC card...") while True: # Check if a card is available to read uid = pn532.read_passive_target(timeout=0.5) print(".", end="") # Try again if no card is available. if uid is None: continue print("Found card with UID:", [hex(i) for i in uid])
Page last edited November 29, 2012
Text editor powered by tinymce.
Page last edited November 29, 2012
Text editor powered by tinymce.
Sector Block Bytes Description ------ ----- ----- ----------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Sector Block Bytes Description ------ ----- ----- ----------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 3 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer 2 [ Data ] Data 1 [ Data ] Data 0 [ Data ] Data
1 3 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer 2 [ Data ] Data 1 [ Data ] Data 0 [ Data ] Data
0 3 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer 2 [ Data ] Data 1 [ Data ] Data 0 [ Manufacturer Data ] Manufacturer Block
0 3 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer 2 [ Data ] Data 1 [ Data ] Data 0 [ Manufacturer Data ] Manufacturer Block
Sector Trailer Bytes -------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [ Key A ] [Access Bits] [ Key B ]
Sector Trailer Bytes -------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [ Key A ] [Access Bits] [ Key B ]
Value Block Bytes -------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [ Value ] [ ~Value ] [ Value ] [A ~A A ~A]
Value Block Bytes -------------------------------------------------------------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [ Value ] [ ~Value ] [ Value ] [A ~A A ~A]
Sector Block Bytes Description ------ ----- ----- ---------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Sector Block Bytes Description ------ ----- ----- ---------- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
32 15 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer 32 14 [ Data ] Data 13 [ Data ] Data ... 2 [ Data ] Data 1 [ Data ] Data 0 [ Data ] Data
32 15 [-------KEY A-------] [Access Bits] [-------KEY B-------] Sector Trailer 32 14 [ Data ] Data 13 [ Data ] Data ... 2 [ Data ] Data 1 [ Data ] Data 0 [ Data ] Data
0XFF 0XFF 0XFF 0XFF 0XFF 0XFF 0XD3 0XF7 0XD3 0XF7 0XD3 0XF7 0XA0 0XA1 0XA2 0XA3 0XA4 0XA5 0XB0 0XB1 0XB2 0XB3 0XB4 0XB5 0X4D 0X3A 0X99 0XC3 0X51 0XDD 0X1A 0X98 0X2C 0X7E 0X45 0X9A 0XAA 0XBB 0XCC 0XDD 0XEE 0XFF 0X00 0X00 0X00 0X00 0X00 0X00 0XAB 0XCD 0XEF 0X12 0X34 0X56
0XFF 0XFF 0XFF 0XFF 0XFF 0XFF 0XD3 0XF7 0XD3 0XF7 0XD3 0XF7 0XA0 0XA1 0XA2 0XA3 0XA4 0XA5 0XB0 0XB1 0XB2 0XB3 0XB4 0XB5 0X4D 0X3A 0X99 0XC3 0X51 0XDD 0X1A 0X98 0X2C 0X7E 0X45 0X9A 0XAA 0XBB 0XCC 0XDD 0XEE 0XFF 0X00 0X00 0X00 0X00 0X00 0X00 0XAB 0XCD 0XEF 0X12 0X34 0X56
[--------------------------Start of Memory Dump--------------------------] ------------------------Sector 0------------------------- Block 0 8E 02 6F 66 85 08 04 00 62 63 64 65 66 67 68 69 ?.of?...bcdefghi Block 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 3 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 1------------------------- Block 4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 7 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 2------------------------- Block 8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 11 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 3------------------------- Block 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 15 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 4------------------------- Block 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 19 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 5------------------------- Block 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 23 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 6------------------------- Block 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 27 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 7------------------------- Block 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 31 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 8------------------------- Block 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 35 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 9------------------------- Block 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 39 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 10------------------------- Block 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 43 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 11------------------------- Block 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 47 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 12------------------------- Block 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 51 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 13------------------------- Block 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 55 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 14------------------------- Block 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 59 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 15------------------------- Block 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 63 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ [---------------------------End of Memory Dump---------------------------]
[--------------------------Start of Memory Dump--------------------------] ------------------------Sector 0------------------------- Block 0 8E 02 6F 66 85 08 04 00 62 63 64 65 66 67 68 69 ?.of?...bcdefghi Block 1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 3 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 1------------------------- Block 4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 7 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 2------------------------- Block 8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 11 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 3------------------------- Block 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 15 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 4------------------------- Block 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 19 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 5------------------------- Block 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 23 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 6------------------------- Block 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 27 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 7------------------------- Block 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 31 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 8------------------------- Block 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 35 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 9------------------------- Block 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 39 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 10------------------------- Block 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 43 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 11------------------------- Block 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 47 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 12------------------------- Block 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 51 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 13------------------------- Block 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 55 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 14------------------------- Block 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 59 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ ------------------------Sector 15------------------------- Block 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 63 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF ......ÿ.?iÿÿÿÿÿÿ [---------------------------End of Memory Dump---------------------------]
Page Description ---- ------------ 0 Serial Number (4 bytes) 1 Serial Number (4 bytes) 2 Byte 0: Serial Number Byte 1: Internal Memory Byte 2..3: lock bytes 3 One-time programmable memory (4 bytes) 4..15 User memory (4 bytes)
Page Description ---- ------------ 0 Serial Number (4 bytes) 1 Serial Number (4 bytes) 2 Byte 0: Serial Number Byte 1: Internal Memory Byte 2..3: lock bytes 3 One-time programmable memory (4 bytes) 4..15 User memory (4 bytes)
Page Block 0 Block 1 Block 2 Block 3 ----- --------------------------------------- 0 [ Serial Number ] 1 [ Serial Number ] 2 [Serial] - [Intern] - [ Lock Bytes ] 3 [ One Time Programmable Memory ] 4 [ User Data ] 5 [ User Data ] 6 [ User Data ] 7 [ User Data ] 8 [ User Data ] 9 [ User Data ] 10 [ User Data ] 11 [ User Data ] 12 [ User Data ] 13 [ User Data ] 14 [ User Data ] 15 [ User Data ]
Page Block 0 Block 1 Block 2 Block 3 ----- --------------------------------------- 0 [ Serial Number ] 1 [ Serial Number ] 2 [Serial] - [Intern] - [ Lock Bytes ] 3 [ One Time Programmable Memory ] 4 [ User Data ] 5 [ User Data ] 6 [ User Data ] 7 [ User Data ] 8 [ User Data ] 9 [ User Data ] 10 [ User Data ] 11 [ User Data ] 12 [ User Data ] 13 [ User Data ] 14 [ User Data ] 15 [ User Data ]
Page Byte Values ---- ---------------------- 0 1 2 3 4 0xFF 0xFF 0xFF 0xFF 5..15 0x00 0x00 0x00 0x00
Page Byte Values ---- ---------------------- 0 1 2 3 4 0xFF 0xFF 0xFF 0xFF 5..15 0x00 0x00 0x00 0x00
Page last edited November 29, 2012
Text editor powered by tinymce.
The NFC Data Exchange Format (NDEF) is a standardised data format that can be used to exchange information between any compatible NFC device and another NFC device or tag. The data format consists of NDEF Messages and NDEF Records. The standard is maintained by the NFC Forum and is freely available for consultation but requires accepting a license agreement to download.
The NDEF format is used to store and exchange information like URIs, plain text, etc., using a commonly understood format. NFC tags like Mifare Classic cards can be configured as NDEF tags, and data written to them by one NFC device (NDEF Records) can be understood and accessed by any other NDEF compatible device. NDEF messages can also be used to exchange data between two active NFC devices in "peer-to-peer" mode. By adhering to the NDEF data exchange format during communication, devices that would otherwise have no meaningful knowledge of each other or common language are able to share data in an organised, mutually understandable manner.
Bit 7 6 5 4 3 2 1 0 ------ ------ ------ ------ ------ ------ ------ ------ [ MB ] [ ME ] [ CF ] [ SR ] [ IL ] [ TNF ] [ TYPE LENGTH ] [ PAYLOAD LENGTH ] [ ID LENGTH ] [ RECORD TYPE ] [ ID ] [ PAYLOAD ]
Bit 7 6 5 4 3 2 1 0 ------ ------ ------ ------ ------ ------ ------ ------ [ MB ] [ ME ] [ CF ] [ SR ] [ IL ] [ TNF ] [ TYPE LENGTH ] [ PAYLOAD LENGTH ] [ ID LENGTH ] [ RECORD TYPE ] [ ID ] [ PAYLOAD ]
TNF Value Record Type --------- ----------------------------------------- 0x00 Empty Record Indicates no type, id, or payload is associated with this NDEF Record. This record type is useful on newly formatted cards since every NDEF tag must have at least one NDEF Record. 0x01 Well-Known Record Indicates the type field uses the RTD type name format. This type name is used to stored any record defined by a Record Type Definition (RTD), such as storing RTD Text, RTD URIs, etc., and is one of the mostly frequently used and useful record types. 0x02 MIME Media Record Indicates the payload is an intermediate or final chunk of a chunked NDEF Record 0x03 Absolute URI Record Indicates the type field contains a value that follows the absolute-URI BNF construct defined by RFC 3986 0x04 External Record Indicates the type field contains a value that follows the RTD external name specification 0x05 Unknown Record Indicates the payload type is unknown 0x06 Unchanged Record Indicates the payload is an intermediate or final chunk of a chunked NDEF Record
TNF Value Record Type --------- ----------------------------------------- 0x00 Empty Record Indicates no type, id, or payload is associated with this NDEF Record. This record type is useful on newly formatted cards since every NDEF tag must have at least one NDEF Record. 0x01 Well-Known Record Indicates the type field uses the RTD type name format. This type name is used to stored any record defined by a Record Type Definition (RTD), such as storing RTD Text, RTD URIs, etc., and is one of the mostly frequently used and useful record types. 0x02 MIME Media Record Indicates the payload is an intermediate or final chunk of a chunked NDEF Record 0x03 Absolute URI Record Indicates the type field contains a value that follows the absolute-URI BNF construct defined by RFC 3986 0x04 External Record Indicates the type field contains a value that follows the RTD external name specification 0x05 Unknown Record Indicates the payload type is unknown 0x06 Unchanged Record Indicates the payload is an intermediate or final chunk of a chunked NDEF Record
IL: ID LENGTH Field
The IL flag indicates if the ID Length Field is preent or not. If this is set to 0, then the ID Length Field is ommitted in the record.
SR: Short Record Bit
The SR flag is set to one if the PAYLOAD LENGTH field is 1 byte (8 bits/0-255) or less. This allows for more compact records.
CF: Chunk Flag
The CF flag indicates if this is the first record chunk or a middle record chunk.
ME: Message End
The ME flag indicates if this is the last record in the message.
MB: Message Begin
The MB flag indicates if this is the start of an NDEF message.
Name Offset Size Description ---- ------ ---- ----------- Identifier Code 0 1 byte See table below URI Field 1 N bytes The rest of the URI (depending on byte 0 above)
Name Offset Size Description ---- ------ ---- ----------- Identifier Code 0 1 byte See table below URI Field 1 N bytes The rest of the URI (depending on byte 0 above)
Value Protocol ----- -------- 0x00 No prepending is done ... the entire URI is contained in the URI Field 0x01 http://www. 0x02 https://www. 0x03 http:// 0x04 https:// 0x05 tel: 0x06 mailto: 0x07 ftp://anonymous:anonymous@ 0x08 ftp://ftp. 0x09 ftps:// 0x0A sftp:// 0x0B smb:// 0x0C nfs:// 0x0D ftp:// 0x0E dav:// 0x0F news: 0x10 telnet:// 0x11 imap: 0x12 rtsp:// 0x13 urn: 0x14 pop: 0x15 sip: 0x16 sips: 0x17 tftp: 0x18 btspp:// 0x19 btl2cap:// 0x1A btgoep:// 0x1B tcpobex:// 0x1C irdaobex:// 0x1D file:// 0x1E urn:epc:id: 0x1F urn:epc:tag: 0x20 urn:epc:pat: 0x21 urn:epc:raw: 0x22 urn:epc: 0x23 urn:nfc:
Value Protocol ----- -------- 0x00 No prepending is done ... the entire URI is contained in the URI Field 0x01 http://www. 0x02 https://www. 0x03 http:// 0x04 https:// 0x05 tel: 0x06 mailto: 0x07 ftp://anonymous:anonymous@ 0x08 ftp://ftp. 0x09 ftps:// 0x0A sftp:// 0x0B smb:// 0x0C nfs:// 0x0D ftp:// 0x0E dav:// 0x0F news: 0x10 telnet:// 0x11 imap: 0x12 rtsp:// 0x13 urn: 0x14 pop: 0x15 sip: 0x16 sips: 0x17 tftp: 0x18 btspp:// 0x19 btl2cap:// 0x1A btgoep:// 0x1B tcpobex:// 0x1C irdaobex:// 0x1D file:// 0x1E urn:epc:id: 0x1F urn:epc:tag: 0x20 urn:epc:pat: 0x21 urn:epc:raw: 0x22 urn:epc: 0x23 urn:nfc:
Well Known Records
URI Record
An example of a URI record is shown in "Memory Dump of a Mifare Classic 1K Card with an NDEF Record" below.
Text Record
To Do
Smartposter Record
To Do
Absolute URI Record
To Do
Public KEY A of MAD Sectors --------------------------------------------------- BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5
Public KEY A of MAD Sectors --------------------------------------------------- BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5
Public KEY A of NFC Sectors --------------------------------------------------- BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7
Public KEY A of NFC Sectors --------------------------------------------------- BYTE 0 BYTE 1 BYTE 2 BYTE 3 BYTE 4 BYTE 5 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7
TLV Block Types Block Type Value Description ------------- ----- -------------------------------------- NULL 0x00 These blocks should be ignored NDEF Message 0x03 Block contains an NDEF message Proprietary 0xFD Block contains proprietary information Terminator 0xFE Last TLV block in the data area
TLV Block Types Block Type Value Description ------------- ----- -------------------------------------- NULL 0x00 These blocks should be ignored NDEF Message 0x03 Block contains an NDEF message Proprietary 0xFD Block contains proprietary information Terminator 0xFE Last TLV block in the data area
Byte 0: Always 0xFF to indicate that we are using the three byte format Byte 1..2: Can be a value between 0x00FF and 0xFFFE
Byte 0: Always 0xFF to indicate that we are using the three byte format Byte 1..2: Can be a value between 0x00FF and 0xFFFE
[ Start of Memory Dump ] ------------------------Sector 0------------------------- Block 0 3E 39 AB 7F D3 88 04 00 47 41 16 57 4D 10 34 08 >9«Ó?..GA.WM.4. Block 1 14 01 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 ...á.á.á.á.á.á.á Block 2 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 .á.á.á.á.á.á.á.á Block 3 00 00 00 00 00 00 78 77 88 C1 00 00 00 00 00 00 ......xw?Á...... ------------------------Sector 1------------------------- Block 4 00 00 03 11 D1 01 0D 55 01 61 64 61 66 72 75 69 ....Ñ..U.adafrui Block 5 74 2E 63 6F 6D FE 00 00 00 00 00 00 00 00 00 00 t.comþ.......... Block 6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 7 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 2------------------------- Block 8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 11 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 3------------------------- Block 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 15 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 4------------------------- Block 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 19 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 5------------------------- Block 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 23 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 6------------------------- Block 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 27 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 7------------------------- Block 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 31 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 8------------------------- Block 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 35 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 9------------------------- Block 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 39 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 10------------------------- Block 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 43 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 11------------------------- Block 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 47 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 12------------------------- Block 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 51 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 13------------------------- Block 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 55 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 14------------------------- Block 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 59 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 15------------------------- Block 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 63 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... [ End of Memory Dump ]
[ Start of Memory Dump ] ------------------------Sector 0------------------------- Block 0 3E 39 AB 7F D3 88 04 00 47 41 16 57 4D 10 34 08 >9«Ó?..GA.WM.4. Block 1 14 01 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 ...á.á.á.á.á.á.á Block 2 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 03 E1 .á.á.á.á.á.á.á.á Block 3 00 00 00 00 00 00 78 77 88 C1 00 00 00 00 00 00 ......xw?Á...... ------------------------Sector 1------------------------- Block 4 00 00 03 11 D1 01 0D 55 01 61 64 61 66 72 75 69 ....Ñ..U.adafrui Block 5 74 2E 63 6F 6D FE 00 00 00 00 00 00 00 00 00 00 t.comþ.......... Block 6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 7 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 2------------------------- Block 8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 11 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 3------------------------- Block 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 15 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 4------------------------- Block 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 19 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 5------------------------- Block 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 23 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 6------------------------- Block 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 27 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 7------------------------- Block 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 31 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 8------------------------- Block 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 35 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 9------------------------- Block 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 39 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 10------------------------- Block 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 43 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 11------------------------- Block 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 47 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 12------------------------- Block 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 51 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 13------------------------- Block 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 55 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 14------------------------- Block 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 59 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... ------------------------Sector 15------------------------- Block 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Block 63 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 .......?@...... [ End of Memory Dump ]
Block 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Char Value ----- ----------------------------------------------- ------------ 04 00 00 ..
Block 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Char Value ----- ----------------------------------------------- ------------ 04 00 00 ..
Block 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Char Value ----- ----------------------------------------------- ------------ 04 03 11 D1 01 0D 55 01 61 64 61 66 72 75 69 Ñ..U.adafrui 05 74 2E 63 6F 6D t.com
Block 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Char Value ----- ----------------------------------------------- ------------ 04 03 11 D1 01 0D 55 01 61 64 61 66 72 75 69 Ñ..U.adafrui 05 74 2E 63 6F 6D t.com
Byte(s) Value Description ------- ----- ----------- 04:02 0x03 Field Type (0x03 = NDEF Message) 04:03 0x11 Length Field (17 bytes)
Byte(s) Value Description ------- ----- ----------- 04:02 0x03 Field Type (0x03 = NDEF Message) 04:03 0x11 Length Field (17 bytes)
Byte(s) Value Description ------- ----- ----------- 04:04 0xD1 This byte is the **NDEF Record Header**, and indicates that this is an NFC Forum Well Known Record (0x01 in the first 3 bits), and that this is the first and last record (MB=1, ME=1), and that this is a short record (SR = 1) meaning the payload length is less than or equal to 255 chars (len=one byte). TNF = 0x01 (NFC Forum Well Known Type) IL = 0 (No ID present, meaning there is no ID Length or ID Field either) SR = 1 (Short Record) CF = 0 (Record is not 'chunked') ME = 1 (End of message) MB = 1 (Beginning of message) 04:05 0x01 This byte is the **Type Length** for the Record Type Indicator (see above for more information), which is 1 byte (0x55/'U' below) 04:06 0x0D This is the payload length (13 bytes) 04:07 0x55 Record Type Indicator (0x55 or 'U' = URI Record) 04:08 0x01 This is the **start of the record payload**, which contains the URI Identifier ("http://www.") since this is a URI Well-Defined Record Type (see Well-Defined Records above). This will be prepended to the rest of the URI that follows in the rest of the message payload 04:09..05:04 ... The remainder of the URI ("adafruit.com"), which combined with the pre-pended value from byte 04:08 yields: http://www.adafruit.com
Byte(s) Value Description ------- ----- ----------- 04:04 0xD1 This byte is the **NDEF Record Header**, and indicates that this is an NFC Forum Well Known Record (0x01 in the first 3 bits), and that this is the first and last record (MB=1, ME=1), and that this is a short record (SR = 1) meaning the payload length is less than or equal to 255 chars (len=one byte). TNF = 0x01 (NFC Forum Well Known Type) IL = 0 (No ID present, meaning there is no ID Length or ID Field either) SR = 1 (Short Record) CF = 0 (Record is not 'chunked') ME = 1 (End of message) MB = 1 (Beginning of message) 04:05 0x01 This byte is the **Type Length** for the Record Type Indicator (see above for more information), which is 1 byte (0x55/'U' below) 04:06 0x0D This is the payload length (13 bytes) 04:07 0x55 Record Type Indicator (0x55 or 'U' = URI Record) 04:08 0x01 This is the **start of the record payload**, which contains the URI Identifier ("http://www.") since this is a URI Well-Defined Record Type (see Well-Defined Records above). This will be prepended to the rest of the URI that follows in the rest of the message payload 04:09..05:04 ... The remainder of the URI ("adafruit.com"), which combined with the pre-pended value from byte 04:08 yields: http://www.adafruit.com
Block 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Char Value ----- ----------------------------------------------- ------------ 05 FE þ
Block 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Char Value ----- ----------------------------------------------- ------------ 05 FE þ
Page last edited November 29, 2012
Text editor powered by tinymce.
$ wget http://libnfc.googlecode.com/files/libnfc-x.x.x.tar.gz $ tar -xvzf libnfc-x.x.x.tar.gz $ cd libnfc-x.x.x
$ wget http://libnfc.googlecode.com/files/libnfc-x.x.x.tar.gz $ tar -xvzf libnfc-x.x.x.tar.gz $ cd libnfc-x.x.x
$ ./configure --with-drivers=pn532_uart --enable-serial-autoprobe
$ ./configure --with-drivers=pn532_uart --enable-serial-autoprobe
wget http://libnfc.googlecode.com/files/libnfc-1.6.0-rc1.tar.gz tar -xvzf libnfc-1.6.0-rc1.tar.gz cd libnfc-1.6.0-rc1 ./configure --with-drivers=pn532_uart --enable-serial-autoprobe sudo make sudo make install
wget http://libnfc.googlecode.com/files/libnfc-1.6.0-rc1.tar.gz tar -xvzf libnfc-1.6.0-rc1.tar.gz cd libnfc-1.6.0-rc1 ./configure --with-drivers=pn532_uart --enable-serial-autoprobe sudo make sudo make install
cd examples Kevins-Mac-mini:examples kevin$ ./nfc-poll /Users/kevin/libnfc-1.6.0-rc1/examples/.libs/nfc-poll uses libnfc 1.6.0-rc1 (r1326) NFC reader: pn532_uart:/dev/tty.usbserial-FTE5WWPB - PN532 v1.6 (0x07) opened NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations) ISO/IEC 14443A (106 kbps) target: ATQA (SENS_RES): 00 04 UID (NFCID1): 3e b9 6e 66 SAK (SEL_RES): 08
cd examples Kevins-Mac-mini:examples kevin$ ./nfc-poll /Users/kevin/libnfc-1.6.0-rc1/examples/.libs/nfc-poll uses libnfc 1.6.0-rc1 (r1326) NFC reader: pn532_uart:/dev/tty.usbserial-FTE5WWPB - PN532 v1.6 (0x07) opened NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations) ISO/IEC 14443A (106 kbps) target: ATQA (SENS_RES): 00 04 UID (NFCID1): 3e b9 6e 66 SAK (SEL_RES): 08
Page last edited November 29, 2012
Text editor powered by tinymce.
uint8_t mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen, uint32_t blockNumber, uint8_t keyNumber, uint8_t * keyData); uint8_t mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data); uint8_t mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data);
uint8_t mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen, uint32_t blockNumber, uint8_t keyNumber, uint8_t * keyData); uint8_t mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data); uint8_t mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data);
Yes, the PN532 supports peer to peer communication, but the SW support for this isn't implemented in the Adafruit libraries.
Peer to peer communication with Android is possible, for example, but the actual implementation is quite complicated on the PN532 side. You need to go through a lot of SW layers to communicate with Android in a way that it understands -- it would require developing a full NDEF stack for the messages, SNEP and LLCP stacks, etc. -- which is unfortunately well beyond the scope of what we can offer on a development board at this price point.
All of the HW requirements for this are met with the Adafruit shield and breakout board, but the stack implementation is non trivial and would require us to charge a significant premium for these boards if we implemented this.
We've focused our energy on providing a reliable, proven, properly-tuned HW reference, and enough of a SW building block to get everyone started, but there are too many holes to fill in to cover everything NFC can do with a development board at this price point.
No. The PN532 is designed to be used with ISO14443 tags, with Mifare Classic probably the most common general-purpose tag type in use.
#include <Wire.h> #include <Adafruit_NFCShield_I2C.h> #define IRQ (2) #define RESET (3) // Not connected by default on the NFC Shield Adafruit_NFCShield_I2C nfc(IRQ, RESET); void setup(void) { Serial.begin(115200); Serial.println("Hello!"); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print("Didn't find PN53x board"); while (1); // halt } // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); // configure board to read RFID tags nfc.SAMConfig(); Serial.println("Waiting for an ISO14443A card"); } void loop(void) { boolean 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 cards (Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { Serial.println("Found a 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); } else { // PN532 probably timed out waiting for a card Serial.println("Timed out waiting for a card"); } }
#include <Wire.h> #include <Adafruit_NFCShield_I2C.h> #define IRQ (2) #define RESET (3) // Not connected by default on the NFC Shield Adafruit_NFCShield_I2C nfc(IRQ, RESET); void setup(void) { Serial.begin(115200); Serial.println("Hello!"); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print("Didn't find PN53x board"); while (1); // halt } // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); // configure board to read RFID tags nfc.SAMConfig(); Serial.println("Waiting for an ISO14443A card"); } void loop(void) { boolean 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 cards (Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { Serial.println("Found a 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); } else { // PN532 probably timed out waiting for a card Serial.println("Timed out waiting for a card"); } }
Page last edited November 29, 2012
Text editor powered by tinymce.
For more details about NFC/RFID and this chip we suggest the following fantastic resources:
Page last edited November 29, 2012
Text editor powered by tinymce.