MFRC522 issue with Pico

Posted on
  • I've upgraded my pico to the latest firmware 2.01, and testing the MFRC522 NFC/RFID module that came with the kickstarter geek kit. I've tried running the test code on this page and another and finding I'm getting some kind of runtime error.

    Uncaught Error: MFRC522 Request Error 254
     at line 1 col 189
    ...("MFRC522 Request Error "+a);a=this.r(20);return this.ra(18,...
    in function "req" called from line 1 col 34
    this.w(26,7);return 0<this.req(38).length
    in function "isNewCard" called from line 1 col 16
    in function "findCards" called from line 6 col 3
    in function called from system

    I'm running this test code

    SPI1.setup({sck:B3, miso:B4, mosi:B5 });
    var nfc = require("MFRC522").connect(SPI1, B1/*CS*/);
    setInterval(function() {
     nfc.findCards(function(card) {
      print("Found card");
    }, 1000);

    I wonder if anyone else has come across this issue?


  • Sun 2019.02.17

    Hi @Michael

    Have you tried removing the embedded comment in Line 2 of the test code?

    and if lines 4 and 6 are commented out, does the same error occur? (attempting to see if the library even gets loaded without error)

    I remember having a similar issue nearly two years ago, and vaguely remember the /*CS*/ may have been the culprit, but can't find my notes. I'll keep looking. . . .

    Not in my notes but was part of a post I made. Similar error, not sure if this will solve your issue, just passing info along. Contains battery supply considerations, mfg error code reference links, along with other code snippets.­299035/

    Also, do you have the green KeyStudio variant, or the typical blue circuit card? After two weeks back then, I eventually had to abandon as I had read on other sites, that the KeyStudio board was problematic.

  • /*...*/ is the perfect way to do inline documentation... some doc tool compose html doc of this information.

    Having above out the way, lets look at some details.

    As this conversation shows, it is badly manufactured hardware. Taking a closer look at can though fix the issue... I got numerous RFID HW modules going with the given Espruino RFID SW module and there is no complaint what so ever...

    Sometimes the best approach is to take everything apart, forget the experience back to the begin of starting with the subject matter. Then switch everything off and on again. Then make sure you have the most recent Espruino update flashed (which you did). After that, go methodically step by step forward and put the things together. Do not think about any short cut even though in the past they worked.

    If things just don't want to budge, take the unminified module and put it inline with your (test) code, because as many rules are true, this one is as well: nobody ever has proved that a particular SW piece is error free, because errors are like truly new viruses: until they get active - for what ever reason - they cannot be detected... Whit that I say: it is possible that there is an error in the module... and there could even be one with the hardware, and with that I also allow an STM32X4... chip appliance not doing its job anymore because it is blown up... (recently I experienced- at least it felt that way - that A8 on a PICO could not do PWM anymore... it made logically no sense, but I switched to another pin and I could move forward... I did not go back and validate, because at that point in time there was just no need to. But I will remember when using that pin on that board again for PWM and will take a closer look then.)

    With the code inline, you can do some debugging w/ Espruino IDE debugger, and you can also add console logging to see what's going on.

    This source for you code example LGTM - nicely documented.

    What can help to help you in this matter is to attach a pic of your hardware setup... With a close enough crisp shot, hardware issues - board or wiring - can be detected as well. Another thing to remember is that breadboards and jumper wires sometimes quit their job or do it fluky / unreliably...

  • Thanks guys for your help. As expected, taking the comment out didn't help. The RFID board is the same greenish-looking one on the module demo page. I've seen other red-coloured variants of this board that doesn't seem to have the SDA pin (not sure what this is for anyway).

    Yes, I will try looking at the source file for the module's include and see what I can find (I may try another board too). I may also try pull-up resistors on the SPI lines.

    Thanks alot for your assistance.

  • Is it possible you're just powering the module from 3.3v and not the 5v output? And is GND connected ok?

    I've actually used these boards pretty recently so I'd be reasonably confident that everything works ok.

  • Thanks Gordon. I've tried the 5v and 3.3v supply & GND is connected ok I believe. I've tried the other SPI ports, so I suspect it maybe the card. What should I connect SDA pin (on the RFID board) to? Your original page says B2 but I think that's not an accessible pin.

    The image shows how I originally wired it up.

    I've ordered another card (red board) so I'll see how that fares when it arrives.

    1 Attachment

    • pico.jpg
  • Ahh - I wonder why the docs say B2 - as you say that's not usable on the Pico. You can however use pretty much any signal pin on the Pico for B2. You used B1 originally by the look of it, and that would be fine.

    It doesn't seem to be connected in that image though? If it wasn't connected to anything then it would definitely cause your problems

  • Sorry I forgot to mention originally that I had tried using B1 (wired it to SDA - B1 is 4th from the right on the top row of pins in the photo). It may be worth to update the doc (to specify B1 for pico & B2 for original for SDA)? I also tried tying SDA to hi or lo, and in all cases I'm getting spurious emissions of the error I mentioned. I will try another card, and report back. Thanks for your help.

  • @Michael

    The MFRC522 chip as well as the board supports multiple protocols. That the chip AND board run on SPI requires pin 1 to be connected to GND. I do no expect this not to be, but one never knows... and it may be configurable on your version of the board.

    In your hardware setup I miss the connection of NSS/CS that selects the board... An open input could be the issue. You though say in your last post #8 that you tied it to either LOW and HI, and you still get spurious emissions of the error. Tie it to an Espruino pin and let it control... Even though I do not expect that the signal change / edge just before and after the communication makes a difference, it could be.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

MFRC522 issue with Pico

Posted by Avatar for Michael @Michael