You can download this code by clicking the button below.
This code is now available for download.
This function uses the PyNFC library to read NFC tags and prints out the content of the tag.
Technology Stack : PyNFC
Code Type : The type of code
Code Difficulty : Intermediate
def read_tag(tag):
import nfc
clf = nfc.ContactlessFrontend('usb')
try:
tag = clf.connect(rdwr={'on-connect': lambda tag: True})
print("Tag read: {}".format(tag.ndef))
except Exception as e:
print("Error reading tag: {}".format(e))