百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

nxppy

> 编程语言
开源

Python 封装,用于与 Raspberry Pi 的 NXP EXPLORE-NFC 保护板进行接口通信

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Python 封装,用于与 Raspberry Pi 的 NXP EXPLORE-NFC 保护板进行接口通信

nxppy

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

License

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

External components

NXP now releases the NFC Reader Libary as a Debian package for easy installation on a Raspberry Pi. Start by downloading the DEB file from here:

https://www.nxp.com/products/:PNEV512R?&tab=Design_Tools_Tab

or here:

https://www.nxp.com/products/:NFC-READER-LIBRARY?tab=In-Depth_Tab

Once downloaded, you can install the library by running:

bash
sudo apt-get update
sudo apt-get install build-essential cmake python3-dev python2.7-dev
sudo dpkg -i NFC-Reader-Library-4.010-2.deb

Installation will take some time as it builds the NXP NFC Reader Library from source.

Compatibility

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

Requirements

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

Installation

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

bash
pip install nxppy

Usage

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

python
import nxppy

mifare = nxppy.Mifare()

# Select the first available tag and return the UID
uid = mifare.select()

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

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

# Read the entire user data area (this relies on byte 2 of the capability container being set to the correct tag size)
user_data = mifare.read()

Example polling for tags:

python
import nxppy
import time

mifare = nxppy.Mifare()

# Print card UIDs as they are detected
while True:
    try:
        uid = mifare.select()
        print(uid)
    except nxppy.SelectError:
        # SelectError is raised if no card is in the field.
        pass

    time.sleep(1)

NDEF records can be read as bytes, and then passed through ndeflib for parsing

python
import nxppy
import ndef

# Instantiate reader
mifare = nxppy.Mifare()

# Select tag
uid = mifare.select()

# Read NDEF data
ndef_data = mifare.read_ndef()

# Parse NDEF data
ndef_records = list(ndef.message_decoder(ndef_data))

Authentication example:

This example uses the address layout of a NTAG216 card. Please refer to the specific card manual for the address layout.

NTAG cards remain authenticated until removed from field or an error occurs. Reauthenticate to gain access again.

NTAG216 configuration page layout:

Address Byte 0 Byte 1 Byte 2 Byte 3
0xE3 Mirror RFUI Mirror_Page AUTH0
0xE4 Access RFUI RFUI RFUI
0xE5 PWD PWD PWD PWD

Relevant parts:

0xE3 Byte3 Defines the address from which the password verification is required

0xE4 Byte0 Bit7 Defines access protection: 0 for write protection (read only), 1 for read and write protection

0xE5 All 4 bytes are used to store the password

Values not mentioned here are the cards default values and not altered by this script.

…

Common Issues

I encounter fatal error: Python.h: No such file or directory during install.

The Python development package is required for nxppy install. If you're using Raspbian, you can install this package using sudo apt-get install python-dev where "<xx>" is either "2.7" or "3" depending on which version of Python you're using.

I encounter error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/nxppy.so' during install.

Looks like you're trying to install nxppy into the global python site-packages directory. There are many many many blog posts out there about why it's best to develop Python applications using a virtualenv. If you really want to install nxppy into the global package store, you can install with sudo pip install nxppy. It's not recommended.

Feedback

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. Thanks to NXP for the excellent support over the years. Enjoy!

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言