Arduino NFC

Maker Faire - September 21, 2014

Don Coleman


NFC Data Exchange Format

NDEF Message

One or more NDEF Records

NDEF Record

Contains a payload of data

Information describing the payload

Text Record

hello, world

  • TNF = Well Known
  • Type = T
  • Payload = 2 + en + hello, world

Adafruit NFC Shield

Seeed Studio NFC Shield

PN532 Library Based on Adafruit's Library and modified by Yihui Xiong to support both I2C and SPI

NDEF Library

for Arduino



Write Tag

Read Tag

NDEF Record

  • TNF = Mime Media
  • Type = text/led
  • Payload = 0,0,255
 if (nfc.tagPresent()) {
   NfcTag tag =;
   NdefMessage message = tag.getNdefMessage();
   NdefRecord record = message[0];

   if (record.getTnf() == TNF_MIME_MEDIA &&
       record.getType() == "text/led") {
     String payload = getPayloadAsString(record);
     color = parseColor(payload);
     // turn on the lights


Peer to Peer

Simple NDEF Exchange Protocol (SNEP)

Setup for P2P

  #include "SPI.h"
  #include "PN532_SPI.h"
  #include "snep.h"
  #include "NdefMessage.h"

  PN532_SPI pn532spi(SPI, 10);
  SNEP nfc(pn532spi);
  uint8_t ndefBuf[128];

Send Message to Peer

  NdefMessage message = NdefMessage();

  int messageSize = message.getEncodedSize();
  nfc.write(ndefBuf, messageSize));

Receive Message from Peer

  int size =, sizeof(ndefBuf));
  if (size > 0) {
    NdefMessage msg = NdefMessage(ndefBuf, size);
  } else {
    Serial.println("Error reading message");


Android Apps for NFC

Read Tags PhoneGap NFC Reader

Format and Unformat Mifare Classic Tags NXP Tag Writer

View Raw Data on Tag NFC TagInfo by NXP

View Raw Data on Tag NFC Tag Info

Thank You

Don Coleman




Creative Commons License
Arduino NFC by Don Coleman
is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at