ITEAD PN532 NFC module is equipped with a double-row pin, which can be connected directly to the Raspberry Pie via connection cable and then drive the module for non-contact near field communication operations, such as reading and writing 13.56M IC card with our ITEAD PN532 NFC SPI Library.
First, before installing the library offered by us, we need to modify some of the configurations of Raspberry Pie to make SPI module automatically activated when powering on:
cd / etc / modprobe.d /
Enter the Configuration folder
sudo nano raspi-blacklist.conf
Open the configuration file as superuser
# blachlist sip-bcm2708
Comment out that line, to achieve SPI module loading when powering on.
Then, you can unzip the library we provided. Let’s take placing to the desktop as an example:
cd / home/pi/Desktop/ITEAD_PN532_NFC
Enter the Library folder
Install ITEAD PN532 NFC library
Thus our database has been compiled and installed. As long as the project file contains nfc.h, functions in the library can be called. During compiling, the called library functions can be compiled by adding –INFC in the command line.
Take DEMO provided in our library as an example:
gcc readID.c -o readID -l NFC
Compile readID routine file
sudo. / readID
Run the compiled routine file – as long as the 13.56M IC card approaches NFC module, the ID N.O, of the card will be displayed on the monitor.
Following is a brief description of some of the functions in the library:
Begin(): Begin to communicate with the ITEAD NFC module
SAMConfig(): Configure RPI to read RFID tags and cards
Return: false or true
getFirmwareVersion(): Get the firmware version of the NFC module
Return: the number of the firmware version(fail will return 0);
Usage: I = getFirmwareVersion();
readPassiveTargetID(uint8_t cardbaudrate): Get the passive target card ID
Return: the ID of the card(fail will return 0);
Usage: I = readPassiveTargetID(PN532_MIFARE_ISO14443A);
authenticateBlock(cardnumber, cid, blockaddress, authtype, * keys): Authenticate the block
Authenticate the block
authenticateBlock(cardnumber, cid, blockaddress, authtype, * keys)
uint8_t cardnumber: 1 or 2;
uint32_t cid: Card NUID;
uint8_t blockaddress:0 to 63;
uint8_t authtype: Either KEY_A or KEY_B;
uint8_t * keys
Return: true or false;
readMemoryBlock(cardnumber, blockaddress, block): Read a block(16 bytes) from the tag and stores in the parameter
-uint8_t cardnumber, can be 1 or 2;
-blockaddress, range from 0 to 63;
-uint8_t* block, will save 16bytes that read from tag.
Return: true or false
writeMemoryBlock( cardnumber, blockaddress, * block): Write a block(16 bytes) to the tag
-uint8_t cardnumber,can be 1 or 2;
-blockaddress,range from 0 to 63;
-uint8_t* block,saves 16bytes that will write to the tag.
Return: true or false
ITEAD Raspbrerry PI PN532 NFC Library (36.0 KiB, 10,633 hits)