testing NFC

This commit is contained in:
EggMan20339 2024-05-09 21:11:20 -04:00
parent c3a1359339
commit 1edbf9c4ae
2 changed files with 27 additions and 1 deletions

View File

@ -33,7 +33,7 @@ On Windows, the native WebAuthn API will be used.
"""
import time
import configparser
gpie = True
gpie = False
if gpie:
import RPi.GPIO as GPIO
import pickle

26
test.py Normal file
View File

@ -0,0 +1,26 @@
import nfc
import time
def connected(tag):
print("Tag detected:", tag)
return True
def read_nfc():
try:
clf = nfc.ContactlessFrontend('usb') # Ensure this matches your connection
print("NFC reader initialized.")
except Exception as e:
print("Failed to initialize NFC reader:", e)
return
try:
while True:
print("Waiting for NFC tag...")
clf.connect(rdwr={'on-connect': connected})
time.sleep(1)
except Exception as e:
print("Error reading NFC tag:", e)
finally:
clf.close()
read_nfc()