• I want to make this post mostly for documenting my attempts at getting an RC522 RFID sensor to work with my small ESP8266 centered project.

    When trying to use the sensor with an adapted version of the MFRC522 example code, it gives an error :

    Uncaught Error: MFRC522 Request Error 16
    

    I understand the error code should be representing a bit register on the RC522 module itself, expressing an error. However I do not understand the page describing the errors in the datasheet (page 41) and how to relate it to my error code.

    I managed to get error 15 too, by using a different CS pin on my WemosD1.
    And error 255 by swapping MISO and MOSI pins.

    I know the sensor works properly. I tested it with an Arduino Nano, and most importantly, with my ESP8266 board (D1), with the same sketch as the Nano, using the Arduino IDE, using the same pinouts as with Espruino. It works fine this way. The Arduino library requires the RST pin to be wired to a pin, but I left it unplugged and set it to an empty pin. It didnt prevent it working.

    I've tried using both software and hardware SPI.
    I only get the error code with hardware SPI.
    MFRC522.findCards returns undefined with software SPI. Nothing else.

    At this point i'm suspecting there is something wrong with the MFRC522 library, probably something minor. The library is not very big but I don't understand the inner workings of the RC522.

    The options I'm considering:

    • Delve more into the SPI protocol, the MFRC522 library and datasheet, possibly re-making a library of my own.
    • Somehow compile the Arduino library into Espruino, if at all possible.
    • Drive the RFID with an additional MCU, like an Arduino Nano and communicate over existing i2C setup.
    • Drop Espruino. Javascript is only icing in this project. All components are working with the Arduino libraries.

    Any help welcome!

    Important links regarding this issue or similar ones :
    (Using software SPI) https://github.com/espruino/EspruinoDocs­/issues/258
    (Pico, KeyesStudio, similar error code) http://forum.espruino.com/conversations/­299035/

    Specific gear:
    Wemos D1 R1 (Uno form factor ESP8266 board)
    Keyestudio RFID-RC522 Module

  • Mon 2019.12.30

    Good Morning @Drumline18 and thank you for your interest in Espruino. Nicely written inquiry, with all the detail required.

    'At this point i'm suspecting there is something wrong with the MFRC522 library'

    Nope. That module written prior to my usage, was developed for the Original and Pico boards. I eventually got it to work with other boards as have many others. See last pp. ref 'finiky'

    Thank you for referencing my forum thread 299035. That was the second module I worked with, when I first started with Espruino and three years ago, Yikes! where did the time go? I intended to follow up in that thread with a solution I found, just nine months ago, but it is a back burner project at this time. Can't remember all the detail, and there have been many firmware chnges, upgrades and improvements since, but I think it had something to do with pin naming. See this associated thread:

    Attempting to get SPI running on ESP8266

    I also solved this using a logic analyzer, which enabled me to actually observe the bus data. Worth every penny and around twenty dollars. See resultant images in an un-related post at:

    Programming the Ublox NEO-6M


    'Somehow compile the Arduino library into Espruino'

    When one analyzes the detail ('C' vs Javascript) in volume of code lines Arduino requires, then gets the epiphany after working with Espruino (less code, WebIDE debugging, instant patch fix without recompile, tutorial modules that just work - with official supported boards), you may, like myself rarely do these tasks using Arduino. (I dove into Arduino nealy two years after starting with micros three years ago)

    Also, purchased a different CH manufacturer board to compare, but did eventually get the KeyeStudio flavor working with the logic analyzer. The RF detection was finiky for both, until it's working reliably. Watch the RFID ID digits too, as I muxed (fubar) decimal with hex.

About

Avatar for Robin @Robin started