{"id":13780798,"url":"https://github.com/don/NDEF","last_synced_at":"2025-05-11T14:33:57.849Z","repository":{"id":6680471,"uuid":"7925469","full_name":"don/NDEF","owner":"don","description":"NDEF Library for Arduino. Read and Write NDEF Messages to NFC tags with Arduino.","archived":false,"fork":false,"pushed_at":"2022-10-13T08:09:43.000Z","size":195,"stargazers_count":287,"open_issues_count":41,"forks_count":144,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-11-16T22:06:47.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/don.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-30T22:37:09.000Z","updated_at":"2024-11-07T08:35:18.000Z","dependencies_parsed_at":"2023-01-11T20:09:54.686Z","dependency_job_id":null,"html_url":"https://github.com/don/NDEF","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/don%2FNDEF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/don%2FNDEF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/don%2FNDEF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/don%2FNDEF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/don","download_url":"https://codeload.github.com/don/NDEF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225064399,"owners_count":17415239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:01:19.874Z","updated_at":"2024-11-17T16:30:28.108Z","avatar_url":"https://github.com/don.png","language":"C++","readme":"# NDEF Library for Arduino\n\nRead and Write NDEF messages on NFC Tags with Arduino.\n\nNFC Data Exchange Format (NDEF) is a common data format that operates across all NFC devices, regardless of the underlying tag or device technology.\n\nThis code works with the [Adafruit NFC Shield](https://www.adafruit.com/products/789), [Seeed Studio NFC Shield v2.0](http://www.seeedstudio.com/depot/nfc-shield-v20-p-1370.html) and the [Seeed Studio NFC Shield](http://www.seeedstudio.com/depot/nfc-shield-p-916.html?cPath=73). The library supports I2C for the Adafruit shield and SPI with the Seeed shields. The Adafruit Shield can also be modified to use SPI. It should also work with the [Adafruit NFC Breakout Board](https://www.adafruit.com/products/364).\n\n### Supports \n - Reading from Mifare Classic Tags with 4 byte UIDs.\n - Writing to Mifare Classic Tags with 4 byte UIDs.\n - Reading from Mifare Ultralight tags.\n - Writing to Mifare Ultralight tags.\n - Peer to Peer with the Seeed Studio shield\n\n### Requires\n\n[Yihui Xiong's PN532 Library](https://github.com/Seeed-Studio/PN532)\n\n## Getting Started\n\nTo use the Ndef library in your code, include the following in your sketch\n\nFor the Adafruit Shield using I2C \n\n    #include \u003cWire.h\u003e\n    #include \u003cPN532_I2C.h\u003e\n    #include \u003cPN532.h\u003e\n    #include \u003cNfcAdapter.h\u003e\n    \n    PN532_I2C pn532_i2c(Wire);\n    NfcAdapter nfc = NfcAdapter(pn532_i2c);\n\nFor the Seeed Shield using SPI\n\n    #include \u003cSPI.h\u003e\n    #include \u003cPN532_SPI.h\u003e\n    #include \u003cPN532.h\u003e\n    #include \u003cNfcAdapter.h\u003e\n    \n    PN532_SPI pn532spi(SPI, 10);\n    NfcAdapter nfc = NfcAdapter(pn532spi);\n\n### NfcAdapter\n\nThe user interacts with the NfcAdapter to read and write NFC tags using the NFC shield.\n\nRead a message from a tag\n\n    if (nfc.tagPresent()) {\n        NfcTag tag = nfc.read();\n        tag.print();\n    }\n\nWrite a message to a tag\n\n    if (nfc.tagPresent()) {\n        NdefMessage message = NdefMessage();\n        message.addTextRecord(\"Hello, Arduino!\");\n        success = nfc.write(message);\n    }\n\nErase a tag. Tags are erased by writing an empty NDEF message. Tags are not zeroed out the old data may still be read off a tag using an application like [NXP's TagInfo](https://play.google.com/store/apps/details?id=com.nxp.taginfolite\u0026hl=en).\n\n    if (nfc.tagPresent()) {\n        success = nfc.erase();\n    }\n\n\nFormat a Mifare Classic tag as NDEF.\n\n    if (nfc.tagPresent()) {\n        success = nfc.format();\n    }\n\n\nClean a tag. Cleaning resets a tag back to a factory-like state. For Mifare Classic, tag is zeroed and reformatted as Mifare Classic (non-NDEF). For Mifare Ultralight, the tag is zeroed and left empty.\n\n    if (nfc.tagPresent()) {\n        success = nfc.clean();\n    }\n\n\n### NfcTag \n\nReading a tag with the shield, returns a NfcTag object. The NfcTag object contains meta data about the tag UID, technology, size.  When an NDEF tag is read, the NfcTag object contains a NdefMessage.\n\n### NdefMessage\n\nA NdefMessage consist of one or more NdefRecords.\n\nThe NdefMessage object has helper methods for adding records.\n\n    ndefMessage.addTextRecord(\"hello, world\");\n    ndefMessage.addUriRecord(\"http://arduino.cc\");\n\nThe NdefMessage object is responsible for encoding NdefMessage into bytes so it can be written to a tag. The NdefMessage also decodes bytes read from a tag back into a NdefMessage object.\n\n### NdefRecord\n\nA NdefRecord carries a payload and info about the payload within a NdefMessage.\n\n### Peer to Peer\n\nPeer to Peer is provided by the LLCP and SNEP support in the [Seeed Studio library](https://github.com/Seeed-Studio/PN532).  P2P requires SPI and has only been tested with the Seeed Studio shield.  Peer to Peer was tested between Arduino and Android or BlackBerry 10. (Unfortunately Windows Phone 8 did not work.) See [P2P_Send](examples/P2P_Send/P2P_Send.ino) and [P2P_Receive](examples/P2P_Receive/P2P_Receive.ino) for more info.\n\n### Specifications\n\nThis code is based on the \"NFC Data Exchange Format (NDEF) Technical Specification\" and the \"Record Type Definition Technical Specifications\" that can be downloaded from the [NFC Forum](http://www.nfc-forum.org/specs/spec_license).\n\n### Tests\n\nTo run the tests, you'll need [ArduinoUnit](https://github.com/mmurdoch/arduinounit). To \"install\", I clone the repo to my home directory and symlink the source into ~/Documents/Arduino/libraries/ArduinoUnit.\n\n    $ cd ~\n    $ git clone git@github.com:mmurdoch/arduinounit.git\n    $ cd ~/Documents/Arduino/libraries/\n    $ ln -s ~/arduinounit/src ArduinoUnit\n    \nTests can be run on an Uno without a NFC shield, since the NDEF logic is what is being tested.\n    \n## Warning\n\nThis software is in development. It works for the happy path. Error handling could use improvement. It runs out of memory, especially on the Uno board. Use small messages with the Uno. The Due board can write larger messages. Please submit patches.\n\n## Book\nNeed more info? Check out my book \u003ca href=\"http://www.anrdoezrs.net/click-7521423-11260198-1430755877000?url=http%3A%2F%2Fshop.oreilly.com%2Fproduct%2F0636920021193.do%3Fcmp%3Daf-prog-books-videos-product_cj_9781449372064_%2525zp\u0026cjsku=0636920021193\" target=\"_top\"\u003e\nBeginning NFC: Near Field Communication with Arduino, Android, and PhoneGap\u003c/a\u003e\u003cimg src=\"http://www.lduhtrp.net/image-7521423-11260198-1430755877000\" width=\"1\" height=\"1\" border=\"0\"/\u003e.\n\n\u003ca href=\"http://www.tkqlhce.com/click-7521423-11260198-1430755877000?url=http%3A%2F%2Fshop.oreilly.com%2Fproduct%2F0636920021193.do%3Fcmp%3Daf-prog-books-videos-product_cj_9781449372064_%2525zp\u0026cjsku=0636920021193\" target=\"_top\"\u003e\u003cimg src=\"http://akamaicovers.oreilly.com/images/0636920021193/cat.gif\" border=\"0\" alt=\"Beginning NFC\"/\u003e\u003c/a\u003e\u003cimg src=\"http://www.awltovhc.com/image-7521423-11260198-1430755877000\" width=\"1\" height=\"1\" border=\"0\"/\u003e\n\n## License\n\n[BSD License](https://github.com/don/Ndef/blob/master/LICENSE.txt) (c) 2013-2014, Don Coleman\n","funding_links":[],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdon%2FNDEF","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdon%2FNDEF","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdon%2FNDEF/lists"}