element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Pi Passport: Step 2: Setting up NFC
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: charlotte_godley
  • Date Created: 10 Aug 2014 6:19 PM Date Created
  • Views 1863 views
  • Likes 2 likes
  • Comments 12 comments
  • raspberry-pi-b+
  • b+
  • raspberry-pi-bplus
  • pipassport
  • explore-nfc
  • raspberry-pi
  • raspberrypi
  • nfc
  • charlotte_godley
Related
Recommended

Pi Passport: Step 2: Setting up NFC

charlotte_godley
charlotte_godley
10 Aug 2014

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.

Complicated hardware set up out of the way, turn your pi back on. Run an update and upgrade:image

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:

image

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:

image

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

image


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.

  • Sign in to reply
  • charlotte_godley
    charlotte_godley over 11 years ago

    NOTE: the code used in this tutorial, as described in the text in bold, is now deprecated in the current release of nxppy. Anyone who wants to continue using this code, please download and install a copy from the releases page, NOT pip. I will be updating the code to use version 1.2 in the next few weeks, but for now please refer to the readme file of the aforementioned github repo if you would like to update your own code to use the new version.

    Cheers!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 11 years ago

    Dear friends.

     

     

     

     

    I am  write a C library using SPI communication for interface the Board NFC EXPLORE PN512 with a micocrontroller 8 bit, 16 bit or 32 bit. This because lot off pleople dont has Raspeberry or prefere use this Board with another MCU, like in my case.

     

     

    After one week working in this projects I can manager the NFC EXPLORE register, for exemaple write and read the FIFO BUFFER, clear the configuration, transmitte data to RF anntena.

     

     

    Now I need any help to solve the last problem that is: Cannot send data to MIFARE card to read the UID or other data that is store in the card EEPROM.

     

     

    Below is my code:

     

     

    // THIS LINES OF CODE CONFIGURE THE DEVICE TO ENABLE RF ANTENA AND

     

     

    EXPLORE_NFC_PN512_ControlReg(0x05);

      EXPLORE_NFC_PN512_TxAutoReg();

      EXPLORE_NFC_PN512_RxThresholdReg();

      EXPLORE_NFC_PN512_RFCfgReg();

      EXPLORE_NFC_PN512_GsNOnReg();

      EXPLORE_NFC_PN512_TxControlReg();

     

     

      // CLEAR THE FIFO BUFFER BEFORE  WRITE THE COMMAND DO BE SEND TO RF

     

     

      EXPLORE_NFC_PN512_Clear_Fifo_Buffer();

      EXPLORE_NFC_PN512_WRITE_MB_INTO_FIFO_BUFFER(0x26);  // value write 0x26h command do quest card

     

     

    // NOW SEND THE FIFO CONTENT TO ANNTENA AND WAIT FOR MIFARE CARD RESPONSE

    // IN THIS PARTICULAR CASE I WAITING FOR 04h 00h

     

     

    EXPLORE_NFC_PN512_Start_Send();

    EXPLORE_NFC_PN512_Transmit();

    EXPLORE_NFC_PN512_Transceive();

     

     

        _delay_cycles (50000);

     

     

        nBytes=EXPLORE_NFC_PN512_GetFifoLevel(); // Get FiFo level

     

     

      _delay_cycles (50000);

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube