Loading...

You have no items in your shopping cart.

 
 
 
×

Registration

Profile Informations

Login Datas

or login

First name is required!
Last name is required!
First name is not valid!
Last name is not valid!
This is not an email address!
Email address is required!
This email is already registered!
Password is required!
Enter a valid password!
Please enter 6 or more characters!
Please enter 16 or less characters!
Passwords are not same!
Terms and Conditions are required!
Email or Password is wrong!
Captcha is required!
Captcha is wrong!

Raspberry Pi Drives ITEAD PN532 NFC Module with libnfc

ITEAD PN532 NFC module is equipped with double-row pins, 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. Users can buy this module from here.

libnfc is the first libre low level NFC SDK and Programmers API released under the GNU Lesser General Public License. It provides complete transparency and royalty-free use for everyone. The library currently supports modulations for ISO/IEC 14443 A and B, FeliCa, Jewel/Topaz tags and Data Exchange Protocol (P2P) as target and as initiator. For more information, please refer to this page

The following tutorial demonstrates how to use libnfc on Raspberry Pi to drive ITEAD PN532 module with the SPI bus.

1, Hardware connection

As Itead PN532 Module is customized for Raspberry Pi, it can be connected directly to Raspberry Pi via the adapter cable, as shown in the picture below:

According to the connection in the picture above, Itead PN532 Module is connected via the SPI bus with raspberry pi, and therefore, the operating mode of PN532 Module should be set to SPI mode, as shown below:

    SET0-->L
    SET1-->H

If you want to use I2C mode of PN532 module, you should set the code as below:

    SET0-->H
    SET1-->L

Before installation of the needed software, please do the configuration first, as given below.

Raspberry Pi Software Configuration

sudo raspi-config

Choose to configure SPI, I2C, and Serial.

2, Install the software pack needed

sudo apt-get update
sudo apt-get install libusb-dev libpcsclite-dev

3, Download and compress source code pack of libnfc

cd ~
wget http://dl.bintray.com/nfc-tools/sources/libnfc-1.7.1.tar.bz2
tar -xf libnfc-1.7.1.tar.bz2  

4, Compile and install

cd libnfc-1.7.1
./configure --prefix=/usr --sysconfdir=/etc
make
sudo make install 

5, Modify configuration file

cd /etc
sudo mkdir nfc
sudo nano /etc/nfc/libnfc.conf

Copy and paste the following contents to file /etc/nfc/libnfc.conf:

# Allow device auto-detection (default: true)
# Note: if this auto-detection is disabled, user has to manually set a device
# configuration using file or environment variable
allow_autoscan = true

# Allow intrusive auto-detection (default: false)
# Warning: intrusive auto-detection can seriously disturb other devices
# This option is not recommended, so user should prefer to add manually his/her device.
allow_intrusive_scan = false

# Set log level (default: error)
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
# Note: if you compiled with --enable-debug option, the default log level is "debug"
log_level = 1

# Manually set default device (no default)
# To set a default device, users must set both name and connstring for their device
# Note: if autoscan is enabled, default device will be the first device available in device list.
device.name = "Itead_PN532_SPI"
device.connstring = "pn532_spi:/dev/spidev0.0:500000"

6, As Raspberry Pi defaults to disable the driver for SPI module, we need to enable it

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Add # in front of blacklist spi-bcm2708 and it will become #blacklist spi-bcm2708

As shown in the picture below

You can see two spi devices under /dev after rebooting.

7, So far, the preparations are done. So now we can use command nfc-list to check if it is successfully installed.

Let's try swiping the card.

8, Configurations for connection via I2C bus

8.1 Software configuration

Enable I2C bus on Raspberry Pi, and change blacklist i2c-bcm2708 in /etc/modprobe.d/raspi-blacklist.conf to #blacklist i2c-bcm2708

Add i2c-dev at the end of /etc/modules

Modify last line of /etc/nfc/libnfc.conf to pn532_i2c:/dev/i2c-1 as shown in the picture below

8.2 Hardware connection

Connection is as shown in the picture below:

Running result is as shown in the picture below:

Appendix: Related links

A1. libnfc configuration method: http://nfc-tools.org/index.php?title=Libnfc:configuration

A2. libnfc installation tutorial: http://nfc-tools.org/index.php?title=Libnfc

A3. libnfc user API: http://nfc-tools.org/index.php?title=Libnfc:API

A4. libnfc main page: http://nfc-tools.org/index.php?title=Main_Page

A5. libnfc tutorial: http://nfc-tools.org/index.php?title=Category:Libnfc:Examples

A6. Iteadstudio PN532 Module website: http://imall.iteadstudio.com/im130625002.html

A7. Disable R-Pi/RASPBIAN serial console for using UART0: http://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi