RFID-RC522 starter problems

I followed an old thread from 2014 to setup my RFID-Kit like this:

Photon to Board:
A2 = SDA
A3 = SCK
A5 = MOSI
A4 = MISO
nothing = IRQ
GND = GND
A1 = RST (why not to Photon RST)?
3.3V = 3.3V

I tried this code with Photon v0.6.3:

    // This #include statement was automatically added by the Particle IDE.
    #include <MFRC522.h>

    #define SS_PIN      A2
    #define RST_PIN    A1

    MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance.

    void setup() {
        SPI.begin();
        SPI.setClockDivider(SPI_CLOCK_DIV8);
        mfrc522.PCD_Init();
    }

    void loop() {
        // Look for new cards, if nothing found, quit
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
        	return;
        
        }
        
        // Select one of the cards, if nothing found, quit
        if ( ! mfrc522.PICC_ReadCardSerial()) {
        	return;
        }
        
        char cardID[32] = "";

        for (byte i = 0; i < mfrc522.uid.size; i++) {
        char hex[4];
        snprintf(hex, sizeof(hex), "%02x", mfrc522.uid.uidByte[i]);
        strncat(cardID, hex, sizeof(cardID));
      }
    
    Particle.publish("rfid_scan", cardID, 60, PRIVATE);
    mfrc522.PICC_HaltA();
}

I get no output: how can I check that my PIN soldering is just ok and
why the definitions from RST mapped not to Photon RST?

Because you want to control that pin to reset the RFID reader by code, but the RST pin on the Photon can't be controlled via code and would also reset the Photon and not the RFID reader alone.

SInce there is not delay() in loop() you potentially also violate the rate limit for Particle.publish()

1 Like

ok - understand the point with RST (Link to pinout diagramm)
I expand the code with an serial output and delay:

Particle.publish("rfid_scan", cardID, 60, PRIVATE);
mfrc522.PICC_HaltA();
Serial.println("Card detected:");
Serial.println(cardID);

delay(2000);

No output on serial/cloud. It´s a brand new kit - how can I check whether the solder joint works?

Usually visual inspection should be enough.
If you post a hi-res image of both sides we can have a look too.

Is there no way to check the initialization-status by code?

The MOSI joint doesn’t look too good.

If you want to check the initialisation you can copy/paste the library sources to your project and sprinkle some Log.trace() statements all over the code.

Instead of using SPI.begin() and SPI.setClockDivider() in your setup, I’d rather use the libraries own function mfrc522.setSPIConfig() tho’
You can also add some debug statement and check the state of A1 (reset pin). It should be HIGH after initialisation.

1 Like

Check if your board works with this project https://go.particle.io/shared_apps/5a37b8b8e59b62cef1001011 if it doesn’t, then it’s either a wiring problem or a dead board problem. Remember to connect RST pin to D3 because you have it to A1 and in my project I use it at D3.

The code was taken from the github of one of the guys who posted in the thread of 2014.

1 Like

Thx for ideas and sharing code example: it works by using your code lpared12 (after I activated soft-SPI in sheet “RFID.h” and D2 as in the code defined for RST). I tested well the libary-example DumpInfo with success!
Previously I had soldered the PINs again, so thanks also to ScruffR with his eagle eyes.

Remark: In the following I tested round about 20 customer cards to see what happend. OK no response.
Then I tried my business admission card, which gives me access to premises. I was expecting an identification: at least with the issue of CardID, but there was no output. I am curious how the topic RFID continues to open and conclude this thread as solved! Thanks again and a blessed Christmas time.

1 Like