Raspberry Pi Interface with PN532 NFC Module

Demonstration
PN532 Raspberry Pi test

Physical connections

SPI connections

Notes

  1. The PN532 module has connections for UART, SPI, I2C, selectable by jumper. So far I have only tried the SPI interface
    (The jumpers are upper left on the picture. The UART connection are on the same pins as I2C; the labels are on the other side of the board.)
  2. SPI connections:
    • SCK, MISO, MOSI, GND as expected
    • SS to either CE0 or CE1; I think libnfc can handle either, but the example uses CE0.
      See libnfc configuration information for setup
    • VCC can be 3.3V, so no level shifting is needed for the Raspberry Pi.
    • No connections to IRQ or RSTO

Python code

import subprocess
import time

def nfc_raw():
	lines=subprocess.check_output("/usr/bin/nfc-poll", stderr=open('/dev/null','w'))
	return lines

def read_nfc():
	lines=nfc_raw()
	return lines

try:
	while True:
		myLines=read_nfc()
		buffer=[]
		for line in myLines.splitlines():
			line_content=line.split()
			if(not line_content[0] =='UID'):
				pass
			else:
				buffer.append(line_content)
		str=buffer[0]
		id_str=str[2]+str[3]+str[4]+str[5]
		print (id_str)


except KeyboardInterrupt:
        pass
    

Notes

  1. It might make sense to put more of the decoding into read_nfc(), which basically does nothing at present.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG
2.0
(Level AA)

Wilfrid Laurier University