Connect NFC-Reader to RaspberryPi

NFC - Near Field Communication - is a short range (<10cm) contactless communication protocol. Many Smartphone have an NFC-Chip and several tags (stickers, cards, kesy rings, ...) are available. How can I use an NFC reader (e.g. on a raspberryPi? To read tags or exchange data with smartphones.
1 answer

Libnfc and Libfreefare

Libnfc ( is an open source library for Linux.
Unlike most NFC drivers this is a completely free MFC library and tool collection.

at first check if your reader hardware is compatible:
This is not a complete list. If your reader is not listed but the NFC-controller PN53x, you have a god chance that it will work.

If you want to read/write Mifare (Classic and Desfire) Tags, install the Libfreefare API first. It adds some mifare specific functions, so you can handle MIFARE Tags much easier.


sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install libssl-dev

get sources and extract
tar -xvjf libfreefare-0.4.0.tar.bz2

cd libfreefare-0.4.0
autoreconf -vis
./configure --prefix=/usr
sudo make install

get sources and extract
tar xfvj libnfc-1.7.1.tar.bz2

create configuration directory
mkdir /etc/nfc/
mkdir /etc/nfc/devices.d

create config file e.g. /etc/nfc/devices.d/nfc_arygon.conf.
name = "NFC Arygon"
connstring = arygon:/dev/ttyUSB0
allow_intrusive_scan = true
allow_autoscan = true

connstring is the most important option. If you have a different NFC-Controller or it is not connected by USB, you have to change this string.
for more configuration Options :
btw. the brand "Arygon" is now "Identive"

install libnfc
cd libnfc-1.7.1/
./configure --with-drivers=arygon --sysconfdir=/etc --prefix=/usr
sudo make clean
sudo make install all

(--with-drivers adept, if you have a different NFC Controller. eg. pn532_uart if you have a serial connected reader.)

Test the installation with the included examples.
cd examples

This lists all the connected and recognized NFC-Readers. Try a restart if it does not work. Check the connstring and --with-drivers parameters.

and hold a tag over the reader (<4cm) to read a tag.

Type ls to show all examples. Read the example sources to use the API for your own projects.