Trying to read my RFID MFRC522 using a Mifare blue tag and it is not working. Wondering if i could get any help on this as when i put the tag to read it doesn’t show up as quick?
using:
-
Comments are not for extended discussion; this conversation has been moved to chat. – Ghanima♦ 2 days ago
Question
Rpi3 NOOBS python 2.7 SimpleMFRC522 cannot read Mifare tag problem.
Answer
- The OP used Rpi3 NOOB python 2.7, and installed himself SpiPy, SpiDev for testing.
- I think python 2.7 is a bit out of date. So I am repeating the OP’s situation but instead using Rpi4B buster 2020feb13 (full version image), with the following buster preinstalled software:
(a) python 3.7.3
(b) thonny IDE
(c) spiDev
(d) pip3
- I am using pip3 to install the MFRC522 python library, which includes the following two python3 programs:
(a) mfrc522.py (about 400 lines)
(b) simpleMFRC.py (about 100 lines)
- I am using the RFID/NFC module already tested OK using libnfc-1.7.1 in I2C configuration (Appendix A).
- I am using pip3 to install mrfc522, RPi.GPIO, and spidev in the following directory (Appendix B). I am not sure if the above GPIO and spidev modules are the same or different from the buster’s corresponding preinstalled programs.
/usr/local/lib/python3.7/dist-packages
- I am using the built-in SPI interface /dev/spidev0.0 and /dev/spidev0.1 (Appendix C)
- I used python3 shell to import SimpleMFRC522 from mfrc522, and found creating a reader object OK. (Appendix D).
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
- I read MFRC522-python/mfrc522/SimpleMFRC522.py/ – GitHu 2019mar26 saying the following:
@death-droid Improve compatibility with Python 3 – 2019mar26
So I guess the earlier versions of SimpleMFRC522 were not very compatible to python3. I was wondering if my pip3 installed stuff is more or less updated than the OP’s corresponding software using Git Clone. I guess I better download the most updated versions of mfrc522, SimpleMFRC522, and the demo/test red/write tag programs and freeze them for later testing.
- Now have tidied up the different version of the four main programs mfrc522.py, samplemfrc522py, read.py, and write.py, and put them in a penzu reading log file. Next step is to skim the two big files to get a rough picture of what is going on.
- Now I have skimmed the two main programs mrfc522.py and simpleMFRC522.py. I surprisingly found the program structure is very simple. So it should not not that difficult to debug and expand. The penzu reading log is here:
- Now I have tried the SPI loopback test and found it OK. (Appendix E)
- I tried to repeat the OP is problem, ie, raed a tag. Still no luck, the program hanged. Because I already double checked that the NFC module can read OK the same tag using libbnfc-1.7.1 I2C mode, and SPI loopback at 50kHz is OK. So the problem is likely at the SimpleMFRC522 side. Next step is to debug Read.py, SimpleMFRC522.py and the MFRC522.py library.
- Now I am checking the schematic of [another similar] nfc module to make sure that my guess of the IRQ and RST wiring is correct, ie, no need to connect these two pins to Rpi. This is verified by the success of libnfc-1.7.1 I2C read card without connect the RST and IRQ pins. Perhaps I can ping the module to make sure SPI Clk, Mosi, and Miso are working OK (the previous SPI loopback only tests 50kHz and only MOSI and Miso, CS is not tested.
/ to continue, …
References
(1) to continue, …
Appendices
Appendix A – The PN532 NFC/RFID Module V3 being tested
Reference: nfclib v1.1.7 PN532 NFC Module Testing
Appendix B – Mfrc522 software (including SPIdev and GPIO) setup record
Appendix C – Minimal configuration of SPI and I2C channels for testing the PN532 module
Appendix D – PiMyLifeUp Gus SimpleMFRC522 Library
Appendix E – SPI Loopback Test
Categories: Uncategorized