/PN532

NFC library for Arduino using PN532

Primary LanguageC++

NFC library for Arduino

This is an Arduino library for PN532 to use NFC technology. It's based on Adafruit_NFCShield_I2C , improved by Seeed Studio, added HSU(High Speed Uart) driver by Elechouse.

It works with:

Features

  • Support all interfaces of PN532 (I2C, SPI, HSU )
  • Read/write Mifare Classic Card
  • Works with Don's NDEF Library
  • Support Peer to Peer communication(exchange data with android 4.0+)
  • Support mbed platform

Getting Started

  1. Download zip file and extract the three folders(PN532, PN532_SPI, PN532_HSU and PN532_I2C) into libraries of Arduino.
  2. Downlaod Don's NDEF library and extract it into libraries of Arduino's into a new folder called "NDEF" (Note if you leave this folder as NDEF-Master Arduino will not be able to use it as a library)
  3. Follow the examples of the PN532 library

To do

  • Card emulation

HSU Interface

HSU is short for High Speed Uart. HSU interface needs only 4 wires to connect PN532 with Arduino, Sensor Shield can make it more easier. For some Arduino boards like Leonardo, DUE, Mega ect, there are more than one Serial on these boards, so we can use this additional Serial to control PN532, HSU uses 115200 baud rate .

To use the Serial1 control PN532, refer to the code below.

#include <PN532_HSU.h>
#include <PN532.h>

PN532_HSU pn532hsu(Serial1);
PN532 nfc(pn532hsu);

void setup(void)
{
	nfc.begin();
	//...
}

If your Arduino has only one serial interface and you want to keep it for control or debugging with the Serial Monitor, you can use the SoftwareSerial library to control the PN532 by emulating a serial interface. Include PN532_SWHSU.h instead of PN532_HSU.h:

#include <SoftwareSerial.h>
#include <PN532_SWHSU.h>
#include <PN532.h>

SoftwareSerial SWSerial( 10, 11 ); // RX, TX

PN532_SWHSU pn532swhsu( SWSerial );
PN532 nfc( pn532swhsu );

void setup(void)
{
	nfc.begin();
	//...
}