NFC is a reality today. A lot of cities in the world want to add this technology to their daily life, using it for transport, payments, access systems and almost all we can think (in some countries, like Japan and Korea, NFC is used years ago). Even reading NFC tags can be used to perform certain actions in our mobile phones like put it in flight mode, synchronize data, etc.
NFC is based on the ISO/IEC 18092 standard, published at the end of 2003, and it's compatible with other standards like ISO/IEC 14443 A/B (RFID) and ISO/IEC 15693 (FeliCa - Sony). As probably you know, it's a short distance wireless technology (normally < 10cm), high frequency (13'56 MHz) and low speed (normally until 424 Kbps). Unlike RFID, NFC is capable to perform bidirectional communications, and the time to establish the communication is much lower than using Bluetooth.
The aim of this blog post is not explaining how NFC works but giving some advice to setup a lab and start playing with this technology. The first thing we need is a NFC reader/writer. After looking around the most used are the following:
The first three devices include a PN53x chip, use the PC/SC stack and USB as connection interface. There is another option, the fourth one, and it's buying a board with this chip model, made by Adafruit Industries in this case. This is a more flexible option because we can choose between different ways to connect to our computer and other details you can find out taking a look at its specification. It's important to take into account that our device must be compatible with the most active NFC software projects, like libnfc and nfcpy. We can also use a NFC capable mobile phone like Samsung Galaxy Nexus, of course, but I think if we want to develop our own tools maybe it's easier to work with a reader/writer connected to our computer.
I'm going to focus on the NFC board I've mentioned (PN532). When it's received at home it's not ready to work. Some pins must be soldered to be able to choose between the different communication interfaces (UART, SPI or I2C). If you use a FTDI cable other 5 pins must be also soldered to have something to connect in the board (the 5 left pins in the image below). There are some web sites very helpful to perform these steps and you can always ask questions in the Adafruit forum.
Now we have the hardware ready, it's time to install the proper software. The most mature project talking about developing NFC tools seems to be libnfc, created in early 2009. If you prefer using Python you can find pynfc and nfcpy, being the latter the most active and recommendable out of the two. We can find a lot of information about installing libnfc in the official web page, but also in other sites and forums. Focusing on Ubuntu the steps we can take to install it are the following (some package versions and names can be different depending on distributions, tested with Ubuntu 10.04):
$ sudo apt-get install libusb-dev libpcsclite-dev
$ sudo apt-get install libusb-0.1-4 libpcsclite1 libccid pcscd libftdi1
$ wget http://libnfc.googlecode.com/files/libnfc-x.x.x.tar.gz
$ tar -xvzf libnfc-x.x.x.tar.gz
$ cd libnfc-x.x.x
$ ./configure --with-drivers=pn532_uart --enable-serial-autoprobe
$ make clean
$ make install
If it's all right, putting a RFID card or a NFC tag close to the reader and using the nfc-list command we should see something like this:
Our lab is almost ready. The only missing thing is that we need something to read with our toy. We could choose one of the different RFID cards we use daily at gyms, buses, work, etc., but I think it would be better using a real NFC payment card or similar. If we don't have any of this we can buy some NFC Forum tags to make some tests with our reader or our smartphone. In following blog posts I will show what we can do now we have the lab ready, stay tune! ;)