Created: 21.10.2016 01:29 Last Modified: 21.10.2016 01:33
Views: 64116
Keywords: Linux, NFC, PN532, Python, Raspberry Pi, RFID
Writing and Reading Data to NFC Cards and RFID Tags with Raspberry Pi and PN532 Module
Introduction
This is a simple demo for writing and reading data to RFID tags on NFC cards using Raspberry Pi and PN532 NFC module. Only free and open source software has been used for examples in this video.
There are a lot of different RDIF and NFC modules on the market. I bought this particular unit from ebay. You can find it and other similar modules with the same PN532 chip for about 15 USD. I bought it as a convenient kit with RFID tag and NFC card for testing. Adafruit is offering a similar module.
PN532 operates at 13.56 MHz resonance frequency. The main advantage of the module is that it supports 3 hardware interfaces for connecting to other devices: high speed UART, I2C and SPI. Therefore it is very convenient for rapid prototyping on Raspberry Pi or Arduino.
Required Hardware
For this tutorial you will need:
Raspberry Pi (any model and version is suitable)
PN532 NFC Module
Breadboard
Female to male and male to male jumper wires
microSD card with Raspbian GNU/Linux distribution
NFC Card and RFID token (tag) for testing
Wiring
Connect PN532 NFC module to your Raspberry Pi as shown on the diagram below:
Please note that I have already soldered male header pins to the NFC module as shown in the video. It is powered by 3.3V from Raspberry Pi. Although the module support 3 hardware interfaces this tutorial covers only the usage through SPI. So after the wiring switch the module to SPI and after that boot Raspberry Pi with the Raspbian GNU/Linux distribution.
Source Code
Open a terminal on your Raspberry Pi or login remotely using SSH. If Python and Git are not install type the commands below to install it: