Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1225

Python • MFRC522 RFID Reader + "This channel is already in use" + GPIO.cleanup()

$
0
0
Hey everyone,

I am currently trying to set up an MFRC522 RFID reader with my raspberry pi and I'm having some issues.

For reference, this is the code I am using:

Code:

#!/usr/bin/env pythonimport RPi.GPIO as GPIOfrom mfrc522 import SimpleMFRC522reader = SimpleMFRC522()try:        print("Waiting for you to scan RFID card")        id = reader.read()[0]        print("ID for this card is: ", id)finally:        GPIO.cleanup()
Everytime this program is ran I get this runtime error:
/usr/local/lib/python3.9/dist-packages/mfrc522/MFRC522.py:151: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(pin_rst, GPIO.out)

The first time I executed this program it was still able to read and output the data on my RFID card but everytime after that it has not been able to read it. I've ensured that the cables are in all in correctly. I've tried to separately run on my terminal when the program is not running:

Code:

import RPi.GPIO as GPIOGPIO.cleanup()
But it tells me that no channels have been set up yet - nothing to clean up!

I've attempted to reboot my raspberry pi as well but I continue to deal with the exact same issue of the pin_rst channel being in use. Any advice on what exactly I'm doing wrong would be greatly appreciated.

Thank you for your time!

Statistics: Posted by Ape1ron — Sat Jan 06, 2024 4:52 am



Viewing all articles
Browse latest Browse all 1225

Trending Articles