No Description

gwillz 23061bd5e4 version bump 1.5.6 3 years ago
nxppy 45065cfec3 stringtag handles init/end block boundaries internally 3 years ago
src 7dd4bade9b fixed python3 init 4 years ago
tests cd944a2606 Update tests to use class-based interface 6 years ago
.gitignore 2ade72f722 added armv6 tags, sdist to CI 4 years ago
.gitlab-ci.yml 2ade72f722 added armv6 tags, sdist to CI 4 years ago 132e3d6bca Add a file for C style enforcement. Run the file against nxppy-specific c/h files. 4 years ago d304b658d5 Working python interface for Mifare cards. 6 years ago 173476f6f7 moved source files, added new examples to readme, version bump 4 years ago
NXP_NFC_Reader_Library_licencefile.pdf 9dea0b3f88 The licence file as pdf because pip does not support whiptail 4 years ago e0e575b93e Merge branch 'mk2' 4 years ago 675b79fabb Merge branch 'master' of 4 years ago 23061bd5e4 version bump 1.5.6 3 years ago


build status coverage report

nxppy is a very simple Python wrapper for interfacing with the excellent NXP EXPLORE-NFC shield for the Raspberry Pi. It takes NXP's NFC Reader Library and provides a thin layer for detecting a Mifare NFC tag, reading its UID (unique identifier), and reading/writing data from/to the user area.


All files in this repository are distributed under the MIT license.

External components

This work was based very heavily on NXP's MifareClassic example code. The example code was only reorganized to be more conducive as an interface. NXP still retains full copyright and ownership of the example code and the NFC Reader Library. The license conditions that need to be accepted in order to use this project in conjunction with the NFC Reader Library can be found in the document NXP_NFC_Reader_Library_licencefile.pdf


Tested with both Python 2.7 and 3.4 as installed on Raspian Jessie.


The EXPLORE-NFC card relies on SPI being enabled. Please enable SPI using raspi-config prior to installing nxppy.

Pin layout

Should you ever attempt to detach the Explore-NFC, here is the pin layout used by the board.

Name Physical BCM
3V3 1, 17 -
V5 2, 4 -
GND 6, 9, etc -
NFC BUSY 22 25
NFC IRQ 16 23
SPI MOSI 19 10
SPI SCLK 23 11
SPI CE0 25 8
I2C SDA 3 2
I2C SCL 5 3

Note: the 'NFC' pins must always be present. Nxppy only uses SPI so i2c can be safely ignored.


nxppy is available from PyPI. To install, simply run:

sudo pip install nxppy

Installation will take some time as it automatically pulls down the NXP NFC Reader Library from source.


Currently, the module supports ISO14443-3A/4A cards only:

import nxppy

mifare = nxppy.Mifare()

# Select the first available tag and return the UID
uid =

# Read a single block of 4 bytes from block 10
block10bytes = mifare.read_block(10)

# Write a single block of 4 bytes
mifare.write_block(10, 'abcd')

# Get Sak, ATQA, UID
ident = mifare.get_ident()

# Get Version/manufacturer data (for NTAG compliant tags)
ntag_ver = mifare.get_version()

Example polling for tags:

import nxppy
import time

mifare = nxppy.Mifare()

# Print card UIDs as they are detected
while True:
        uid =
    except nxppy.SelectError:
        # SelectError is raised if no card is in the field.

Native Extensions

Nxppy includes the ability to create abstractions in pure Python code.

For example, NTAG-23xx type cards can be processed with the NTAG class, included in nxppy/ Further abstractions can be created for different variants of the Mifare Ultralight/ISO-14443-3A/4A standard.


I welcome your feedback and pull requests! This project started as a necessity for my own Raspberry Pi development, but I'm hoping others will find it useful as a way to quickly bootstrap NFC-based projects. Enjoy!