See the first post: project introduction

 

Here I'm going to go through really simple set up with NFC, which I promise is dead quick, using Python as it's simplest. This assumes you know how to set your pi up, and have it all ready for putting code onto it using the internet, and communicating with it in some way in order to program. You will need:

  1. A Raspberry pi of any model and power supply
  2. An SD card or MicroSD card with raspbian installed
  3. Add-on board - Explore NFC from Farnell element14
  4. Internet connection

Stage 1: Set up Start by removing power from your pi, if it's turned on (make sure you do a sudo halt first!), and plugging in your NFC board onto the GPIO connector.

140812-123230.jpgComplicated hardware set up out of the way, turn your pi back on. Run an update and upgrade:

sudo apt-get update

sudo apt-get upgrade

and turn SPI on in raspi config (sudo raspi-config, advanced options>spi>yes).

For the interfacing with NXP, I'm using a library called NXPPY – this is an incredibly simple python wrapper which calls the code made by Farnell for the explorer board: as such the only function in python is reading the serial ID. Please note the following code is deprecated! This tutorial was written using version 1 of the above library, which you will need to download using the releases page. If you've downloaded and installed using pip instead, please refer to the realm on the github page of the repo: https://github.com/svvitale/nxppy

The code essentially boils down to this:

import nxppy 
uid = nxppy.read_mifare()













Which is fairly simple to understand. In order to make it so it'll keep waiting for an ID:


Make this file by entering:

sudo nano read.py

entering the code, then CTRL+X followed by y, then press enter to save the file.

In the console now enter:

sudo python read.py

As shown in the screenshot:

sc1.png

The program should hang, waiting for a scanned NFC (If you'd like to close the python file, you can also press CTRL+C) - if you put the card that came with the scanner on the scanner whilst this program is running as shown in this photo:

140812-123255.jpg

Your python file should print out the card's ID:

sc2.png


Something to note: you can scan your mobile phone using this, but the NFC serial ID will be different every time, so we can't use a phone for the purpose of this project.

I'll cover my next step, of how to build a class around this in the next blog.