Hooking Everything Up

The Adafruit NFC Breakout board is much more appropriate with the Pi than the NFC Shield, since the breakout doesn't have 5V level shifting (which means you won't accidentally damage your Pi!), and you have easier access to the bus select pins, etc.

If it isn't already hooked up, you can connect your breakout now using a convenient Pi Cobbler, following the image below: There are two places to do this: either the board end header (fits more nicely in a breadboard), or the FTDI header along one side (shown in photo below):

Note: Make sure that the SEL0 and SEL1 jumpers on the NFC breakout are set to OFF, which will cause the PN532 to boot into UART mode (rather than SPI and I2C, which aren't currently supported by libnfc).  You will need to reset the breakout after changing these pins, which you can do by cycling the power pin.

Use a 5V supply pin from the Pi, and the 5V input on either the FTDI header or board end header, rather than the Pi’s 3.3V supply, since the 3.3V supply is used by the core on the Raspberry Pi and you don't want to pull sharp, heavy loads from it, like when you first enable and charge the near field.

Raspberry Pi

NFC Breakout Board (board end header)

5V

5.0V

GND

GND

GPIO14 (TXD0)

RX on board-end header, or TX on FTDI header

GPIO15 (RXD0)

TX on board-end header, or RX on FTDI header

Read an ISO14443-A (Mifare, etc.) Card with nfc-poll

With libnfc configured, built and installed, you can go back to the command-line, place a card on the reader, and run the following command to get the tags unique ID:

nfc-poll

nfc-poll should be able to run this way thanks to the “make install” step on the prior page, which puts it in the /user/bin directory. If it doesn’t run, check if you did the install step, or you can find the executable program in ~/libnfc/examples

A successful run will yield the following:

That's it!  From here, you can explore some of the other examples in the 'examples' folder, and figure out how to get started writing your own applications based on libnfc!  Be sure to have a look at the libnfc project page.

Common Issues

If nfc-poll returns this message:

pn53x_check_communication error

The culprit is usually one of two things:

  • Try swapping the RX and TX wires.
  • The particular model of Pi might be an exception to the “Recent” vs “Earlier” rules on the previous page. If the wire swap didn’t fix the issue, try using the opposite library setup steps…do a “make clean” first so that everything’s rebuilt.

This guide was first published on Jul 29, 2012. It was last updated on Mar 08, 2024.

This page (Testing it Out) was last updated on Mar 08, 2024.

Text editor powered by tinymce.