2021-08-16
NFC, Python, Raspberrypi, Sensor
nfc raspberrypi tag id matching
ximport nfc
import time
my_id = '01010501b00ac30b'
def connected (tag):
time.sleep(1)
clf = nfc.ContactlessFrontend('usb')
touched = 0
while True:
print('waiting...')
tag = clf.connect(rdwr={'on-connect':connected})
felica_id = str(tag.idm).encode("hex")
if (my_id == felica_id):
print('matched!!')
else:
print('invalid id!!')
print('scaned')
で,
指定したfelica(=my_id)だと,
xxxxxxxxxx
waiting...
matched!!
scaned
waiting...
違うfelicaだと,
xxxxxxxxxx
waiting...
invalid id!!
scaned
waiting...
となる.