1

I connected a RFID-RC522 to my RPi 4. It was working perfectly to read data until now. I don't know why but I cannot read anymore data now. Nothing changed in the hardware, neither the software. Maybe a configuration of the Pi changed, but I'm not sure.

I connected the pins like that:

Name    Pin #   Pin name
SDA     24      GPIO8
SCK     23      GPIO11
MOSI    19      GPIO10
MISO    21      GPIO9
IRQ     None    None
GND     Any     Any Ground
RST     22      GPIO25
3.3V    1       3V3

Here is my code (I also tried with pirc522 library):

import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522

reader = SimpleMFRC522() print("Wait RFID tag...") try: id, text = reader.read() print(id) print(text) finally: GPIO.cleanup()

Nothing happens now, the code is waiting even if I put a tag front of the reader. I don't know what I can check to see if everything is well configured. I already went to raspi-config to enable SPI. I don't understand why it suddenly stopped to work.

Thanks in advance for your help.

Dark Patate
  • 103
  • 2
  • 9
  • 1
    Not much we can do to help. You need to add debug/trace statements to find the failure point. http://abyz.me.uk/rpi/pigpio/piscope.html and/or http://abyz.me.uk/rpi/pigpio/examples.html#Python_monitor_py will help you check the SPI comms. – joan Nov 19 '20 at 11:57
  • Your problem of "*Code waiting if tag in front of reader*" is common. There are many causes, including the following. (1) Rpi OS is upgraded, but old driver does not catch up. (2) Rpi OS reconfigured and no longer compatible to old driver. You can check the config files. If you have no luck checking all the config files, you can try my simple demo program: https://raspberrypi.stackexchange.com/questions/109773/how-can-rpi-spi-python-read-the-mfrc522-nfc-module to continue, ... – tlfong01 Nov 20 '20 at 06:38
  • I would recommend the following testing procedures: (1) Get a fresh micro SD card installed with Rpi Os. (2) Follow the three parts to make sure (a) Hardware wiring is OK, (b) SPI loopback test is OK. (c) Install the simple library, (4) Use CLI commands to initialize of class and crate a tag object., (5) Use simple CLI and python statements to write and read a tag. The CLI and python statements are fully debugged. You just blindly copy and paste the text commends. Complete test procedure takes 15~30 minutes. Good luck and cheers. – tlfong01 Nov 20 '20 at 06:49
  • PS - Your might also find the chat record of the above Q&A useful: https://chat.stackexchange.com/rooms/106073/discussion-on-question-by-627117717-pr-trying-to-code-a-rfid-tag-to-a-mfrc522-ch. – tlfong01 Nov 20 '20 at 06:52
  • 1
    Thanks @joan for your softwares. I could check the signals, and it looks like I sending data. I just have nothing (with the both solution, I cannot see anything) on the RST pin. I don't know if it's the problem. Also the clock doesn't look regular. – Dark Patate Nov 20 '20 at 09:05
  • 1
    Thanks a lot @tlfong01 ! I'll following your guidelines and checking everything. I hope it's not that deep problem, because I already made deep configuration on my Pi for other softwares. I also saw you put a pull-up resistor on the RST, is it mandatory? Mine is just connected to the RPi GPIO 25. Checking all the config files looks troublesome ^^' – Dark Patate Nov 20 '20 at 09:08
  • Ah, your following comment worries me: "*I already made deep configuration on my Pi for other softwares". Every time you install something, the installation program might config some hardware setting. For example, if every time you use pip3 to install a library for python 3 programs, the SPI modules would be placed in some directories for python 3 intepreter to find and use. But then one day you follow some old library instruction and use pip (not pip3), then an old SPI module will be placed in another directory dedicated for python 2 interpreter*. / to continue, ... – tlfong01 Nov 20 '20 at 14:25
  • My lesson learnt is *always backup a micro SD card image before installing a new library, just in case you make a mess and want to go back.. And for the pull up thing, if a device is Low level to reset*, then the module usually has the reset pin pull High to Vcc. But if you pull to a GPIO pin, then you are asking for trouble, because you never know the status of that GPIO pin during boot etc. – tlfong01 Nov 20 '20 at 14:30
  • 1
    Is there a way to reinstall the SPI module properly, if it's the problem? I tried to add a pull-up resistor (but after checking my RST is already HIGH). I tried to reinstall the mfrc522 library, hopping it reset the parameters. I'll try to start a new setting from 0, and installing step by step the needed programs. – Dark Patate Nov 24 '20 at 09:49
  • 1
    I tried with a freshly installed RPi, and I got the same problem :( I don't know why it stopped to work :/ – Dark Patate Nov 28 '20 at 08:45
  • Well, my demo experiment shows a complete run down of all the CLI commands and response in a screen capture. If you follow step by step and only fails in the last step, and the responses show something is written, and only cannot read, then it is can read can not write problem. Perhaps it is the hardware problem. It would be nice if you can also upload the screen captures (not that many, isn't it?) to compare and contrast with mine. Of course there are other possibilities, ... Or try 5V PSU? Have a great locking down weekend. Cheers. – tlfong01 Nov 28 '20 at 09:38
  • 1
    Ok, my bad! It works! I checked again the connections, and... I shifted everything by one pin facepalm (I did my test on another Pi, the previous Pi uses a PCB where the connections are ok). So now, I have to install everything I need hoping the RFID will still works – Dark Patate Nov 28 '20 at 11:17
  • Ha, so it the human brain that does not work and cannot even walk the very first troubleshooting step! Have a great weekend. Cheers. – tlfong01 Nov 28 '20 at 14:07

0 Answers0