Skip to content

Gog2006/nfc-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFC Reader

A Python application for reading NFC card UIDs using PC/SC compatible card readers.

Features

  • Reads NFC card UIDs in real-time
  • Detects card presence and removal
  • Automatic reconnection on connection loss
  • Supports PC/SC compatible NFC readers with PICC interface

Requirements

System Dependencies

  • Python 3.x
  • PC/SC Lite library
  • SWIG (for building pyscard)
  • pcscd daemon

Python Dependencies

  • pyscard

Installation

1. Install System Dependencies

On Debian/Ubuntu:

sudo apt-get update
sudo apt-get install -y libpcsclite-dev swig pcscd

2. Set Up Python Virtual Environment

python3 -m venv .venv
source .venv/bin/activate

3. Install Python Dependencies

pip install -r requirements.txt

Usage

Run with Virtual Environment

source .venv/bin/activate
python read_uid2.py

Or directly:

.venv/bin/python read_uid2.py

How It Works

  1. The script detects available PC/SC readers with PICC interface
  2. Waits for an NFC card to be placed on the reader
  3. Reads and displays the card UID in hexadecimal format
  4. Continues monitoring for card removal and new cards

Files

  • read_uid.py - Basic NFC reader implementation
  • read_uid2.py - Enhanced version with improved error handling
  • requirements.txt - Python package dependencies

Troubleshooting

"No module named 'smartcard'"

Install pyscard: pip install pyscard

"Failed to establish context: Service not available"

The pcscd service is not running. Install and enable it:

sudo apt-get install pcscd
sudo systemctl start pcscd

"No PICC reader found"

Ensure your NFC reader is properly connected and recognized by the system:

pcsc_scan

"pcsc_scan: invalid option -- 'a'"

Some pcsc-tools versions do not support -a. Use one of these instead:

pcsc_scan -r -t 8
pcsc_scan

pcsc_scan -r -t 8 lists detected readers for 8 seconds.

License

This project is open source and available for use and modification.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages