mxgxw / mfrc522-python Goto Github PK
View Code? Open in Web Editor NEWA small class to interface with the NFC reader Module MFRC522
License: GNU Lesser General Public License v3.0
A small class to interface with the NFC reader Module MFRC522
License: GNU Lesser General Public License v3.0
Hi
I run "Read.py", I got below error:
Can't open device: No such file or directory
"SPI-Py" is intalled but when I run this: ls /dev/spi*
and it returned this:
No such file or directory
what should I do?
thanks
Hi
Thanks for great software.
How to modify MFRC522.py and Read.py file to read from two readres ?
I'm connect first to /dev/spidev0.0 (24 pin) and second /dev/spidev0.1 (25 pin).
I'm can read from first and second reader when change /dev/spidev0.0 ti /dev/spidev0.1 in MFRC522.py.
Regards
Lukasz
Hello,
just somehow got to your cool module so i thought i ask you.
I bought some really cheap MFRC-522 reader/writers for my raspberry pi RFID project.
Now i started testing the things, but was really disappointed by the distance of reading the passive tags (<1 cm)
What i want to do is to achieve reading tags with a raspberry in a distance, lets say 0.5-1 meter and through clothes
Do I need to get an antenna a differenet reader? Any good suggestion. How far does your reader read and trhorugh clothes too??
Thanks a lot
I needed to be able to read MFRC522 reader on a Pi from JavaScript (Node.js). What I did was port the code from Python to JavaScript. I'd like to offer this up to you as a new repository. If you are not interested in taking the code, let me know and I'll create my own ... the reason I want to offer it up to you is that I don't know how the MFRC522 works ... and merely ported code ... the JavaScript code works fine but I feel that the ownership of such an offering is best held by someone who owns MFRC522 knowledge at the core.
Was able to setup the RC522 and get it running with the card and tag that came shipped with it. I tried reading my other NFC sticker tags (NTAG216), and I keep getting authentication errors:
AUTH ERROR!!
AUTH ERROR(status2reg & 0x08) != 0
Authentication error
Anyone have an idea on how to fix this?
This code is missing cleaning up for the open file descriptor. Just like we open spi.openSPI()
we must also clean up by calling spi.closeSPI()
. This is required when dealing various SPI slaves and when you need to open and close to those slaves often. This can cause too many open file descriptors.
Out of curiosity, and because SPI-Py was previously unknown to me, I'd love to know what motivated you to chose it over py-spidev.
Cheers!
Hey,
I just downloaded this code, and I'm using it now! I just got this MFRC522 card, and I got no clue how to operate it, so could you explain or link me to some kind of documentation of how I could implement writing? And what about the tag size? Not all tags have 5 bytes, or do they?
Thanks man, you're great!
how to clear a crc error when it happens ?
a soft/hard reset does not solve the problem.
need to clear the crc error without powering up the circuit again.
appreciate all the help.
thanks
Hi
If a card is put against the reader, the Read.py script will continue to read the same card over and over, and process the output (in this case printing the UID) again and again.
I am looking for a way of only printing the UID out once, and then upon subsequent iterations, if the code detects it is the same card sitting on the reader, then it should not print out the UID.
Any assistance would be greatly appreciated.
i am using pi3 and mfrc522 , but pi3 gpio has changed, can you update your doucument , wo dont konw how to line pi3 and mfrc522. thank you very much
PICC_REQIDL = 0x26
PICC_REQALL = 0x52
PICC_ANTICOLL = 0x93
PICC_SElECTTAG = 0x93
PICC_AUTHENT1A = 0x60
PICC_AUTHENT1B = 0x61
PICC_READ = 0x30
PICC_WRITE = 0xA0
PICC_DECREMENT = 0xC0
PICC_INCREMENT = 0xC1
PICC_RESTORE = 0xC2
PICC_TRANSFER = 0xB0
PICC_HALT = 0x50
Where did you find all these? Could you please tell me?
I am trying to understand the code you wrote.
The following error is printed when running this Python code:
Card detected
Card read UID: 13,136,60,202,115
Size: 8
AUTH ERROR!!
AUTH ERROR(status2reg & 0x08) != 0
How to half tag ?
If i tapping card, i want to read just once.
I'm a NOOB at NFC and Python, so please forgive my ignorance.
I installed SPI-Py and MFRC522-Python per the instructions. When I run "SUDO PYTHON Read.py" the next line displays no text, even when waving a card in front of the reader. The line remains blank until I use ctrl+c. In viewing the Read.py file, it appears that SOMETHING should be on the screen.
I'm not quite sure where to begin looking to find out where I'm going wrong.
Thoughts, anyone?
I actually already raised the issue and details on this thread, but belatedly thought it might have been better to raise it as a new issue if help was to be allocated #40
I don't know how maintained this is anymore, but I think a warning note about the Access Control Bits in the sector trailer should be added somehow (either in the code or the readme here on github).
There is a rundown of how they work here, but basically the last block of a sector contains the authentication keys and bit pattern used to set access rights. Overwriting this with random data will most likely destroy that sector forever as there is no way to write back a new pattern if you don't have proper access. I also suspect this is the reason for some of the people are reporting unexpected authentication errors on the issue tracker, as trying to read a garbled sector will trip the auth check.
It could also be smart to mention that the very first block contains manufacturer info and is read-only, basically staying out of the first sector all together is probably smart unless you really need the space.
tl;dr: Do not use MFRC522_Write with location 3, 7, 11, 15, 19, 23, ..., etc. unless you know EXACTLY what you are doing. They are used for important stuff, and overwriting them makes the whole sector UNREADABLE FOREVER!
Also note: There also seems to be a mismatch in the code output about what a block/sector is, each block is 16 byte, each sector is 4 blocks (with the last block being reserved for the access control). The read/write commands of this library operates on block level, but the read prints it as sector, which can be confusing.
Hi~
Thanks for this useful module.
I can run the read.py file successfully
pi@raspberrypi ~/Documents/rfid_demo $ sudo python read.py
Welcome to the MFRC522 data read example
Press Ctrl-C to stop.
but when I move the file to another directory
error occured
the command line output is:
pi@raspberrypi ~/Document/mahjong/test_code $ sudo python read.py
Traceback (most recent call last):
File "read.py", line 21, in <module>
MIFAREReader = MFRC522.MFRC522()
File "/home/pi/Documents/mahjong/test_code/MFRC522.py", line 111, in __init__
nSPI(device=dev,speed=spd)
NameError: global name 'nSPI' is not defined
so I wonder what is the function nSPI()?
the code is absolutely the same.
I am new to python.
Thank you for your help!
Hello,
i have a small problem with my MFRC522.
All the pins are connected correctly. but now, when i want to start the programm the pi shows me
python Read.py Traceback (most recent call last): File "Read.py", line 41, in <module> MIFAREReader = MFRC522.MFRC522() File "/home/pi/Desktop/MFRC522-python/MFRC522.py", line 133, in __init__ GPIO.setup(NRSTPD, GPIO.OUT) NameError: global name 'NRSTPD' is not defined
I hope that you can help me.
Thanks a lot for your help!
If I run python Read.py
without sudo, it gives me an error:
can't open device: Permission denied
Aborted
I can't rely on sudo privileges while reading RFID tags, what should I do?
Hey, I wanted to add a RFID reader in an Existing project , but GPIO - 25 is already in use . So how can i change the reset pin in the code ?
When working with a library MFRC522-python I watched high CPU. About ~ 50%. Please support this issue. Thank you.
I am trying to send an NDEF Message from my Android Phoneto my Raspberry Pi via the rfid-rc522 reader.
When using this library I constantly get an authentication error. Is it possible to read NDEF Messages from Android with this library?
I would like to note that this code did not worked with the model B+
when executing (sudo python Read.py) I just got the following message:
Welcome to the MFRC522 data read example
Press Ctrl-C to stop.
when I touch the tag nothing happens.
Is there any diagnostic steps that I can follow to discover where is the bug?
I've followed this tutorial (https://www.piddlerintheroot.com/rfid-rc522-raspberry-pi/) to the T, and I keep getting the error " Traceback (most recent call last):
File "Read.py", line 41, in
MIFAREReader = MFRC522.MFRC522()
File "/home/pi/MFRC522-python/MFRC522.py", line 131, in init
spi.openSPI(device=dev,speed=spd)
AttributeError: 'module' object has no attribute 'openSPI' "
whenever I try to run the Read.py file.
Any help?
Dump.py map all data stored in MIFARE Classic 1k card or tag. When Dump.py is executed, prints "Sector" at the beginning of each line of data. I think this is wrong. Each line represents a “Block”.
"2.2 Logical Structure
A MiFare Classic card is in principle a memory card with few extra functionalities. The memory is divided into data blocks of 16 bytes. Those data blocks are grouped into sectors. The MiFare Classic 1k card has 16 sectors of 4 data blocks each..."
Sources:
http://www.cs.ru.nl/~flaviog/publications/Attack.MIFARE.pdf (p. 4, section 2.2.)
https://upload.wikimedia.org/wikipedia/commons/3/39/MiFare_Byte_Layout.png
Hello
Is it possible to reader the raw hex code with this lib?
ie - 1a44cb1b which can then convert into a 10 digit code 0440716571
currently using the examples I can only see a 12 digit code 272056826136
The newer version of Raspbian have switched to using dttree when enabling SPI. When you do this upgrade this library stops working. Running the Read.py example just sits there.
hi,
i have key and i want to read 2nd sector and 2nd blocks data.
is it possible to do this with MFRC522-python library?
https://github.com/mxgxw/MFRC522-python/blob/master/MFRC522.py#L179
>>> not ~(0b1000101 & 0x01)
False
>>> not ~(0b1000100 & 0x01)
False
I feel like I'm eating shit when refactoring this code. Sorry, but one should choose the language he knows for his projects.
Hi - Thanks for a useful module.
Could I trouble you to add some indication of the license / copyright to this project?
It seems that the original Arduino code might be under Apache v2 - if this is a port of https://github.com/JoyLabs/arduino
I'm interested in using the code as part of https://github.com/oskarpearson/raspberry-pi-access-control-system but would prefer to license clarity before I do so.
Thanks!
Oskar
It appears @mxgxw has abandoned this project. Is there anyone willing and able to maintain it?
Please shout "here" now ;-)
Please, remove this... Not an issue.
Im not sure if this is a issue or not, but i have had a look at the antennaOn function witch on line 157 contains this if(~(temp & 0x03)):
As far as my testing goes I am not able to make this statement return true. This is because of the ~ bitwize complement never return 0.
Would any of you be able to shed some light on what this if statement does? or is suppose to do?
I can see that you are checking if the "output signal on pin TX1 delivers the 13.56 MHz energy carrier
modulated by the transmission data", also TX2. Whatever that is supposed to mean.
File: MFRC522.py
Hi,
And first of all, thank you for this program, that works well!
I I just noticed that the reader stops readingt usually after a few hours in use, even if the program still run. Has anyone got some tips for solving this issue?
Cheers,
Maxime
I tried the your lib and it works great (haven't tried the reading and writing data yet).
My problem is that when I use my Mifare Ultralight cards that have a 7 Byte UID instead of the 4 Bytes of a Mifare 1K. I've been searching myself for hours but I can't figure out how to change the code or what to call.
According to the datasheet the Mifare Ultralight cards are supported so I don't know why I can't get it fixed. Any chance you could add support for it?
Hi!! Great job!! I dont know if it is the right place to ask, but, this library can read MIFARE PLUS with RC522?
If not, could give me a tip of why it can read? Is a software or a hardware point?
Thanks!!
As in topic. Anybody know how can I write to the card new key?
Key is used for example in MFRC522_Auth method.
how to control and recieve data from two rc522 readers in one raspberry?
Hi
Any clue on how to adapt the receiver gain in your example ?
As a complete novice to Pi, I am having trouble out how to actually write data onto an rfid. Any help? Thanks
I am tyring to implement this with another process, where i can read the stdout of the main.c and get card details.
Ex: .sudo python Read.py | ./sample.c
my sample.c contains simple read operation from stdout, when i check with any other program which prints output like "hello world" continously in infinite loop, i am able to read it from sample.c. When i test with rc522, i am not able to read anything.
I was curious if there was a way to limit the read script from a continuous scan to limit a scan recognition to every five seconds or even a minute. I've just noticed that if I hover an RFID card over the sensor that it will continue to read until I swipe it away. And sometimes if it's a fast swipe, it could still read two or three times.
Is there a way to fix this or does anyone have any suggestions? Thanks~ Matt
Hi,
Can I write in the Sector 0 with the chinese changeable UID cards? Seems not possible with this library but not impossible by hardware.
Hi there,
I can see that the code in this repository isn't working, as there is an issue with authentication. Is this repository still active? I'm asking because I've fixed the error with authentication and created some examples in another repository. If you still maintain this I'll submit a pull-request with the changes.
Hi, I've downloaded your library but it has bad indentation in your last commit, i rolled back to your first version and it's working, but as your last commit it is not working.
Hi! I am trying to run the codes you have uploaded.I have downloaded the SPI-py file and the RPI.GPIO -0.4la files, both of these are stored in my home/pi directory along with zip life of your code( I extracted them in the same home/pi) .
I don't have a lot of experience with pi, just have run a simple code of PIR using GPIO which works.
I have tried to run the files you gave in the Idle , gksudo idle- then opened the files in the order MFRC522.py, dump.py, read.py, then write.py and clicked on run module no output is coming, I am placing my RFID card to read but it is not reading anything, no print statements shown in the code are coming on python shell.
an error line113 GPIO.setup(22,GPIO.OUT) is coming
i will recheck the pins but please tell me how to execute these file, I mean one by one or all together what is the procedure
Scenario:
I want to dump all of the data like the DumpClassic1k funtion except one of my sections of sectors has a different auth key. (Sector 11 has a non-factory auth key, so Sectors 8-10 don't authenticate).
So, I kick off that function expecting Sectors 8-11 to fail auth. But, ALL sectors after 8 fail. 12, 13, ... 63.
The issue (after making my own versions of that function and working through it) is that the auth function doesn't reset after a failure. So, any future calls fail too regardless of the auth key. Now, if you create a whole new instance (ie. Rerun your script) of the MFRC522, then it works again (well, until you get a single failure.) I've output the status value and it seems that the status is never reset. Status is "0" until a failed auth. Then it is "2" and all subsequent auth calls have status "2" regardless if they SHOULD succeed or not. If I remove the "failed" sector in my iteration and run only against sectors that pass auth, then all status's are "0" (even the ones that showed a "2" in the previous scenario where they ran after a failure.)
Any help is appreciated. This utility is awesome and I really like its functionality. Just need this flaw fixed. Thanks.
Hi, I try to use my RPi3 and the RC522 and a touchscreen display aswell so i need to put my RC522 on the SPI1 How can I do it ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.