A Python application for reading NFC card UIDs using PC/SC compatible card readers.
- 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
- Python 3.x
- PC/SC Lite library
- SWIG (for building pyscard)
- pcscd daemon
- pyscard
On Debian/Ubuntu:
sudo apt-get update
sudo apt-get install -y libpcsclite-dev swig pcscdpython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtsource .venv/bin/activate
python read_uid2.pyOr directly:
.venv/bin/python read_uid2.py- The script detects available PC/SC readers with PICC interface
- Waits for an NFC card to be placed on the reader
- Reads and displays the card UID in hexadecimal format
- Continues monitoring for card removal and new cards
read_uid.py- Basic NFC reader implementationread_uid2.py- Enhanced version with improved error handlingrequirements.txt- Python package dependencies
Install pyscard: pip install pyscard
The pcscd service is not running. Install and enable it:
sudo apt-get install pcscd
sudo systemctl start pcscdEnsure your NFC reader is properly connected and recognized by the system:
pcsc_scanSome pcsc-tools versions do not support -a. Use one of these instead:
pcsc_scan -r -t 8
pcsc_scanpcsc_scan -r -t 8 lists detected readers for 8 seconds.
This project is open source and available for use and modification.