我正在尝试使用 MFRC522 在 Raspberry Pi 中进行条件访问。而且代码似乎不起作用。
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
import datetime
reader = SimpleMFRC522()
allowed_id = "141854387750"
try:
while True:
print("Hold an RFID tag near the reader")
id = reader.read_id()
if id == allowed_id:
print("Access granted for Tag ID:", id)
print("Data:", text)
else:
print("Access denied.", id)
except KeyboardInterrupt:
GPIO.cleanup()
我想如果我正确地编写了序列号并预定义它,我就可以授予对该特定 ID 的访问权限。我的代码有问题吗?或者是硬件问题?我哪里或怎么出错了?
我不知道您是否受此指导,但也许它会对您有所帮助https://pimylifeup.com/raspberry-pi-rfid-rc522/