1AdityaX / mfrc522-python

The mfrc522-python library is used to interact with RFID readers that use the MFRC522 chip interfaced with a Raspberry Pi.
https://pypi.org/project/mfrc522-python/
GNU General Public License v3.0
13 stars 4 forks source link

Error in line 147 MFRC522-python/mfrc522/MFRC522.py #2

Closed mirjamgebauer closed 7 months ago

mirjamgebauer commented 7 months ago

Hey! I was wondering, why in the README file it says, that the connection of the reset pin is physical PIN 22/ GPIO Pin 25 and in the lines 145-149 of MFRC533-python/mfrc522/MFRC522.py it refers to PIN 22 or PIN 15.

` if pin_rst == -1:

        if pin_mode == 11:

            pin_rst = 15

        else:

            pin_rst = 22`

First I did not know, what pin_mode 11 and pin_mode 10 means, so I did some research and I found out, that pin_mode 11 refers to BCM Mode (the GPIO numbering) and pin_mode 10 refers to BOARD Mode (https://pypi.org/project/RPi.GPIO/#files official RPi.GPIO documentation, in the zip archive it is said in the #defines of source/common.h)

So, since the default pin_mode is set to 10, it is correct, but if you call the constructor of MFRC522 with the parameter pin_mode=11 it will set the wrong pin to the reset pin (Physical Pin 10 and GPIO Pin 15)

I think you have to change 15 to 25 in line 147

1AdityaX commented 7 months ago

Hii, You are right!!, What it should have been is

if pin_mode == 10:
    pin_rst = 15
else:
    pin_rst = 22

Since pin 15 is GPIO 22. It's an error in the code as well in the documentation It's better to change 15 to 25, else it would break other's work. I am change it now And I appreciate your attention to detail and research