Add details and clarify the problem being solved. This will help others answer the question. You can edit the question.
(Viewable by the post author and users with the close/reopen votes privilege)Edit question
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
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.
- 1Not much we can do to help. You need to add debug/trace statements to find the failure point. abyz.me.uk/rpi/pigpio/piscope.html and/or abyz.me.uk/rpi/pigpio/examples.html#Python_monitor_py will help you check the SPI comms. – joan Nov 19 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: raspberrypi.stackexchange.com/questions/109773/… to continue, … – tlfong01 Nov 20 at 6: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 at 6:49
- PS – Your might also find the chat record of the above Q&A useful: chat.stackexchange.com/rooms/106073/…. – tlfong01 Nov 20 at 6:52
- 1Thanks @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 at 9:05
- 1Thanks 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 at 9: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 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 at 14:30
- 1Is 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 at 9:49
- 1I tried with a freshly installed RPi, and I got the same problem 😦 I don’t know why it stopped to work – Dark Patate 2 days ago
- 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 2 days ago
- 1Ok, 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 2 days ago
- 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 2 days ago