By: Marko Javorac Toronto, Canada
NFC/RFID technology has been a staple in the world for decades. From security to automation, this technology can implemented in a varity of ways. This guide will help you up and running using the Adafruit PN532 board with your Rasberry Pi.
Due to its nature, a few skills will be required that are beyond the scope of this guide. A few helpful links are provided below.
- Soldering Basics Tutorial https://www.youtube.com/watch?v=BxASFu19bLU
- Eagle https://www.youtube.com/watch?v=1AXwjZoyNno&t=0s
- CorelDraw https://www.youtube.com/watch?v=iKfFNNtfpMU
- Raspberry Pi Guide https://www.youtube.com/watch?v=juHoJYX86Dg
The time required can vary depening on a few factors. If recive your parts, prepare Raspberry Pi, and install required libraries
The toal cost of this project can very depending on how much equipment you have access to and the PCB providers. The average cost will be around $150. A fulll breakdown of the costs is avaliable here.
- PN532 Board + NFC Card https://learn.adafruit.com/adafruit-pn532-rfid-nfc
- Soldering Station
- PCB/Acrylic Printing
- Prototyping Equipment
- RaspianOS running on a Raspberry Pi Model 3
To enable comunicattion between the Pi and the PN532 Board, you will have to choose a communications protocol and solder jumpers on the designated protocol. For this tutorial we will be using I2C. The jumpers are included in the PN532 kit.
To enable I2C or any other communication protocol, the jumpers must be configured correctly. Setup table is below.
We will now be shifting our focus over to the sofware side. To interact with the board and use nfc functionality, we will be using an open source library called libnfc. The is a basic but powerful package of libraries that will get us going and be foundation to your future projects. We will again assume you understand how to setup and run Debian on a Pi.
This official libnfc guide will walk you through installing the library. This website contains a plethora of information regarding NFC and should be your goto for troubleshooting the software side.
We will give it quick test to make sure all our components are working. A prototyping breadboard is a great way to do this. The pins must be configured the right way for our sensor. Be extra careful as you do this to not damage you board.
- Pin01 --> 3.3V
- Pin03 --> SDA
- Pin05 --> SLC
- Pin06 --> GND
Running the i2cdetect program will let you know if your PI can actually see the i2c device. Your address might vary from mine and thats fine. The goal is just get an address.
Using libnfc, we can run a simple poll program that when a card is detected, it will state simple information and confirm we can read nfc cards.
Our PCB is designed in EAGLE and the file is provided in PCB folder of this repository. Notice that I went through multiple iterations of the PCB to get a design that worked for me. Unless you have a PCB printing station avaliable to you, You will have to use an online printing soultion. A quick look up online will help you find the right one. It is also possible to find PCB printers in your area. There are a variety of pros and cons to each that you willl have to decide for yourself.
You will have to solder headers and resitors where shows in the images below. Follow the soldering guide linked at the top.
This PCB is not the final one provided in the repository. It has a modifcation so you don't need to drill and rewire as I had to. In the future, I will repost an image of the final one.
Although it it not necessary to have a case, protecting your hardware is a great idea. In this repo, there is a case design cad file that is to be used with a sheet of acrylic. It is not a perfect case but it will get the job done
You should now be able to combine the pcb, board, and PI onto one neat unit.
This guide helps you make one unit but scaling up to commercial introduces a new dimension of challenges. Condensing board design, cost-effective materials, and dedicated read-only nfc board are possible avenues to explore when considering commercial opportunities.
By following these instructions, you should be able to get your own PN532 board working on the Rasberrry Pi and begin exploring NFC projects with confidence. If you have any comments or suggestions please email me at [email protected].
-Marko
This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details
- The undying support of my family and friends, in particular Jacob Ladan and Denald Demirxhiu.
- All the faculty and support staff at Humber Collage