B4R Question PN532 and NFC Library

Discussion in 'B4R Questions' started by Helmut S, Apr 19, 2019.

  1. Helmut S

    Helmut S Member Licensed User

    Hi to all of the friends of B4R!

    I have the urgent need to read the UID of Mifare Desfire RFID cards and also to communicate with NFC enabled mobile phones. I guess that the PN532 chip would be the right choice, but i haven't found a B4R library so far. So far, I have used the MFRC522, but I'm not sure if it works with Desfire cards.

    Please, does anybody have a library to share or is someone willing to create one for SPI and I2C access to the PN532 RFID/Near Field Communication chip for B4r

    like e.g.


    Thanks in advance,

  2. kolbe

    kolbe Active Member Licensed User

    What does urgent mean? Yesterday, tomorrow, a few weeks from now?
  3. Helmut S

    Helmut S Member Licensed User

    Urgent means: the sooner, the better. Yesterday and tomorrow would be fine but I guess that might be a bit unrealistic ;). A few weeks from now will also be ok.

    Any help will be highly appreciated.
  4. MathiasM

    MathiasM Member Licensed User

    I am also looking into this topic. Altough my PN532 and MFRC522 readers are still on there way from China. But in my opinion, there should be no way why the MFRC522 should not work with Mifare Desfire (I use EV2). They operate on the same frequency, so 'something' should be read from the card. If the NFC protocol is correctly applied, it should work (and DesFire cards are NFC)

    Here is a topic on someone doing it with a MFRC522 reader on a RPI, and it seems to work: https://www.raspberrypi.org/forums/viewtopic.php?t=222832

    It's just a matter of reading the right bits and bytes I think. But as said, my readers will arrive somewhere this month..

    How far have you come with the MFRC522? Do you get something, or doesn't anything happen at all?
  5. Helmut S

    Helmut S Member Licensed User

    Hello Mathias,

    so far I've used the MFRC522 together with the rMFRC522 library to read the UIDs of Mifare 1k and Ultralight transponders, and it works fine for these kinds of transponders. The current point of interest is to read Desfire transponders too.
  6. MathiasM

    MathiasM Member Licensed User


    Yes I understand, those cards are easy. DesFire cards have a different inner working. But the RC522 should be capable of reading it.
    The problem with DesFire is that there is an OS running on those cards, and they need more power than the outdated (and unsafe) Mifare cards. El cheapo card readers are sometimes not perfectly wired or use sub-standard components.
    But it seems to be possible to alter them to actually read DesFire cards, see this page: https://revspace.nl/RC522Hacking
    I ordered a few to destroy them with my bad soldering.

    Altough that's only the hardware side, reading the bits and bytes is part 2. But I cannot say anything useful about that because my readers are somewhere in the pacific.

    That's why I asked that question on the final line, does anything happen at all? Are you getting giberish data? Or does nothing happen at all when you read your DesFire cards?
  7. Helmut S

    Helmut S Member Licensed User

    I guess you are right with both assumptions. I think, the main problem is that the rMFRC522 library isn't capable of reading the Desfire code.

    When I try to read a Desfire card, nothing happens at all.
  8. Helmut S

    Helmut S Member Licensed User

    By the way, all my RC522 boards (at least 10) can read Mifare Ultralight cards so far.

  9. MathiasM

    MathiasM Member Licensed User

    Yes, i've ordered the same readers, around 3$ a pop?

    I should first try it with sample C++ code with the arduino IDE, use this library: https://github.com/JPG-Consulting/rfid-desfire

    If that doesn't work, your reader is just too weak to power the DesFire EV card, then you have some soldering to do. You can try 3 things:

    Good luck, I don't know what I will do, because I really need DesFire EV2 to work :)
    Last edited: May 2, 2019
  10. kolbe

    kolbe Active Member Licensed User

  11. MathiasM

    MathiasM Member Licensed User

    Hi, very nice library you've made. But the library you've ported works only with the older (and unsafe) Mifare Classic cards. Not DesFire EV1 or EV2 as far as I'm aware.
  12. kolbe

    kolbe Active Member Licensed User

    Here's some info on that. Haven't tested any of that so not sure. I would guess you could use the send command method to do something.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice