Sunday, January 19, 2014

Raspberry Pi: clean install of NFCPY

NFCPY is a Python library allowing for Near Field Communications readers to be accessed directly from Raspberry Pi. As part of a project I am working on, I needed to install this library on a clean Raspbian install of a Raspberry Pi.

Once the installation was completed I used the base ‘history’ command to retrieve all the commands that I typed in the terminal to accomplish this task. I removed all the commands that were wrong or superfluous.

Please note that this was a brand new install: I used a NOOBs SD card and chose Raspbian. Once the operating system was installed, the following commands were typed in:

$ sudo nano /boot/cmdline.txt $ sudo nano /etc/inittab

The above two commands need to be modified in order to free up the UART on the Pi (to be totally honest, I’m not sure if this needs to be done for nfcpy.) Follow these directions from Clayton Smith’s website. Initially, I used Adafruit’s website for these instructions, but they were not totally clear.

$ sudo raspi-config

This allows you to personalize your Pi through the Raspbian Configuration utility.

Install Launchpad bazaar, a VCS (Version Control System), which allows you to download NFCPY.

$ mkdir pythonprogs $ cd pythonprogs

Above 2 commands create and then switch to the directory where my Python programs will be stored on this machine.

$ bzr branch lp:nfcpy

Download the latest version of NFCPY.

$ cd /pythonprogs/nfcpy/examples

Switch to the examples directory of NFCPY.

$ python tagtool.py --device tty:AMA0:pn53x show

Run the Python program tagtool. The ‘device’ switch following tagtool.py specifies that we want to use the serial device.

Then put a card near the reader: partial success. There is output on the screen, but the reader cannot read the card, apparently NFCPY cannot handle MIFARE Classic 1K cards. So I ordered some other ones, hopefully they will work!

UPDATE 2014/01/29 The cards I ordered from OverAir Proximity Technologies do work! They are

NFC Card - White - NTAG203 PAC-N3Card

UPDATE 2014/08/02 I purchased a Raspberry Pi B+ (mainly for the form factor) and found I needed to modify to contents of some of the links above in order to successfully install nfcpy.