pi-rfid-jukebox/tag-reader.py

20 lines
334 B
Python

from pirc522 import RFID
import RPi.GPIO as GPIO
import sys
GPIO.setwarnings(False)
rdr = RFID()
while True:
(error, tag_type) = rdr.request()
if not error:
(error, uid) = rdr.anticoll()
if not error:
tag_id = ''.join(hex(x)[2:].zfill(2) for x in uid)
print(tag_id)
sys.stdout.flush()
rdr.cleanup()