Jul-01-2021, 07:16 PM
I have the following python code which continuously listens for NFC chip presence and when detected it prints the UID (ident)
Thank you.
from nfc import ContactlessFrontend from time import sleep def connected(tag): ident = ''.join('{:02x}'.format(ord(c)) for c in tag.identifier) print(ident) return False clf = ContactlessFrontend('usb') while True: clf.connect(rdwr={'on-connect': connected}) sleep(1)This works well. However, the problem I face is that if a user holds the NFC tag down then the script reads the same "ident" value over and over again. I want to solve this by possibly temporarily storing the value of "ident" so that it doesn't print if the value is the same as last scanned for at least X seconds before it is allowed to re-print the same UID. Is someone able to help me modify the code above to do this please?
Thank you.