stanwin00
Posts: 22
Joined: Tue Aug 06, 2019 9:55 am

RFID MFRC522 Issues

Fri Sep 20, 2019 6:42 am

Hi, I have installed and successfully managed to get my MFRC522 RFID to work and unlock an EM lock. However i did a stress test and found out that i could only tap successfully for 3 times. After which the reader fails to read any more. I had to do a reboot of the pi and then it worked again but after that the reboot failed. I was even reading in an extra character when i tried to read the UID of my rfid card.

Has anyone experienced this before? What could be the possible causes?

danjperron
Posts: 3402
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID MFRC522 Issues

Fri Sep 20, 2019 10:46 pm

Please specify which library you are using ?

Python or C or c++ or else?

Stress test ? what is the procedure exactly.

What kind of card 5 , 7 or 10 RFID id bytes?

stanwin00
Posts: 22
Joined: Tue Aug 06, 2019 9:55 am

Re: RFID MFRC522 Issues

Sat Sep 21, 2019 5:41 am

library is python.

Stress test ? what is the procedure exactly.

Ans: Run the script -> tap the card. Script ends. Start the script again. Tap the card. script ends. Start the script again. Tap the card script ends.

Run the script -> unable to read.

What kind of card 5 , 7 or 10 RFID id bytes?

It's the normal Mifare card that came with the MFRC522 board.

danjperron
Posts: 3402
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RFID MFRC522 Issues

Sat Sep 21, 2019 1:29 pm

I forked the MFRC522 github and I modified the code to remove the GPIO and use spidev instead.

Try my version just too see if it works better. it is able to read 7 and 10 bytes CARD.

https://github.com/danjperron/MFRC522-python

stanwin00
Posts: 22
Joined: Tue Aug 06, 2019 9:55 am

Re: RFID MFRC522 Issues

Tue Sep 24, 2019 8:53 am

Thanks dan but the same issue persisted after i added in the relay code to unlock the maglock. Here is the code in full with my minimal additions. This code works for one time. After that the MFRC522 just doesn't read anymore. I'm thinking of resoldering the board to see if it's the actual cause. I've also done the gpio test. All gpios are working fine.

Code: Select all

import RPi.GPIO as GPIO
import MFRC522
import signal
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(12,GPIO.OUT)
GPIO.output(12,GPIO.LOW)
Sleeptime=5

continue_reading = True

# function to read uid an conver it to a string

def uidToString(uid):
    mystring = ""
    for i in uid:
        mystring = format(i, '02X') + mystring
    return mystring


# Capture SIGINT for cleanup when the script is aborted
def end_read(signal, frame):
    global continue_reading
    print("Ctrl+C captured, ending read.")
    continue_reading = False
    GPIO.cleanup()

# Hook the SIGINT
signal.signal(signal.SIGINT, end_read)

# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()

# Welcome message
print("Welcome to the MFRC522 data read example")
print("Press Ctrl-C to stop.")

# This loop keeps checking for chips.
# If one is near it will get the UID and authenticate
while continue_reading:

    # Scan for cards
    (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)

    # If a card is found
    if status == MIFAREReader.MI_OK:
        print ("Card detected")

        # Get the UID of the card
        (status, uid) = MIFAREReader.MFRC522_SelectTagSN()
        # If we have the UID, continue
        if status == MIFAREReader.MI_OK:
           print("Card read UID: %s" % uidToString(uid))
                #print("Card read UID: %s" % uid)
           GPIO.output(12,GPIO.HIGH)
           print("Access Granted")
        else:
            print("Authentication error")
            print("Access Denied")
Last edited by stanwin00 on Tue Sep 24, 2019 9:54 am, edited 1 time in total.

stanwin00
Posts: 22
Joined: Tue Aug 06, 2019 9:55 am

Re: RFID MFRC522 Issues

Tue Oct 08, 2019 1:02 am

I've fixed this issue. turns out it was a soldering problem. I've changed the card and it works normally now.

Return to “Other projects”