Uncategorized

mfrc522 rfid module notes

 

====================================================================

Trying to code a RFID tag to a MFRC522 chip using raspberry pi but it is not allowing me to read it

Asked 
Active today
Viewed 71 times
1

Trying to read my

Asked 
Active today
Viewed 71 times
1

 

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:

https://pimylifeup.com/raspberry-pi-rfid-rc522/

https://medium.com/coinmonks/for-beginners-how-to-set-up-a-raspberry-pi-rfid-rc522-reader-and-record-data-on-iota-865f67843a2d

Python coding based on the websites I've used in order to try to get my tag to read

 New contributor

0

Answer

1. The PN532 NFC/RFID Module V3 being tested

Reference: nfclib v1.1.7 PN532 NFC Module Testing

pn532 1


2. Mfrc522 software (including SPIdev and GPIO) setup record

mfrc install


3. Minimal configuration of SPI and I2C channels for testing the PN532 module

boot/config.txt


4. PiMyLifeUp Gus SimpleMFRC522 Library

simplemfrc522 lib


 

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:

https://pimylifeup.com/raspberry-pi-rfid-rc522/

https://medium.com/coinmonks/for-beginners-how-to-set-up-a-raspberry-pi-rfid-rc522-reader-and-record-data-on-iota-865f67843a2d

Python coding based on the websites I've used in order to try to get my tag to read

 New contributor

0

Answer

1. The PN532 NFC/RFID Module V3 being tested

Reference: nfclib v1.1.7 PN532 NFC Module Testing

pn532 1


2. Mfrc522 software (including SPIdev and GPIO) setup record

mfrc install


3. Minimal configuration of SPI and I2C channels for testing the PN532 module

boot/config.txt


4. PiMyLifeUp Gus SimpleMFRC522 Library

simplemfrc522 lib


 

 

===============================

Q: Trying to code a RFID tag to a MFRC522 chip using raspberry pi but it is not allowing me to read it

627117717.prTrying 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: https://pimylifeup.com/raspberry-pi-rfid-rc522/ https://medium.com/coinmonks/for-beginners-how-to-set-up-a-r…

I tried libnfc1.1.7 the other day and found it OK. I followed the instructions, setup in 15 minutes, and read a tag successfully. (1) “Problem with detecting badge with PN532 and Raspberry Pi“: stackoverflow.com/questions/60819793/… Perhaps you can try libnfc and let me know if you have any problems. I might also try the PiMyLifeUp and compared with your installation record.

By the way, you gave two tutorial references. The first one is OK. I think I would try that later. But the second tutorial seems a bit out of date, because it uses python 2.7. I worry that the drivers might not be compatible to your hardware/software configuration. Can you let us know your Rpi and OS version?

Hi mate my RPI is 3 and the os is rasbpian noobs using linux

Still not working unfortunately not sure why it is not working in the first place when i have followed each step and the modules all turn on and work!

I didn’t catch you. Did you mean that an hour ago when you asked your question, you had no luck. Both tutorials didn’t work. But in this hour you tried your luck again and every step now work smoothly, and so NOW YOU CAN READ the tag? Can you please confirm which one of the two tutorials works, or both work. It would be nice if you can very briefly answer your question here, so that other newbies would be grateful to know how to setup the RFID reader? If every step work, but still cannot read the tag, I can repeat your steps and see why you still cannot read the tag. Cheers.

SO did each step by step the link you said i should try still NO LUCK still can not read or write the tags

Thank you for your clarification. So perhaps I can try your first tutorial. If no luck, then I can try the second tutorial. Wish me luck. Cheers.
2:47 PM

Ok that sounds good if your ok with that and if the tutorials work for you then must be something software or maybe hardware that is going wrong on my side!

Well, I just finished reading the tutorial by Gus of PiMyLifeup, also skimmed the 70+ comments. I understand 90% what is going on, except the SPI library which seems not exactly the same library I am using. This might be one thing I might get stuck. Anyway, I am now starting to follow the tutorial, not step by step, but skipping steps and using not exactly the same tools. Eg, I will use Rpi4B buster Thonny IDE to edit and run the programs. (One reader commented using IDLE python 3, but IDLE is not longer available), / to continue, …

Thats fine i was using the Terminal to do everything in and the code coming from the pi up my life website just to see if it worked or not and as of yet still not working

No problem. I can also use CLI bash, pip, nano etc for the preliminary setsup, and perhaps more GUI later. I am getting started with the PN532 module which I tested OK with I2C some time ago. Now I am switching from LibNfc library to PyMyLifeUp library.

Yesterday evening I already used “pip3” to install “mfrc522”. As I said earlier, I don’t know nothing about SPI-Py, so I did not use the newbie scary “git-clone” and “python setup” to install the SPI-Py module. I noticed that what you built is a python 2.7 SPI-Py module. But I started learning python already with Rpi IDLE python 3.5.3. So I am not going back to the old python 2.7. Just now I checked out that pip3 seems happy with pip3 installed GPIO, SpiDev, and mfrc522 requirements. So I am hopping that I don’t need SPI-Py and go straight to python programming.

HI have you had anymore luck in trying to use the mfrc522 module to see if it reads any tags by any chance as thats the one im more focussed on?

if the same outcome for the mfrc522 can be achieved like testing the tag pn532 nfc module that would be great as i still can get anything to read what so ever!

No luck! Now I am googling to debug. I need to make sure a couple of things, including: (1) Must I use python 2? (2) Must I use SPI-Py and not buster preinstalled SPI? You might like to check out the following discussion: raspberrypi.org/forums/viewtopic.php?t=207328#p1282986. Ah, supper time, see you tomorrow.

I just found out that I have forgotten to make the reset pin connection. So my module is not reset to start working. There might be other careless mistakes.

I also found out that there are at least two mfrc522 gitHub library. Perhaps I ppip install the wrong library: github.com/mxgxw/MFRC522-python. Of there are other reasons, say the library is only for Rpi 2, 3, not for Rpi4 buster. I also check the source code that SPI speed is set to 10MHz, which is too high for my long wiring. I need to set SPI speed lower, perhaps 400kHz. In short, too many possible bugs. libnfc 1.1.7 is very smooth, it took me only less than 30 minutes. Perhaps I tried the SPI librnfc version to verify that SPI speed can be set to 10MHz.

I also read that PN532 old versions 1.x are not reliable. So everybody is using V3. Are you on V3?

The following also says must lower SPI frequency from 5MHz to 50kHz. That means PN532 cannot do high frequency: wiki.sunfounder.cc/….

Now I am thinking of going back to libnfc and test the spi version, to make sure both libnfc v1.1.7 I2C and SPI version are OK, then I will come back to do PyMyLifeUp SPI version. I am also configuring minimal number of SPI, I2C, and UART channels/ports.
2:47 PM
Sounds good the libnfc version is looking good so far hopefully the same will work for the mfrc522 chip and tags
==================
3:42 AM
I am still debugging. About SPI Py, my quick and dirty conclusion is that it is an old thing, developed 7 years ago, in the Rpi2, python 2.7 days. Gus’s tutorial started 2017, so he might use SPI Py which is universal for the general Rpi users.
Please let me know if you know a reason that we must use PI Py and python 2.7. Otherwise I will still try pip3 mfrc522 and python 3. I am also using Version 3 module. I will also try the Blue PCB Version 1, just to make sure yours V1 module is not working.
Your question says: “read RFID MFRC522 Mifare blue tag not working. … when i put the tag to read it doesn’t show up as quick?” (1) To read quick, you need to use the module interrupt output signal to interrupt Rpi, otherwise loop scanning might be slow,
(2) But your problem is not quick or slow, because the module might be reset/ setup ready to read, or your tag is bad. I forgot to wire the module reset wire to Rpi, so this might be a bug, among other more possible bugs. So I am going to wire “interrupt” and “reset” between Rpi and the NFC module. See you later.
4:21 AM
Now I am reading the following tutorial to learn how to connect the Reset pin. I found that the signal Low power downs the modules, and Rising Edge resets the module. In other words, I can just connect a jumper wire to manually reset the module. It is a bit confusing if I can leave the Reset pin floating. I need to check the schematic to see if this pin is pulled high.
user image
Sorry, I forgot to include the web link in the above comment. Here it is: “What is RFID? How It Works? Interface RC522 RFID Module with Arduino”:
https://lastminuteengineers.com/how-rfid-works-rc522-arduino-tutorial/.
The LatMinuteEngineers’s colourful MiFare Classic 1k memory map is also very good to refresh my memory.
user image
4 hours later…
8:27 AM
Now I am going to look at the SimpleMFRC522.py library module, add debug print statements for debugging.
user image
9:18 AM
@tlfong01 Hi would preferably want to use python 3 instead of 2.7, just really want to see if it works on your side so if it does i can see where i am going wrong and to basically use this a basis and manipulate the code for the mini project i am doing.
for me personally i just want to know the reason why it isnt working becasue even purchasing a brand new module and tags the same output is coming up you see
The mfrc522 modules are on and working i think, the tags dont read or even write when being placed near the chip and the code and wiring is copied exactly from the website and struggling to find where the error could be unless like you said i coul have missed parts out or the blue tags dont work.
quite new to this thing python and the raspberry pi just want to get to the bottom of this!! appreciate you helping out by the way !!
9:57 AM
@627117717.pr Just quick random comments. (1) python 2.7 supported is ending this year 2020. So there is no point trying to debug python 2.7 programs. (2) You seem to have installed python 2.7 compatible SpiDev and SPIPy and perhaps also pip2/git/clone python 2.7 version of mfrc522. That is why I skipped Your or Gus first instructions to install SPI Py and SpiDev. I only use pip3 to install mfrc522.
Since lsmod spi says spidev and spi_bcm2835 are installed, so SPI part should be OK. pip3 install update also says the other installed modules are OK. So I guess I can do everything in python 3. Actually use bash to open python 3 shell and can import mfrc522 without problem, so I think there is 90% chance I can move on to look at the mfrc522 library to see how to debug.
I found the main library/module is only 400 lines of python statements, and seems well documented, so it should be easy to do minor fixes, such as lowering SPI speed from 1MHz to 50kHz and so on. I am not going to move the main library mfrc500.py and the SimplePI speed from 1MHz to 50kHz and so on. I am not going to make a copy of the main library mfrc500.py and the smaller, 100 lines SimpleMFRC522 in a penzu reading log file and make more newbie comments.
If you don’t have much experience in Rpi and python, then perhaps you can just sit back and watch what I am messing around. But you are welcome to make suggestions, such as preferring python 3 and not python 2.7.
10:18 AM
@627117717.pr This penzu programming log file has the mfrc522 library (actually just a 400 line python program) and the SimpleMfrc522 (about 100 lines) . You can easily find the SPI speed setting in the main class. So it is easy to hack. Penzu programming log: penzu.com/p/08d4fdf2. Ah supper time! So see you late this evening or tomorrow.
1 hour later…
11:43 AM
thats great sounds like a plan hopefully can get this working asap
2 hours later…
1:44 PM
@627117717.pr Ah, I am just a nfc newbie, scrapping the surface. So far I only have luck with libnfc-1.7.1 in I2C config. I am trying the other config, SPI. and UART, but I found things about SPI I don’t understand, so it might take me days to google to learn more about SPI. For SimpleMFRC522, I am googling to learn more, before I really starts. By the way, I read the following Q&A and saw a guy using SimpleMFRC, but I don’t know he ahs any problem with the SPI speed.
Anyway, if you have a tight deadline, then try libnfc I2C mode, because I have given the answer in the stackOverflow forum. Or google around harder.
This is the guy who had luck using SimpleMRFC: raspberrypi.stackexchange.com/questions/105293/….
2:12 PM
I searched this forum for SimpleMRFC and found 11 results. Other forums might have many more we can read and learn something.
2 hours later…
3:48 PM
nice one will look for sure
=========================
1:19 AM
I read your question a second time. It appears that you were following two tutorials at the same time, the first one using python 3, second one python 2.7. One tutorial uses SpiPy, and compiled SpiDev, the other does not. I am not sure if you are also using pip/pip2/pip3 at the same time.
If you use pip2 first, the buster might set default to python 2 envrionment. Then if you use pip3 later, the piped drivers might go to the python 2 rooms, causing big mess, or a small dark hole, where garbage goes in will stuck and never come out. So I would suggest the following. Get two unwanted uSD cards, flash new buster, one for buster all preinstalled python 3, pip 3, spidev, only installed is pip 3 install mfrc522.
The above is what I did and summarized in this chat. Now you are in sync with my current configuration. And if you get stuck again, like a reading problem, then I can repeat your situation and program. The SimpleMFRC522 tutorial seem to write first and then read later. But you seem to skip the write part and jump to read part. I need to make sure if the write part does init something that is assumed in the following read part, …
In the mean time, I would study the 400 line MFRC522 library and the 100 line SimpleMFRC program, to see what print statements can be inserted to help debugging.
.END
=====================

Discussion on question by 627117717.pr: Trying to code a RFID tag to a MFRC522 chip using raspberry pi but it is not allowing me to read it

Discussion on question by 627117717.pr: Trying to code a RFID tag to a MFRC522 chip using raspberry pi but it is not allowing me to read it

Raspberry PiImported from a comment discussion on https://raspberrypi.stackexchange.com/questions/109773/trying-to-code-a-rfid-tag-to-a-mfrc522-chip-using-raspberry-pi-but-it-is-not-all

first message 2020-03-29
last message 3 hours 17 minutes ago
00:00
06:00
12:00
18:00
4
today
26
yesterday
17
per day
Su
Mo
Tu
We
Th
Fr
Sa
51
this week
0
last week
51
per week

join this room
view transcript

51
2

Owners of this room

.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: