Home

Adafruit PN532 RFID/NFC Breakout and Shield

image

Contents

1. amp adafruit learning system About the NDEF Format NDEF NFC Data Exchange Format 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 http adafru it aSA 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 Some helpful app notes and white papers relating to NDEF are listed below e NFC Data Exchange Format NDEF Technical Specification http adafru it aSA requires accepting the license terms e NFC Record Type Definition RTD Specification http adafru it aSA requires accepting the license terms e NXP White Paper NFC Forum Typ
2. a E a PN532 Breakout v1 Schematic http adafru it d71 You can also grab the Eagle CAD PCB files from github e https github com adafruit Adafruit PN532 RFID NFC Shield http adafru it dik e https github com adafruit Adafruit PN532 RFID NFC Breakout http adafru it dil Adafruit Industries Last Updated 2014 04 17 09 46 00 PM EDT Page 35 of 35
3. http learn adafruit com adafruit pn532 rfid nfc ndef gt NDEF lt a gt lt span class pdf short link gt http adafru it aXr lt span gt features are experimental and incomplete Only very basic test code has been written to format a card for NDEF messages in a way that any NFC enabled Android phone should be able to understand it and it was written and an extremely simple proof of concept lt br gt lt br gt We would like to improve NDEF support for Mifare tags in the near future and some initial planning has gone into this but at the moment our suggestion is to stick to plain text and vanilla lt a href http learn adafruit com adafruit pn532 rfid nfc mifare title Link http learn adafruit com adafruit pn532 rfid nfc mifare gt Mifare Classic lt a gt lt span class pdf short link gt http adafru it aXs lt span gt reads and writes You can read and write Mifare Classic and Mifare Ultralight blocks from Android and you don t need to used the more complicated NDEF standard to simply pass data back and forth via a Mifare Classic or Ultralight card lt i class icon exclamation sign gt lt i gt lt i class icon exclamation sign gt lt i gt Note Please use the limited NDEF code with care Formatting cards for NDEF support is currently a one way operation and should only be performed on cards you can dedicate to NDEF use Does the PN532 support peer to peer communication to talk with my smartphone Adaf
4. it s own features and peculiarities The two most common formats are described below e Mifare Classic http adafru it cl7 These cards are extremely common and contain 1K or 4K of EEPROM with basic security for each 64 byte 1K 4K cards or 256 byte 4K cards sector e Mifare Ultralight http adafru it cl7 Contains 512 bytes of EEPROM including 32 bits of OTP memory These tags are inexpensive often come in sticker format and are are frequently used for transportation ticketing concert tickets etc Active Communication Peer to Peer Active or Peer to Peer communication is still based around the Initiator Target model described earlier but both devices are actively powered and switch roles from being an Initiator or a Target during the communication When one device is initiating a conversation with the other it enables it s magnetic field and the receiving device listens in with it s own magnetic field disabled Afterwards the target recipient device may need to respond and will in turn activate it s own magnetic field and the original device will be configured as the target Despite two devices being present only one magnetic field is active at a time with each device constantly enabling or disabling its own magnetic field ToDo Add better description of active mode but need to test it out a bit first myself NFC Data Exchange Format NDEF The NFC Data Exchange Format NDEF is a standardised data format that can
5. since each sector can have it s own distinct access keys and rights Note on Authentication Before you can do access the sector s memory you first need to authenticate according to the security settings stored in the Sector Trailer By default any new card will generally be configured to allow full access to every block in the sector using Key A and a value of OxFF OxFF OxFF OxFF OxFF OxFF Some other common keys that you may wish to try if this doesn t work are EE SE eee Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 15 of 35 OXFF OXFF OXFF OXFF OXFF OXFF OXD3 OXF7 OXD3 OXF7 OXD3 OXF7 OXAO OXA1 OXA2 OXA3 0XA4 OXA5 OXBO OXB1 0XB2 OXB3 0XB4 OXB5 0X4D 0X3A 0X99 0XC3 0X51 OXDD OX1A 0X98 OX2C OX7E 0X45 OX9A OXAA OXBB OXCC OXDD OXEE OXFF 0X00 0X00 0X00 0X00 0X00 0X00 OXAB OXCD OXEF 0X12 0X34 0X56 Example of a New Mifare Classic 1K Card The follow memory dump illustrates the structure of a 1K Mifare Classic Card where the data and Sector Trailer blocks can be clearly seen 8E 02 6F 66 85 08 04 00 62 63 64 65 66 67 68 69 0f ocdefghi 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 00 00
6. uid 0 0 0 0 0 0 fer t he r uidLength Length of the UID 4 or 7 b if success printin print UI print uidLength DEC printin by print UID Va for i 0 i lt uidLength i print F print uid i HEX rintin ontinuing Hey wait isn t there something funny with the SVDD pin Indeed good eye Unfortunately both v1 0 and v1 3 of the breakout boards have a problem on the schematic SVDD is connected directly to VDD but should be left floating since it is used to power secure modules This has no effect on the functionality of the boards but does cause some extra current to be drawn It will be fixed on the next revision of the board but if you require the use of the secure modules rare you can simply cut the trace to the left of C22 which is the cap connected to SVDD just follow the trace straight up from pin 37 lt span gt lIndeed good eye Unfortunately both v1 0 and v1 3 of the breakout boards have a problem on the schematic SVDD is connected directly to VDD but should be left floating since itis used to power secure modules This has no effect on the functionality of the boards but does cause some extra current to be drawn It will be fixed on the next revision of the board but if you require the use of the secure modules rare you can simply cut the trace to the left of C22 which is the cap connected to SVDD just follow the trace straight up from pin 37 lt span gt
7. 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 7 10 ze 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 2 11 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 16 of 35 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF V 2iVyWVVV 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF a 15 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 61 00 00 00 00 00 00 00 00 00 00
8. 21 Test Records 21 Smart Poster Records 22 Example NDEF Records 22 Using Mifare Classic Cards as an NDEF Tag 22 Mifare Application Directory MAD 22 Mifare Application Directory 1 MAD1 23 Mifare Application Directory 2 MAD2 23 MAD Sector Access 23 Storing NDEF Messages in Mifare Sectors 23 TLV Blocks 23 Memory Dump of a Mifare Classic 1K Card with an NDEF Record 24 NDEF Records 25 Using with LibNFC 27 Using the PN532 Breakout Boards with libnfc 27 libnfc In Linux Ubuntu 10 10 used in this example 27 Step One Download libnfc 27 Step Two Configure libnfc for PN532 and UART 27 Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 3 of 35 Step Three Build and install libnfc 28 Step Four Check for installed devices 28 Step Five Poll for an 1SO014443A Mifare etc Card 28 lionfc With Mac OSX Lion 29 Download and build libnfc and configure if for PN532 UART making the code changes above before running make 29 If everything worked out switch to the examples folder and see if you can find the PN532 and wait for an appropriate tag 29 FAQ 30 Downloads 35 Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 4 of 35 adafruit learning system Overview Hey So this is not a full tutorial its just a quickstart guide while we do more research into RFID NFC There s a lot of info here but not everything is explained in detail We hope to fill out the tutorial but there
9. Are there any special requirements to use the PN532 Breakout with the Due While the libraries do not officially support the Due yet some customers have been able to get them working with some minor changes to the library We recommend using the 12C libraries with both the shield and the breakout boards since the I2C library represents the latest code from Adafruit and the shield version should work without too much effort There is one caveat combining the breakout I2C and the Due though The Due includes pullup resistors for I2CO SCLO and SDA1 but there are no pullups resistors on SCL1 and SDA1 SCL1 SDA1 are the pins used as replacements for the Uno I2C pins the pins used on standard shields so you will need to add two 1 5K pullups on SCL1 and SDA1 to use the breakout board with I2C1 and the Due Simply solder two 1 5K resistors one from SCL1 to 3V3 and another from SDA1 to 3 3V and then connect the board the same way you would with an Uno This issue only applies to the PN532 Breakout board since the PN532 shield includes I2C pullup resistors right on board While the libraries do not officially support the Due yet some customers have been able to get them working with some minor changes to the library lt br gt lt br gt We recommend using the I2C libraries with both the shield and the breakout boards since the I2C library represents the latest code from Adafruit and the shield version should work without too much effort lt br g
10. URI Field This field provides the URI as per RFC 3987 and contains the rest of the URI after the value corresponding to the URI Identifier is prepended unless the URI ID is 0x00 in which case the complete URI will be contained in the URI Field Test Records To Do Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 21 of 35 Smart Poster Records To Do Example NDEF Records 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 Using Mifare Classic Cards as an NDEF Tag Mifare Classic 1K and 4K cards can be configured as NFC Forum compatible NDEF tags but they must be organised in a certain manner to do so The requirements to make a Mifare Classic card NFC Forum compliant are described in the following App Note from NXP AN1304 NFC Type MIFARE Classic Tag Operation http adafru it aSP While the App Note above is the authoritative source on the matter the following notes may also offer a quick overview of the key concepts involved in using Mifare Classic cards as NFC Forum compatible NDEF tags Mifare Application Directory MAD In order to form a relationship between the sector based memory of a Mifare Classic card and the individual NDEF records the Mifare Application Directory MAD structure is used The MAD indica
11. block in the data area Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 23 of 35 Length Field The Length Field or L Field contains the size in bytes of the value field The Length Field can be organised in two different ways using either one or three bytes The one byte format simple contains a single byte value from 0x00 0xFF The three byte format consists of the following format OxFF to indicate that we are using the three byte format be a value between OxOOFF and OxFFFE Both the one byte and three byte format must be supported for NFC Forum and NDEF compatability Value Field The Value Field or V Field is only present if the Length Field described above is present and not equal to 0x00 If the Length Field is not equal to 0 the Value Fields will contain N bytes of data in the format indicated by the T Field above The value field is where the payload an NDEF Message for example is stored Terminator TLV The Terminator TLV is the last TLV block in the data area and consist of a single byte OxOFE see the TLV Block Type table above This TLV Block in mandatory Memory Dump of a Mifare Classic 1K Card with an NDEF Record 3E 39 AB 7F D3 88 04 00 47 41 16 57 4D 10 34 08 gt 9 lt 00 GA WM 4 14700 OS ENO3 EMOS EOS NOs Fl 0303 ELE aia 03 E1 03 El 03 E1 03 E1 03 E103 E103 E103 E1 35 30 49 00 00 00 00 00 00 78 77 88 C1 00 00 00 00 00 00 xw 00 00 03 11 D101 0D 5
12. s not a lot of good information about NFC so it s taking a bit of time Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 5 of 35 adafruit learning system Breakout Wiring This part of the tutorial is specifically for the Breakout board We show how to use it with SPI The breakout also supports TTL serial and I2C but we don t have a tutorial for using it that way as SPlis the most cross platform method to communicate If you re using the shield check the next page Wiring the Breakout for SPI The PN532 chip and breakout is designed to be used by 3 3V systems To use it with a 5V system such as an Arduino a level shifter is required to convert the high voltages into 3 3V If you have a 3 3V embedded system you won t have to use the shifter of course To begin we ll solder in the header to the breakout board You ll need two small 3 pin pieces of header and one 8 pin piece You can break these off of a large piece Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 6 of 35 Solder the two small pieces to the SELO and SEL1 pads These are interface selectors for the chip Depending on how the jumpers are inserted the chip will talk in TTL serial i2c or SPI Also solder a strip to the end so you can plug it into a breadboard Wire up the 4050 level shifter chip to the Arduino as shown The notch in the 4050 is at the top Adafruit Industries https l
13. the PN532 NFC RFID Breakout http adafru it 364 and NFC Shield http adafru it 789 Can I have multiple shields on one Arduino Nope the I2C library can have only one address per bus and the address is not adjustable So one shield per Arduino please Nope the 12C library can have only one address per bus and the address is not adjustable So one shield per Arduino please lt br gt Can read or write to Mifare tags with the PN532 and Adafruit Libraries Absolutely The Adafruit libraries include functions to authenticate read and write individual blocks to Mifare Classic cards Before you can read or write a block you need to authenticate it with the appropriate key and once the block is authenticated you can read and write to your hearts content For example the key functions in the 12C library http adafru it aSW which was written to go along with the NFC shield http adafru it 789 since it defaults to I2C are Absolutely The Adafruit libraries include functions to authenticate read and write individual blocks to Mifare Classic cards Before you can read or write a block you need to authenticate it with the appropriate key and once the block is authenticated you can read and write to your hearts content lt br gt lt br gt For example the key functions in the lt a href https github com adafruit Adafruit_NFCShield_I2C gt I2C library lt a gt lt span class pdf short link gt http adafru it aSW lt span gt whic
14. 0 00 00 00 00 00 00 00 00 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 63 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 0 of NDEF Records The above example contains two records both located in sector 1 sector 0 contains the MAD Record 1 The first record on the card can be identified by looking at the first byte of block 4 in sector 1 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Every record on the Mifare card starts with the TLV Block described above and the first byte of the TLV Block the Tag Field indicates that this is a NULL Block type value 0x00 The second byte is the Length Field and is 0 Since there is no payload for this record Length 0 the third byte of the TLV block is not present the Value Field This record was likely inserted when the card was first formatted to ensure that at least one record is present Record 2 The second record on the card starts at byte 0x02 of block 4 and continues into block 5 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 03 11 D1 01 0D 55 01 61 64 61 66 7275 69 N U adafrui 05 74 2E 63 6F 6D tcom 04 02 0x03 0x03 NDEF 04 03 0x11 17 bytes Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 25 of 35 This indicates to us that the record contains an NDEF Message value 0x03 and that the message is 17 bytes long 0x11 in hexadecimal 17 in decimal valu
15. 00 00 00 00 00 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 63 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF MiFare Ultralight Cards MiFare Ultralight cards typically contain 512 bits 64 bytes of memory including 4 bytes 32 bits of OTP One Time Programmable memory where the individual bits can be written but not erased MFOICU1 MiFare Ultralight Functional Specification http adafru it aSN MiFare Ultralight cards have a 7 byte UID that uniquely identifies the card EEPROM Memory MiFare Ultralight cards have 512 bits 64 bytes of EEPROM memory including 4 byte 32 bits of OTP memory Unlike Mifare Classic cards there is no authentication on a per block level although the blocks can be set to read only mode using Lock Bytes described below EEPROM memory is organised into 16 pages of four bytes eachs in the following order 4 bytes 4 bytes 0 Ly 2 3 lock bytes time programmable memory 4 bytes memory 4 bytes Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 17 of 35 Lock Bytes Page 2 Bytes 2 and 3 of page 2 are referred to as Lock Bytes Each page from 0x03 and higher can individually locked by setting the corresponding locking bit to 1 to prevent further write access effectively making the memory read only For more information on the lock byte mechanism refer to section 8 5 2 of the datasheet referenced above OTP Bytes Page 3 P
16. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 23 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF i ga 36 00 00 00 00
17. 4 adafruit learning system Adafruit PN532 RFID NFC Breakout and Shield Created by lady ada Last updated on 2014 04 17 09 45 55 PM EDT Guide Contents Guide Contents Overview Breakout Wiring Wiring the Breakout for SPI Shield Wiring Solder the Headers Using the Adafruit NFC Shield with l2C Using with the Arduino Leonardo Arduino Library Which Library I2C Library FOR USE WITH THE SHIELD ONLY SPI Library FOR USE WITH THE BREAKOUT BOARD ONLY Testing MiFare About NFC NFC Near Field Communication Passive Communication IS014443A Cards Mifare etc Active Communication Peer to Peer NFC Data Exchange Format NDEF Reading MiFare Cards amp Tags MiFare Classic Cards EEPROM Memory 4 Block Sectors 16 Block Sectors Accessing EEPROM Memory Note on Authentication Example of a New Mifare Classic 1K Card MiFare Ultralight Cards EEPROM Memory Lock Bytes Page 2 Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc oOo On DM OP 11 11 11 11 11 12 12 12 12 12 13 14 14 14 14 15 15 15 16 17 17 18 Page 2 of 35 OTP Bytes Page 3 18 Data Pages Page 4 15 18 Accessing Data Blocks 18 Read Write Lengths 18 About the NDEF Format 19 NDEF NFC Data Exchange Format 19 NDEF Messages 19 NDEF Records 19 Record Header Byte 0 19 Type Length 20 Payload Length 20 ID Length 20 Record Type 20 Record ID 20 Payload 20 Well Known Records TNF Record Type 0x01 21 URI Records 0x55 U
18. 5 01 61 64 61 66 72 7569 N U adafrui 74 2E 63 6F 6D FE 00 00 00 00 00 00 00 00 00 00 tcomp 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 23 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 Adafruit Industries https learn adaf
19. O14443A Mifare etc Card Next you can use the nfc poll example to wait 30 seconds for an ISO14443A card or tag and display some basic information about this card In the examples folder that we changed to above run the following command nfc poll This should give you some basic information on any card that entered the magnetic field within the specified delay Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 28 of 35 x kevin VirtualBox UbuntuDev Projects libnfc 1 4 1 examples File Edit View Search Terminal Help kevin VirtualBox UbuntuDev Projects lLibnfc 1 4 1 examples nfc list home kevin Projects lLibnfc 1 4 1 examples libs lt nfc list use libnfc 1 4 1 r 869 Connected to NFC device PN532 dev ttyUSBO PN532 v1 6 0x07 kevin VirtualBox UbuntuDev Projects Libnfc 1 4 1 examples nfc poll home kevin Projects libnfc 1 4 1 examples libs 1t nfc poll use libnfc 1 4 1 r 869 Connected to NFC reader PN532 dev ttyUSBO PN532 v1 6 0x07 PN532 will poll during 30000 ms 1 target s have been found T1 ISO IEC 14443A 106 kbps target ATQA SENS RES 00 04 UID NFCID1 3e 39 ab 7f SAK SEL RES 08 kevin VirtualBox UbuntuDev Projects lLibnfc 1 4 1 examples lionfc With Mac OSX Lion scott 42 was kind of enough to post some tips on getting libnfc working on a Mac using an FTDI adapter A couple simple changes to the code were required as of v1 6 0 rc1 with the
20. The first step is to solder the headers to the shield Cut the header strip to length and insert the sections long pins down into an Arduino Then place the shield on top and solder each pin PNS32 RFID N 13 56M e A Satruit A P ro 120 lesve SELO and SELLA open For spt close SELG enc SELI 29990796S npn yO 1 stOvety e Sv Sag Lin Se Pee ok amp ast 3 Using the Adafruit NFC Shield with I2C The Adafruit NFC shield is designed to be used using the I2C by default I2C only uses two pins Analog 4 and 5 which are fixed in hardware and cannot be changed to communicate and one pin as an interrupt pin Digital 2 can be changed however What is nice about I2C is that it is a shared bus unlike SPI and TTL serial so you can put as many sensors as you d like all on the same two pins as long as their addresses don t collide conflict The Interrupt pin is handy because instead of constantly asking the NFC shield is there a card in view yet what about now constantly the chip will alert us when a NFC target comes into the antenna range The shield is drop in compatible with any Classic Arduino UNO Duemilanove Diecimilla etc Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 9 of 35 using the ATmegal68 or 328 as well as any Mega R3 or later Mega R2 Arduinos work as well but you need to solder a wire from the http adafru it aUS SDA http adafru it aUS and ht
21. age 3 is the OTP memory and by default all bits on this page are set to 0 These bits can be bitwise modified using the MiFare WRITE command and individual bits can be set to 1 but can not be changed back to 0 Data Pages Page 4 15 Pages 4 to 15 are can be freely read from and written to provided there is no conflict with the Lock Bytes described above After production the bytes have the following default values Accessing Data Blocks In order to access the cards you must following two steps 1 Connect to a Mifare Ultralight card and retrieve the 7 byte UID of the card 2 Memory can be read and written directly once a passive mode connection has been made No authentication is required for Mifare Ultralight cards Read Write Lengths For compatability reasons Read requests to a Mifare Ultralight card will retrieve 16 bytes 4 pages at a time which corresponds to block size of a Mifare Classic card For example if you specify that you want to read page 3 in reality pages 3 4 5 and 6 will be read and returned and you can simply discard the last 12 bytes if they aren t needed If you select a higher page the 16 byte read will wrap over to page 0 For example reading page 14 will actually return page 14 15 0 and 1 Write requests occur in pages 4 bytes so there is no problem with overwriting data on subsequent pages Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 18 of 35
22. al purpose tag type in use For more information on supported tags see lt a href http www libnfc org documentation hardware tags iso14443 gt http www lipnfc org documentation hardware tags iso14443 lt a gt lt span class pdf short link gt http adafru it aSV lt span gt or search for information on the common Mifare tag family based on ISO1443A Can I set a delay calling readPassiveTargetID Note This question only applies to the 2C Library http adafru it aSW The SPI library http adafru it aSX doesn t handle the timing the same way readPassiveTargetID intentionally waits around in a blocking delay until a card enters the magnetic field The reason for this blocking delay is to ensure a well understood command response flow Once the magnetic field is activated and a read request is sent via readPassiveTargetID you can keep sending new commands to the PN532 but the moment a card or tag enters the field the PN532 will send a response to the initial read request even if it s Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 31 of 35 in the middle of some other response or activity To avoid having to debug this in SW a blocking delay was implemented to keep the command response pattern as clear as possible As a workaround to this blocking delay limitation setPassiveActivationRetries maxRetries was added to the latest NFC libraries to allow you to set a specific timeout after read reques
23. ator generates a small magnetic field that powers the target meaning that the target does not require a power source This means of communication is referred to as Passive Communication and is used to read and write to small inexpensive 13 56MHz RFID tags based on standards like ISO14443A Active communication peer to peer is also possible when both devices are powered where each device alternately creates its own magentic field with the secondary device as a target and vice versa in continuous rotation Passive Communication 15014443A Cards Mifare etc While the PN53x family of transceivers from NXP are compatible with a number of 13 56MHz RFID card standards by far the most popular standard is IS014443A A variety of manufacturers produce ISO14443A compatible cards or chips but the most common are based around the Mifare family from NXP Mifare Classic and Mifare Ultralight are probably the most frequently encountered and useful for basic projects though many tags with improved security and encryption also exist Mifare DESFire etc All of the tags sold at adafruit com are Mifare Classic 1K meaning that they contains 1K 1024 bytes of programmable EEPROM memory which can be read and modified in passive mode by the initiator device the PN532 While all IS014443A cards share certain common characteristics on the highest level defined by the four part standard each set of Mifare chips Classic Ultralight Plus DESFire etc has
24. 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 http adafru it aSA 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 Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 12 of 35 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 The NDEF standard includes numerous Record Type Definitions RTDs that define how information like URIs should be stored and each NDEF device tag or message can contained multiple RTDs Standard RTD definitions are described in NFC Record Type Definition RTD Specification maintained by the NFC Forum NDEF Overview http adafru it cl7 This page offers a more detailed explanation of NDEF includ
25. details here http adafru it aP1 Keeping in mind the code changes mentionned above the following steps should get libnfc compiling and working via an FTDI type adapter and UART on Lion using libnfc 1 6 0_rc1 Download and build libnfc and configure if for PN532 UART making the code changes above before running make wget http tar xvzf libnfc cd libnfc 1 6 0 rc1 configure with drivers pn532_uart enable serial autoprobe sudo make sudo make install If everything worked out switch to the examples folder and see if you can find the PN532 and wait for an appropriate tag 2 arene kevin nfc poll if kevin libnfc 1 6 0 rc1 examples libs nfc poll uses libnfc 1 6 0 rc1 r1326 NFC reader pn532_uart dev tty usbserial FTESWWPB 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 There are some dependencies to get libnfc running but since it isn t an Adafruit project and we can t really support it directly ourselves you will probably have better luck looking at the libnfc forums http adafru it aST for Mac support There are a few active users developping on the Mac Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 29 of 35 amp adafruit learning system FAQ Some of the more common questions on the forums related to
26. e This means that our NDEF message is contained in the next 17 bytes 04 04 05 04 The NDEF record can then be analysed as follows is the NDEF and indicates that th in the first 3 bits s the first and record MB 1 ME 1 rt record SR 1 meaning the payload length is less than or equal to chars len one TNF NFC IL ID present meaning there is no ID or ID either hun of message of message is the see above more information which is U below is the payload length 13 bytes or U URI is the start of the record payload which contains the since this is a URI above will be prepended to the rest of the URI that follows in the rest of the message payload remainder of the URI m which combined pre pended value 08 yields http TLV Terminator The final byte block 5 byte 5 with the value OxFE is the TLV Terminator and indicates that this is the end of the TLV Block Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 26 of 35 amp adafruit learning system Using with LibNFC Using the PN532 Breakout Boards with lionfc libonfc http adafru it aSR is a mature cross platform open source NFC library that can be easily configured to work with the PN532 Breakout Board While Linux is probably the easiest platform to use libnfc with it can be configured for the Mac and Windows as well though you may need to dig around on the libnfc C
27. e Tags http adafru it aSO NDEF Messages NDEF Messages are the basic transportation mechanism for NDEF records with each message containing one or more NDEF Records NDEF Records NDEF Records contain a specific payload and have the following structure that identifies the contents and size of the record MB ME CF SR ILI T TNF TYPE LENGTH PAYLOAD LENGTH ID LENGTH RECORD TYPE ID PAYLOAD Record Header Byte 0 The record header contains a number of important fields including a 3 bit field that identifies the type of record that follows the Type Name Format or TNF TNF Type Name Format Field The Type Name Format or TNF Field of an NDEF record is a 3 bit value that describes the record type and sets the expectation for the structure and content of the rest of the record Possible record type names include no type id or payload is associated with this NDEF record type is useful on newly formatted cards since every NDEF tag Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 19 of 35 must have at least one NDEF the type field uses the RTD type name format type name is used to stored any record ya RTD such RTD RTD etc and is one of the mostly frequently used a record types MIME the payload is an intermediate or final chunk of a chunked NDEF URI the type field contains a value that follows the absolute URI BNF construct d d by RFC the
28. earn adafruit com adafruit pn532 rfid nfc Page 7 of 35 in this image e Arduino digital pin 2 is connected to 4050 pin 9 orange wire e Arduino digital pin 3 is connected to 4050 pin 11 yellow wire e Arduino digital pin 4 is connected to 4050 pin 14 green wire On the breakout board e 3 3Vin is connected to the Arduino 3 3V pn e SCK is connected to 4050 pin 10 orange wire e MISO is connected to Arduino pin 5 blue wire e MOST is connected to 4050 pin 12 yellow wire e SSEL is connected to 4050 pin 15 amp green wire e GND connects to Arduino ground black wire 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 onthe Arduino Also we need to select SPI as the interface so on SEL1 place the jumper in the ON position for SELO place the jumper in the OFF position That s it Later on you can change what Arduino pins you are using but for the beginning test we suggest matching our wiring If you are using the shield in I2C mode you will also need to add two 1 5K pullups on the SCL SDA lines since the breakout and the Arduino don t include the pullups Simply solder or add a 1 5K resistor between SCL and 3 3V and SDA and 3 3V and then connect the breakout as you normally would Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 8 of 35 adafruit learning system Shield Wiring Solder the Headers
29. ected using KEY B if you wish to limit the ability of customers to modify the card contents The public KEY A will ensure that they can always read the data Storing NDEF Messages in Mifare Sectors NDEF messages records may be stored in any sector of the Mifare card other than the sector s use by the MAD or sectors beyond the 1K range if a MAD1 table is used When a sector is used to store NDEF records it is referred to as an NFC Sector As with the MAD Sector s described above these sectors must always be accessible in at least read only mode and as such a common public KEY A also exists for NFC Sectors though it is not the same KEY A used in the MAD sector s KEY A of NFC In order to store an NDEF Message on the Mifare Classic card the message needs to be wrapped inside something called a TLV Block The basic structure of a TLV Block is described below TLV Blocks TLV is an abbreviation for three different fields T for Tag Field L for Length Field and V for Value Field A TLV Block consist of one or more bytes depending on which of these three fields is present Note that the TLV Block will always be at least one byte since the T Field is mandatory in every case Tag Field The Tag Field or T Field is the only mandatory field and uses a single byte to identify the type of TLV block accordingly to a pre determined table of values blocks should be ignored contains an NDEF message contains proprietary information TLV
30. ess the folder and rename the folder Adafruit_NFCShield_I2C Inside the folder you should see the Adafruit_NFCShield_I2C cpp and Adafruit_NFCShield_12C h files Install theAdafruit_NFCShield_1I2C 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 http adafru it aYG Restart the Arduino IDE You should now be able to select File gt Examples gt Adafruit_NFCShield_I2C gt readMifare sketch Upload the sketch to your Arduino with the shield plugged in SPI Library FOR USE WITH THE BREAKOUT BOARD ONLY Download the PN532 SPI library from github http 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 http adafru it aYG Restart the Arduino IDE You should now be able to select File gt Examples gt Adafruit_PN532 gt readMifare sketch Upload the sketch to your Arduino wired as in our tutorial Testing MiFare In the serial monitor you should see that it found the PN532 chip Then you can place your tag nearby and it will displa
31. fid nfc Page 27 of 35 kevin VirtualBox UbuntuDev Projects libnfc 1 4 1 File Edit View Search Terminal Help Status creating Doxyfile Status creating Makefile Status creating cmake modules Makefile fig status creating examples Makefile Status creating examples pn53x tamashell scripts Makefile ig status creating include Makefile g status creating include nfc Makefile Status creating Libnfc pc Status creating Libnfc Makefile ig status creating Libnfc buses Makefile g status creating Libnfc chips Makefile Status creating Libnfc drivers Makefile ig status creating test Makefile Status creating config h ig status executing depfiles commands Status executing libtool commands Selected drivers arygon pn531 usb pn532 uart pn533 usb kevin VirtualBox UbuntuDev Projects Libnfc 1 4 1 J Step Three Build and install libnfc You can build and install libnfc with the following three commands also run from the folder where the original archive was unzipped make clean make make install Step Four Check for installed devices Now that libnfc is hopefully built and installed you can run the nfc list example to try to detect an attached NFC board Make sure the board is connected to the FTDI or USB UART adapter and that it is connected to your PC and run the following commands cd examples nfc list This should list the devices that were detected Step Five Poll for an 1S
32. h was written to go along with the lt a href http www adafruit com products 789 gt NFC shield lt a gt lt span class pdf short link gt http adafru it 789 lt span gt since it defaults to I2C are mifareclassic_AuthenticateBlock uid uidLen blockNumber keyNumber keyData mifareclassic_ReadDataBlock blockNumber data mifareclassic_WriteDataBlock blockNumber data This is all you need to start reading and writing data and you can verify the data using one of many Android applications that support working with Mifare cards a search for NFC will turn up plenty What level of NDEF support is included in the libraries At the moment all NDEF http adafru it aXr features are experimental and incomplete Only very basic test code has been written to format a card for NDEF messages in a way that any NFC enabled Android phone should be able to understand it and it was written and an extremely simple proof of concept We would like to improve NDEF support for Mifare tags in the near future and some initial planning has gone into this but at the moment our suggestion is to stick to plain text and vanilla Mifare Classic http adafru it aXs reads and writes You can read and write Mifare Classic and Mifare Ultralight blocks from Android and you don t need to used the more complicated NDEF standard to simply pass data back and forth via a Mifare Classic or Ultralight card At the moment all lt a href
33. ifferent for each sector Due to these security features which are stored in the last block called the Sector Trailer only the bottom 3 blocks of each sector are actually available for data storage meaning you have 48 bytes per 64 byte sector available for your own use Each 4 block sector is organised as follows with four rows of 16 bytes each for a total of 64 bytes per sector The first two sectors of any card are shown Sector Trailer Block 3 The sector trailer block contains the two secret keys Key A and Key B as well as the access conditions for the four blocks It has the following structure Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 14 of 35 A Il ty Bae For more information in using Keys to access the clock contents see Accessing Data Blocks further below Data Blocks Blocks 0 2 Data blocks are 16 bytes wide and depending on the permissions set in the access bits can be read from and written to You are free to use the 16 data bytes in any way you wish You can easily store text input store four 32 bit integer values a 16 character uri etc Data Blocks as Value Blocks An alternative to storing random data in the 16 byte wide blocks is to configure them as Value Blocks Value blocks allow performing electronic purse functions valid commands are read write increment decrement restore transfer Each Value block contains a single signed 32 bit value a
34. ing how Mifare Classic cards can be used to store NDEF messages NOTE The dedicated NDEF page is still a work in progress and some information is currently incomplete Reading For more details about NFC RFID and this chip we suggest the following fantastic resources e RFID selection guide http adafru it aSC a lot of details about RFID in general e Nokia s Introduction to NFC http adafru it aSD a lot of details about NFC in general e NXP S50 chip datasheet http adafru it aSE the chip inside MiFare classic tags e NXP PN532 Short Form Datasheet http adafru it aSF e NXP PN532 Long Form Datasheet http adafru it aSG e NXP PN532 User Manual http adafru it aSH e NXP PN532 App Note http adafru it aS e Using PN532 with libnfc http adafru it aSj e NFC Glossary http adafru it aSK Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 13 of 35 amp adafruit learning system MiFare Cards amp Tags MiFare is one of the four 13 56MHz card protocols FeliCa is another well known one All of the cards and tags sold at the Adafruit shop use the inexpensive and popular MiFare Classic chipset MiFare Classic Cards MIFARE Classic cards come in 1K and 4K varieties While several varieties of chips exist the two main chipsets used are described in the following publicly accessible documents e MF1S503x Mifare Classic 1K data sheet http adafru it aSL e MF1S70yyX MIFARE Cla
35. middle of some other response or activity To avoid having to debug this in SW a blocking delay was implemented to keep the command response pattern as clear as possible lt br gt lt span gt lt br gt As a workaround to this blocking delay limitation lt strong gt setPassiveActivationRetries maxRetries lt strong gt was added to the latest NFC libraries to allow you to set a specific timeout after read requests lt br gt lt br gt By default the PN532 will wait forever for a card to enter the field By specifying a fixed number of retries via lt strong gt MxRtyPassiveActivation lt strong gt see UM section 7 3 1 describing the lt strong gt RFConfiguration lt strong gt register specifically Cfgltem 5 the PN532 will abort the read request after specified number of attempts and you can safely send new commands without worrying about mixing up response frames To wait forever set MxRtyPassiveActivation to OxFF To timeout after a fixed number of retries set MxRtyPassiveActivation to anything less than OxFF lt br gt lt br gt lt span gt Example Sketch lt span gt lt br gt nfc IRQ RESET versiondata nfc getFirmwareVersion if versiondata printi printiIn versiondata gt gt 24 amp ima print versiondata gt gt 16 amp printin versiondata gt gt 8 amp DEG 14443A card Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 32 of 35 oid loop void ean success
36. nd this value is stored 3 times for data integrity and security reasons It is stored twice non inverted and once inverted The last 4 bytes are used for a 1 byte address which is stored 4 times twice non inverted and twice inverted Data blocks configured as Value Blocks have the following structure Manufacturer Block Sector 0 Block 0 Sector 0 is special since it contains the Manufacturer Block This block contains the manufacturer data and is read only It should be avoided unless you know what you are doing 16 Block Sectors 16 block sectors are identical to 4 block sectors but with more data blocks The same structure described in the 4 block sectors above applies Accessing EEPROM Memory To access the EEPROM on the cards you need to perform the following steps 1 You must retrieve the 4 byte NUID of the card this can sometimes be 7 bytes long as well though rarely for Mifare Classic cards This is required for the subsequent authentication process 2 You must authenticate the sector you wish to access according to the access rules defined in the Sector Trailer block for that sector by passing in the appropriate 6 byte Authentication Key ex OxFF OxFF OxFF OxFF OxFF OxFF for new cards 3 Once authenication has succeeded and depending on the sector permissions you can then read write increment decrement the contents of the specific block Note that you need to re authenticate for each sector that you access
37. ommunity Forums for some specific details on compiling dils for Windows etc If you want to test the PN532 Breakout Board out with libnfc this simple tutorial should walk you through the absolute basics of compiling and configuring libnfc and using some of the canned example SW included in the library This is only for using the PN532 breakout with an FTDI cable or FTDI Friend to a proper computer You cannot run LIbNFC on an Arduino or other microcontroller libnfc In Linux Ubuntu 10 10 used in this example Step One Download libnfc Download the latest version of libnfc from Google Code http adafru it aSS ex libnfc 1 4 1 tar gz and extract the contents of the file as follows wget http tar xvzf libnfc x x x tar gz cd libnfc x x x Step Two Configure libnfc for PN532 and UART libnfc currently only supports communication over UART using any inexpensive USB to UART adapter like the FTDI Friend or a TTL FTDI cable Before compiling however you will need to configure libnfc to include support for UART and the PN532 chipset which can be done with the following commmand executing in the folder where the above archive was unzipped configure drivers pn532_uart enable serial autoprobe Note If you also wish to include debug output you can add the enable serial autoprobe flag minus the single quotes to the configure options Adafruit Industries https learn adafruit com adafruit pn532 r
38. red for NFC based P2P communication with a Blackberry device are apparently much lower than on Android Does the PN532 support tag emulation Yes but in reality it s impossible to implement since it requires an external secure element http adafru it aXu that is very difficult to source under export control and general NDA from the few manufacturers of them If you can get one we d love to see it though Yes but in reality it s impossible to implement since it requires an external lt a href http nearfieldcommunication com developers nfc architecture gt secure element lt a gt lt span class pdf short link gt http adafru it aXu lt span gt that is very difficult to source under export control and general NDA from the few manufacturers of them If you can get one we d love to see it though Can the PN532 read Tag lt tags from TI No The PN532 is designed to be used with ISO14443 http adafru it aSU tags with Mifare Classic probably the most common general purpose tag type in use For more information on supported tags seehttp www libnfc org documentation hardware tags iso14443 http adafru it aSV or search for information on the common Mifare tag family based on ISO1443A No The PN532 is designed to be used with lt a href http en wikipedia org wiki ISO IEC_14443 gt ISO14443 lt a gt lt span class pdf short link gt http adafru it aSU lt span gt tags with Mifare Classic probably the most common gener
39. ruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 30 of 35 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 For an example of communicating with a phone via NFC though have a look at Talking With Your Arduino via NFC on Blackberry http adafru it aXt which uses the Adafruit NFC Shield The SW layers required for NFC based P2P communication with a Blackberry device are apparently much lower than on Android Yes the PN532 suppor
40. ruit com adafruit pn532 rfid nfc Page 24 of 35 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 0 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 0 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 0 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 7F 07 88 40 00 00 00 00 00 00 0 60 00 00 00 00 00 00 00 0
41. ssic 4K data sheet http adafru it aSM Mifare Classic cards typically have a 4 byte NUID that uniquely within the numeric limits of the value identifies the card It s possible to have a 7 byte IDs as well but the 4 byte models are far more common for Mifare Classic EEPROM Memory Mifare Classic cards have either 1K or 4K of EEPROM memory Each memory block can be configured with different access conditions with two seperate authentication keys present in each block Mifare Classic cards are divided into section called sectors and blocks Each sector has individual access rights and contains a fixed number of blocks that are controlled by these access rights Each block contains 16 bytes and sectors contains either 4 blocks 1K 4K cards for a total of 64 bytes per sector or 16 blocks 4K cards only for a total of 256 bytes per sector The card types are organised as follows e 1K Cards 16 sectors of 4 blocks each sectors 0 15 e 4K Cards 32 sectors of 4 blocks each sectors 0 31 and 8 sectors of 16 blocks each sectors 32 39 4 Block Sectors 1K and 4K cards both use 16 sectors of 4 blocks each with the bottom 1K of memory on the 4K cards being organised identically to the 1K models for compatability reasons These individual 4 block sectors containing 64 byts each have basic security features are can each be configured with seperate read write access and two different 6 byte authentication keys the keys can be d
42. t corresponse to the value entered in the TNF bits of the record header Record ID The value of the ID field if an ID is included the IL bit in the record header is set to 1 If the IL bit is set to 0 this field is ommitted Payload The record payload which will be exactly the number of bytes described in the Payload Length field earlier Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 20 of 35 Well Known Records TNF Record Type 0x01 Probably the most useful record type is the NFC Forum Well Known Type TNF Type 0x01 Record types that adhere to the Well Defined type are each described by something called an RTD or Record Type Definition Some of the current Well Defined RTDs are URI Records 0x55 U The Well Known Type for a URI record is 0x55 U and this record type can be used to store a variety of useful information such as telephone numbers tel website addresses links to FTP file locations etc URI Records are defined in the document URI Record Type Definition from the NFC Forum and it has the following structure table below N bytes rest of the URI depending on byte 0 above The URI Identifier Code is use to shorten the URI length and can have any of the following values news telnet imap rts p urn pop sip sips urn epc id urn epc tag urn epc pat urn epc raw urn epc urn nfc Following the URI Identifier Code is the
43. t lt br gt There is one caveat combining the breakout I2C and the Due though lt b gt The Due includes pullup resistors for I2CO SCLO and SDA1 but there are no pullups resistors on SCL1 and SDA1 lt b gt SCL1 SDA1 are the pins used as replacements for the Uno Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 33 of 35 I2C pins the pins used on standard shields so you will need to add two 1 5K pullups on SCL1 and SDA1 to use the breakout board with I2C1 and the Due Simply solder two 1 5K resistors one from SCL1 to 3V3 and another from SDA1 to 3 3V and then connect the board the same way you would with an Uno lt br gt lt br gt lt b gt This issue only applies to the PN532 Breakout board since the PN532 shield includes 12C pullup resistors right on board lt b gt Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 34 of 35 Downloads adafruit learning system e SPI library is available from github http adafru it aSX e 2C library is available from github http adafru it aSW Version 1 3 schematic click to enlarge F z 7 7 L3 z z T P AA a A A i ies Eel g a 6 ai i P ANTENNA MATCHING CIRCUET s gt ele a z 0 eve ey i i ce L Firn bg cai a a f 9 te io ie IT f Aart Fi l ioe e I z Ls j L p h 4 a lel E lt H ee k ma rekou viS 1720 2013 trans om Seon 1 1 Ee icwee aanicrodullder eu 5 u z i Z i
44. tes which sector s contains which NDEF record The definitive source of information on the Mifare Application Directory is the following application note AN10787 MIFARE Application Directory MAD http adafru it aSQ For reference sake the two types of MADs depending on the size of the card in question are defined below Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 22 of 35 Mifare Application Directory 1 MAD1 MAD1 can be used in any Mifare Classic card regardless of the size of the EEPROM although if it is used with cards larger than 1KB only the first 1KB of memory will be accessible for NDEF records The MAD1 is stored in the Manufacturer Sector Sector 0x00 on the Mifare Classic card Mifare Application Directory 2 MAD2 MAD2 can only be used on Mifare Classic cards with more than 1KB of storage Mifare Classic 4K cards etc It is NOT compatible with cards containing only 1KB of memory The MAD2 is stored in sectors 0x00 the Manufacturer Sector and 0x10 MAD Sector Access The sectors containing the MAD1 0x00 and MAD2 0x00 and 0x10 are protected with a KEY A and KEY B if you re not familiar with this concept consult the Mifare Classic summary elsewhere in the PN532 NFC wiki To ensure that these sectors can be read by any application the following common KEY A should always be used KEY A of MAD BYTE BYTE BYTE BYTE The MAD sector may optionally be write prot
45. tp adafru it aUS SCL http adafru it aUS pin holes to the Mega s I2C pins on Digital 20 and 21 http adafru it aUS Using with the Arduino Leonardo The IRQ pin is tied to Digital pin 2 by default However on the Arduino Leonardo digital 2 is used for I2C which will not work If using with a Leonardo cut the trace beween the IRQ pin and Digital 2 and solder a wire from IRQ pin to Digital 4 or higher Then change the example code so the the IRQ pin is declared as the new pin say 6 not 2 Here are some photos of setting the IRQ pin to digital 6 First use a sharp hobby knife to cut the trace from IRQ to 2 Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 10 of 35 amp adafruit learning system Arduino Library Which Library We have two libraries hopefully will be merged into one shortly for the Adafruit NFC boards One library is for SPI interfacing and one is for I2C Both have the same functionality capability and function names they just differ in whether they talk to the PN532 chip with I2C or with SPI For the breakout we assume you ll be using the SPI library For the shield we assume you ll be using the 12C library Both libraries have the ability to read MiFare cards including the hard coded ID numbers as well as authenticate and read write EEPROM chunks I2C Library FOR USE WITH THE SHIELD ONLY Download the PN532 I2C library from github http adafru it aSW Uncompr
46. ts By default the PN532 will wait forever for a card to enter the field By specifying a fixed number of retries via MxRtyPassiveActivation see UM section 7 3 1 describing the RFConfiguration register specifically Cfgitem 5 the PN532 will abort the read request after specified number of attempts and you can safely send new commands without worrying about mixing up response frames To wait forever set MxRtyPassiveActivation to OxFF To timeout after a fixed number of retries set MxRtyPassiveActivation to anything less than OxFF Example Sketch lt strong gt Note lt strong gt This question only applies to the lt a href https github com adafruit Adafruit_NFCShield_I2C gt I2C Library lt a gt lt span class pdf short link gt http adafru it aSW lt span gt The lt a href https github com adafruit Adafruit PN532 gt SPI library lt a gt lt span class pdf short link gt http adafru it aSX lt span gt doesn t handle the timing the same way lt br gt lt br gt lt span gt readPassiveTargetID intentionally waits around in a blocking delay until a card enters the magnetic field The reason for this blocking delay is to ensure a well understood command response flow Once the magnetic field is activated and a read request is sent via readPassiveTargetID you can keep sending new commands to the PN532 but the moment a card or tag enters the field the PN532 will send a response to the initial read request even if it s in the
47. ts peer to peer communication but the SW support for this isn t implemented in the Adafruit libraries lt br gt lt br gt 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 lt br gt lt br gt 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 lt br gt lt br gt 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 lt br gt lt br gt For an example of communicating with a phone via NFC though have a look at lt a href http devblog blackberry com 2012 12 talking with your arduino via nfc on blackberry gt Talking With Your Arduino via NFC on Blackberry lt a gt lt span class pdf short link gt http adafru it aXt lt span gt which uses the Adafruit NFC Shield The SW layers requi
48. type field contains a value that follows the RTD external name specification the payload type is unknown the payload is an intermediate or final chunk of a chunked NDEF 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 BeginThe MB flag indicates if this is the start of an NDEF message Type Length Indicates the length in bytes of the Record Type field This value is always zero for certain types of records defined with the TNF Field described above Payload Length Indicates the length in bytes of the record payload If the SR field described above is set to 1 in the record header this value will be one byte long for a payload length from 0 255 bytes If the SR field is set to 0 this value will be a 32 bit value occupying 4 bytes ID Length Indicates the length in bytes of the ID field This field is present only if the IL flag described above is set to 1 in the record header Record Type This value describes the type of record that follows The values of the type field mus
49. y the 4 byte ID code this one is OxAE 0x4C OxFO 0x6C and then the integer version of all four bytes together You can use this number to identify each card Recently NXP made so many cards that they actually ran through all 4 Bytes 2 32 so the number is not guaranteed to be absolutely unique However the chances are extremely slim you will have two cards with the same ID so as long as you aren t using these cards for anything terribly important like money transfer its fine to use the number as a unique identifier COM27 SEE Hello Found chip PN532 Firmware ver 1 6 Supports 7 Found 1 tags Sens Response Ox4 Sel Response 0x8 OxAE Ox4C OxFO Ox6C Read card 2924277868 v Autoscroll Carriage return Y 9600 baud Adafruit Industries https learn adafruit com adafruit pn532 rfid nfc Page 11 of 35 amp adafruit learning system About NFC NFC Near Field Communication NFC Near Field Communication is a set of short range typically up to 10cm wireless communication technologies designed to offer light weight and secure communication between two devices While NFC was invented by NXP Phillips at the time Nokia and Sony the main body behind the NFC standard today is the NFC Forum http adafru it aSy who are responsible for publishing and maintaining a variety of standards relating to NFC technology NFC operates at 13 56MHz and is based around an initiator and target model where the initi

Download Pdf Manuals

image

Related Search

Related Contents

消費電力量測定・算出ガイド - SII 一般社団法人 環境共創イニシアチブ  EV501, EV511, EV502, EV512, EV503, EV504, EV505, EV506    S1+ トランシーバー 2013-2014  ECHA - REACH-IT Industry User Manual: Part 17 Legal Entity Change  11 消耗部品の交換方法  Inspection Certificate Art. Nr. ELQ16-2209-1    User Manual - Boca Scientific Laboratory Products  

Copyright © All rights reserved.
Failed to retrieve file