使用 MFRC522 在 Raspberry Pi 中进行条件访问

问题描述 投票:0回答:1

我正在尝试使用 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()

This is the output when I run it on the terminal

我想如果我正确地编写了序列号并预定义它,我就可以授予对该特定 ID 的访问权限。我的代码有问题吗?或者是硬件问题?我哪里或怎么出错了?

python python-3.x raspberry-pi raspberry-pi3
1个回答
0
投票

我不知道您是否受此指导,但也许它会对您有所帮助https://pimylifeup.com/raspberry-pi-rfid-rc522/

© www.soinside.com 2019 - 2024. All rights reserved.