Jon Gallant

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

2 min read

ScreenshotI’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*

https://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v0-dot-2

  • 2. Make Occidentalis SD card*

https://learn.adafruit.com/adafruit-raspberry-pi-lesson-1-preparing-and-sd-card-for-your-raspberry-pi/making-an-sd-card-using-a-windows-vista-slash-7

  • 3. Run first time config*

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-2-first-time-configuration

  • 4. Free UART on the Pi*

https://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi

https://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/building-libnfc

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.

Screenshot

I found that info here: https://www.mobilefish.com/developer/libnfc/libnfc_quickguide_adafruit.html

  • 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

Screenshot

  • 8. Test it out*

https://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/testing-it-out

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

Screenshot

Let me know if you run into any issues.

Jon

Share:
Share on X