Search code examples
pythonnfcraspberry-pimifare

NFC tag reading in python on raspberry pi


So i bought a cheap mifare NFC chip reader from ebay for 5$. I wanted to play around with chips, and ultimately copy some NFC chips i have here. I have a NFC chip that I use to open my locker with on school, but the card we have is really big and inconvient, so I want to copy it on a smaller NFC chip and put it on my keyring.

So i hooked it up with my raspberry pi, and first off, there is NOTHING on internet about connecting this card with your raspberry pi. Ohwell, a challange, fun.

I found some basic code from a spanish website(im dutch so itwas kinda hard to understand :P) but it can only read the UID of a NFC. So i tried to understand it, and eventually i did, and I added the code to calculateCRC and read some blocks.

However, I have no clue how the NFC data structure actually works, all i did was find some arduino code samples that were in C, translated them to python, and I think it works.

So i setted it up that it reads block 0 to 8 and prints themn all. On all the NFCs i have I can only read block 0, rest is giving an error. And block 0 consists of one byte, that's a 0x04.

If anyone has any clue what is happening, please tell me. And are there any links were NFC data structure is actually explained. I found a bunch of Android stuff, but i dont have a smartphone, and i want to do it with this MFRC522 card. I read somewhere you need to auth a block or something? I saw some code for that too, but how does that work? How do I know the keys?

thanks


Solution

  • There are lots of links on google wherein you can find information on data format used in NFC.

    Some of them are

    http://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef

    http://developer.nokia.com/Community/Wiki/Understanding_NFC_Data_Exchange_Format_(NDEF)_messages