I’ve recently been experimenting with NFC projects.
The first test was done using an Adafruit NFC Shield for Arduino. I was able to get my code working with the default setup (that is using the shield with an Arduino).
However, as I need to test Peer-to-Peer mode (P2P for short) in NFC, I quickly found out that this is not something easy to do with an Arduino.
While the PN532 chip on the shield do have such capability, the Arduino libraries are far from being mature and don’t support this, yet :–(
So, I decided, I should first try out libnfc and if it works, I could replace my Arduino with a Raspberry Pi.
First of all, please note that these instructions are for the NFC shield and not the NFC breakout board which is easier to use/connect than the shield.
Following Adafruit’s guides, I tried to properly hook up the shield to the mac via an FTDI board I already had.
Turned out there are plenty of things that can go wrong:
- the silkscreen on Adafruit NFC shield has a mistake:
- the default timeouts in the pn532 driver are not long enough and unless you patch the driver, the NFC reader won’t show up!
- if some configuration files and directories are missing, the tools/examples will fail silently, giving you nearly no clue to what’s wrong!
Recap of things to do in order to make this work:
- download libnfc, configure it and install it,
- create a directory named
/usr/local/etc/nfc/libnfc.confand modify it in order to manually declare your device, like so:
- use an FTDI board @5V (3.3V won’t work with the shield),
GNDfrom the FTDI board to the shield, connect
RXfrom the FTDI board to
A4on the shield and finally connect
TXon the FTDI board to
A5on the shield,
- on the Adafruit shield, add a blob of solder in order to close
SEL0, so do it for the jumper labeled
SEL1instead as they are inverted!,
- download the latest libnfc distribution and edit
libnfc/drivers/pn532_uart.c, do a search for
Ox55and add plenty of properly formated
0x00in order to increase the timeout:
Now nfc-poll and nfc-list should just work fine!