Www.elechouse.com PN532 NFC RFID Module Manual
User Manual:
Open the PDF directly: View PDF
.
Page Count: 11
| Download | |
| Open PDF In Browser | View PDF |
www.elechouse.com
PN532 NFC RFID Module User Guide
se
.c
om
Introduction
ou
NFC is a popular technology in recent years. We often heard this word while smartphone company such as Samsung or HTC
introduces their latest high-end phones. Almost all the high-end phones in the market support NFC.
le
ch
Near field communication (NFC) is a set of standards for smartphones and similar devices to establish radio communication with
each other by touching them together or bringing them into close proximity, usually no more than a few centimeters.
w
w
.e
For electronics geeks, we also want to use NFC technology to make our own things. So we build this NFC RFID module. This module is
built around NXP PN532. NXP PN532 is very popular in NFC area. And the company offers much technology document to help
developers. We developed this module based on the official document. To make things easier, we also build library for this module.
w
We almost break out all the IO pins of NXP532 on this module. Users could easily connect and play. On this module, I2C is the data
Interface by default. With our Arduino Sensor Shield V6, it is very easy to plug and play. However, if users want to use other
interface such as UART or SPI, this module also makes it easy to connect those pins.
Features
1.
Work in NFC Mode or RFID reader/writer Mode
2.
RFID reader/writer mode support
Mifare 1k, 4k, Ultralight, and DesFire cards
ISO/IEC 14443-4 cards such as CD97BX, CD light, DesFire, P5CN072 (SMX)
Innovision Jewel cards such as IRT5001 card
FeliCa cards such as RCS_860 and RCS_854
3.
4.
5.
Plug and play, Arduino compatible
Built in PCB Antenna, with 4cm~6cm communication distance
On-board level shifter, Standard 5V TTL for I2C and UART, 3.3V TTL SPI
6.
7.
Work as RFID reader/writer
Work as 1443-A card or a virtual card
www.elechouse.com
8.
9.
Exchange data with other NFC devices such as smartphone
Gold plated PCB, more durable under extreme environment
VCC: 3.3V~5V
I2C/UART: 3.3V~30V TTL
Interface: I2C (default)/UART/SPI
ch
ou
se
.c
om
Interface
w
w
w
.e
le
The I2C interface is configured as the default interface. But you could change the interface by setting the configuration pads.
The pad setting is according to the following table:
Working Interface
HIS0
HIS1
HSU
0
0
I2C
1
0
SPI
0
1
Here we use 0 ohm resistors to bridge the pad (The factory requires so for efficiency reason). In fact, Resistor is not necessary. The
pads are designed as soldering pads. It is very easy to bridge two pads with melting solder.
If you use HSU (high speed UART) , you could find the pins definition on the back of this module.
om
www.elechouse.com
In fact, we add all the pin definition on the back. It is useful for some developers. In the developer kits, we will supply pins and wires
w
w
w
.e
le
ch
ou
se
.c
for all those interface. You don’t worry about how to connect wire from the 1.27mm spacing interface.
www.elechouse.com
Hardware Installation
If without the sensor shield, please connect as following:
PN532 Module
<-------------------->
5V
<--------------------->
.e
w
w
SCL
VCC
<--------------------->
SDA
<--------------------->
SCL
w
SDA
GND
le
GND
ch
Arduino
ou
se
.c
om
With our Arduino Sensor Shield V6, just plug and play
Function Test
Here we will show you several functions of this PN532 module. We did the test with Arduino.
RFID Reader/Writer
Here we show how to read and write RFID card with this module.
Click here to download the library. We added comments in the code to help understanding.
/** include library */
#include "Wire.h"
#include "nfc.h"
/** define an nfc object */
NFC_Module nfc;
void setup(void)
{
Serial.begin(9600);
www.elechouse.com
nfc.begin();
Serial.println("MF1S50 Reader Demo From Elechouse!");
uint32_t versiondata = nfc.get_version();
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 normal mode, and disable SAM */
nfc.SAMConfiguration();
om
void loop(void)
{
u8 buf[32],sta;
se
ou
ch
le
/** check state and UID length */
if(sta && buf[0] == 4){
/** the card may be Mifare Classic card, try to read the block */
Serial.print("UUID length:");
Serial.print(buf[0], DEC);
Serial.println();
Serial.print("UUID:");
nfc.puthex(buf+1, buf[0]); // print out the UID
Serial.println();
.c
/** Polling the mifar card, buf[0] is the length of the UID */
sta = nfc.InListPassiveTarget(buf);
w
w
w
.e
/** factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF */
u8 key[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
u8 blocknum = 4;
/** Authentication block 4 */
sta = nfc.MifareAuthentication(0, blocknum, buf+1, buf[0], key);
if(sta){
/** create array to save block data read from the card*/
u8 block[16];
Serial.println("Authentication success.");
/***********************************************************
The following are examples to write data to RFID card. To
protect user’s data in RFID card. By Default we disabled it.
Please remove the annotation symbol to enable it
***********************************************************/
/*
strcpy((char*)block, "Elechouse - NFC");
sta = nfc.MifareWriteBlock(blocknum, block);
if(sta){
Serial.println("Write block successfully:");
}
*/
/***********************************************************
The following are examples to read data from RFID card.
***********************************************************/
/** read block 4 */
sta = nfc.MifareReadBlock(blocknum, block);
if(sta){
Serial.println("Read block successfully:");
www.elechouse.com
}
nfc.puthex(block, 16);
Serial.println();
/** read block 5 */
sta = nfc.MifareReadBlock(blocknum+1, block);
if(sta){
Serial.println("Read block successfully:");
}
nfc.puthex(block, 16);
Serial.println();
/** read block 6 */
sta = nfc.MifareReadBlock(blocknum+2, block);
if(sta){
Serial.println("Read block successfully:");
}
nfc.puthex(block, 16);
Serial.println();
.c
ou
}
}
ch
}
nfc.puthex(block, 16);
Serial.println();
se
}
om
/** read block 7 */
sta = nfc.MifareReadBlock(blocknum+3, block);
if(sta){
Serial.println("Read block successfully:");
w
w
w
.e
le
Uploading the code to Arduino, and then open the Serial Monitor on Arduino IDE:
Put the card above the antenna.
www.elechouse.com
w
w
w
.e
le
ch
ou
se
.c
om
Then you could get output:
If you enable the code of wring card
strcpy((char*)block, "Elechouse - NFC");
sta = nfc.MifareWriteBlock(blocknum, block);
if(sta){
Serial.println("Write block successfully:");
}
You will get the following output:
www.elechouse.com
om
You wrote string "Elechouse - NFC" to block 4, and then you read from block 4 the following data:
45 6C 65 63 68 6F 75 65 73 20 2D 20 4E 46 43 00
.c
Those are Hex ASCII code of the string "Elechouse - NFC". You could change the code to output strings.
se
NFC
ch
ou
Here we need two Arduino boards to test this function. Basically we will program one NFC module as Initiator, and the other as
Target.
NFC_p2p_target
.e
NFC_p2p_initiator
w
w
w
le
Please upload the following two examples to the two Arduino board:
After uploading the sketches, open the Serial Monitor. Please note that Arduino IDE doesn’t support opening 2 Serial Monitors. So
you need another Serial Tool. Here we have 2 versions of Arduino IDE installed in my PC: Arduino 0022 and Arduino 1.0. We open the
two and could have two Serial Monitor working. Note the baud rate is 115200.
www.elechouse.com
om
Target:
w
w
w
.e
le
ch
ou
se
.c
Initiator:
Then put one module above the other:
Finally we get:
www.elechouse.com
om
Target:
w
w
w
.e
le
ch
ou
se
.c
Initiator:
Useful link
PN532 Module Schematic PDF
NXP PN532 User Manual
NXP Mifare One S50 IC
Where to buy
Please visit this page to buy this product: PN532 NFC RFID module kits
Disclaimer and Revisions
The information in this document may change without notice. If you have any problem about it, please visit www.elechouse.com to
contact us.
Revision History
www.elechouse.com
Rev.
Date
A
Oct. 25 , 2012
Description
Wilson
Initial version
w
w
w
.e
le
ch
ou
se
.c
om
th
Author
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.6 Linearized : Yes Encryption : Standard V4.4 (128-bit) User Access : Print, Extract, Print high-res Author : wilson Create Date : 2012:11:29 17:14:55+08:00 Modify Date : 2012:11:29 17:20:44+08:00 Has XFA : No Language : en-US Tagged PDF : Yes XMP Toolkit : Adobe XMP Core 5.2-c001 63.139439, 2010/09/27-13:37:26 Format : application/pdf Creator : wilson Title : www.elechouse.com Creator Tool : Microsoft® Word 2010 Metadata Date : 2012:11:29 17:20:44+08:00 Producer : Microsoft® Word 2010 Document ID : uuid:1e91dee3-abc9-43e1-a80a-50b0a8c84112 Instance ID : uuid:03936784-3b77-42e0-9188-5838064e4e4e Page Count : 11EXIF Metadata provided by EXIF.tools