A Django-based inventory management system for homelabs using NFC tags and the ACR1252U NFC reader. Track equipment, storage locations, and automate tasks with NFC cards.
- Real-time NFC Scanning: WebSocket-based live scanning interface
- Storage Location Management: Hierarchical storage locations with NFC tags
- Item Tracking: Full inventory management with categories, quantities, and locations
- NFC Tag Association: Link NFC tags to locations, items, or commands
- Command Cards: Execute predefined commands by scanning special NFC cards
- Modern UI: DaisyUI + Tailwind CSS responsive interface with 10+ themes
- Theme Switcher: Choose from dark/light themes (Dark, Dracula, Night, Coffee, Synthwave, etc.)
- Admin Panel: Full Django admin for management
- NFC Reader: ACS ACR1252U-DOT (USB NFC Reader)
- NFC Tags: MIFARE Classic 1K/4K or compatible tags
- OS: Linux (Fedora 42 tested, should work on other distros)
Install PC/SC Lite development libraries:
# Fedora/RHEL
sudo dnf install pcsc-lite-devel pcscd
# Ubuntu/Debian
sudo apt-get install libpcsclite-dev pcscdStart the PC/SC daemon:
sudo systemctl start pcscd
sudo systemctl enable pcscd # Optional: auto-start on bootdirenv automatically activates the virtual environment and loads environment variables when you enter the project directory.
# Install direnv
sudo dnf install direnv # Fedora/RHEL
# or
sudo apt-get install direnv # Ubuntu/Debian
# Add to your shell (~/.bashrc or ~/.zshrc)
eval "$(direnv hook bash)" # for bash
# or
eval "$(direnv hook zsh)" # for zsh
# Reload shell
source ~/.bashrc
# Allow direnv in this project
cd /home/mike/nfcinv
direnv allowSee DIRENV_SETUP.md for detailed configuration.
Benefits: Auto-activates venv, loads .env variables, no manual source venv/bin/activate needed!
# Clone the repository (if not already done)
cd /home/mike/nfcinv
# Run the setup script
./setup.sh
# Activate virtual environment
source venv/bin/activate
# Create a superuser for Django admin
python manage.py createsuperuser
# Run the development server with ASGI (for WebSockets)
daphne -b 0.0.0.0 -p 8000 config.asgi:applicationTest if your NFC reader is working:
# Activate virtual environment
source venv/bin/activate
# Test NFC reader connection and scan for tags
python manage.py test_nfc --continuous
# Test reading specific blocks
python manage.py test_nfc --continuous --read-blocks 4 5 6 7For development (with WebSocket support):
source venv/bin/activate
daphne -b 0.0.0.0 -p 8000 config.asgi:applicationAccess the application at: http://localhost:8001 (port configurable in .env)
Note: Port 8001 is used to avoid conflicts with other services. See PORT_CONFIG.md to change the port.
- Dashboard (
/): Overview with stats and recent scans - NFC Scanner (
/nfc-scanner/): Real-time NFC tag scanning - Locations (
/locations/): Manage storage locations - Items (
/items/): View and manage inventory items - Tags (
/tags/): View registered NFC tags - Admin (
/admin/): Full management interface
Click the palette icon (π¨) in the navbar to choose from 10 themes:
- Dark Themes: Dark (default), Dracula, Night, Coffee, Synthwave, Cyberpunk, Forest, Luxury
- Light Themes: Light, Cupcake
Your theme preference is saved automatically. See THEMES.md for details.
-
Create Storage Locations
- Go to Admin β Storage Locations β Add
- Create location (e.g., "Server Rack", "Tool Cabinet")
-
Tag Locations with NFC
- Go to NFC Scanner
- Click "Start Scanning"
- Place NFC tag on reader
- Go to Admin β NFC Tags β find the detected UID
- Associate it with your storage location
-
Add Items
- Go to Admin β Items β Add
- Fill in item details
- Assign to a storage location
- Optionally tag with NFC
-
Scan and Locate
- Use NFC Scanner to scan location tags
- Instantly see what items are in that location
- Scan item tags to see item details and location
Command cards allow you to execute predefined commands by scanning special NFC tags.
-
Create a Command
- Go to Admin β Commands β Add
- Set name and description
- Scan an NFC card and note its UID
- Enter the UID in "Card UID" field
- Enter the command to execute
- Set security options (requires confirmation, etc.)
-
Execute Command
- Go to NFC Scanner
- Scan the command card
- Confirm execution if required
- View execution logs in Admin
Security Note: Commands are executed on the server. Only create commands for trusted operations and implement proper security controls.
- Hierarchical storage locations (can have parent locations)
- Optional NFC tag UID
- Tracks items in location
- Inventory items with name, description, quantity
- Category and barcode/SKU support
- Assigned to storage location
- Optional individual NFC tag
- Tag UID (unique identifier)
- Tag type: location, item, command, or other
- Association with location or item
- Scan tracking (count, last scanned)
- Flexible JSON data storage
- Command card configuration
- Card UID for triggering
- Command string to execute
- Security options (confirmation required, active/inactive)
- Execution tracking and logging
- Audit trail for command executions
- Success/failure status
- Output and error logging
/ws/nfc-scanner/- Real-time NFC scanning events
/api/associate-tag/- Associate NFC tag with location or item (POST)
The inventory/nfc_service.py module provides:
-
NFCReader: PC/SC interface for ACR1252U
connect(): Connect to readerpoll(): Check for card presenceget_uid(): Read card UIDread_block(n): Read data from blockwrite_block(n, data): Write data to block
-
NFCDataEncoder: Helper for encoding/decoding text to NFC blocks
nfcinv/
βββ config/ # Django project settings
β βββ settings.py
β βββ urls.py
β βββ asgi.py # ASGI config for WebSockets
βββ inventory/ # Main app
β βββ models.py # Database models
β βββ views.py # HTTP views
β βββ consumers.py # WebSocket consumers
β βββ nfc_service.py # NFC reader interface
β βββ routing.py # WebSocket routing
β βββ admin.py # Django admin config
β βββ templates/ # HTML templates
β βββ management/
β βββ commands/
β βββ test_nfc.py # NFC testing command
βββ requirements.txt # Python dependencies
βββ setup.sh # Setup script
βββ README.md # This file
# Check if pcscd is running
sudo systemctl status pcscd
# Check if reader is connected
pcsc_scan
# Check permissions (add user to plugdev group)
sudo usermod -a -G plugdev $USER- Ensure you're running with
daphne(notpython manage.py runserver) - Check browser console for WebSocket errors
- Verify firewall allows port 8000
- Default keys are used (FF FF FF FF FF FF)
- Some tags may have different authentication
- Check tag compatibility (MIFARE Classic works best)
For production use:
- Set
DEBUG = Falseinsettings.py - Configure proper
SECRET_KEY - Use PostgreSQL instead of SQLite
- Set up Redis for channel layers
- Use proper ASGI server (Daphne with systemd)
- Configure nginx/Apache as reverse proxy
- Enable HTTPS
- Set up proper logging
This is a homelab project. Feel free to fork and customize for your needs.
MIT License - see LICENSE file
- Django + Channels for WebSocket support
- pyscard for PC/SC interface
- DaisyUI + Tailwind CSS for UI
- ACR1252U reader for NFC support