How to Connect a PN532 NFC Shield to a RaspberryPi via libnfc

I’m working on an NFC project and to test things out I got a PN532 NFC shield working with a RaspberryPi via libnfc.

Adafruit has a good step-by-step tutorial, but it’s not up-to-date and it’s for the PN532 breakout board not the PN532 shield. They also have this one for Arduino – it’s not RaspberryPi, but still helpful for understanding the concepts.

Here’s how I got it going – hope this saves you some time.

1. Get Occidentalis v0.2

2. Make Occidentalis SD card

3. Run first time config

4. Free UART on the Pi

5. Get and Build libnfc

6. Prepare the PN532

When I was going through this I was going under the assumption that libnfc only worked in UART mode (because that is what I found on from many sources), but I later found that it does support I2C and SPI. To get PN532 in UART mode you need to solder SEL0 on the board (make sure you are soldering SEL closest to MOSI on the board. In v.1 of PN532 SEL0 and SEL1 labels were reversed.

I found that info here:

7. Wire up the PN532 to the breadboard and the RaspberryPi

  • Connect 5v power and GND from RaspberryPi to breadboard
  • Connect 5v power and GND from PN532 to breadboard

The PN532 outputs 5V, but the RaspberryPi TXD and RXD pins are rated for 3.3V so we need to put a 220ohm resistor between them.

  • Connect PN532 SCL to RaspberryPi TXD with a 220ohm resistor between them
  • Connect PN532 SDA to RaspberryPi RXD with a 220ohm resistor between them

8. Test it out

After running nfc-poll and swiping a card you should see your UID – which means it is working!

Let me know if you run into any issues.