# Getting the RFID-RC522 to work! \[SOLVED\]

**URL:** <https://community.particle.io/t/getting-the-rfid-rc522-to-work-solved/3571>\
**Category:** Libraries\
**Created:** [March 22, 2014, 6:56pm UTC](https://community.particle.io/t/getting-the-rfid-rc522-to-work-solved/3571 "2014-03-22T18:56:55Z")\
**Posts on this page:** 1\
**Showing post:** 248

<div class="post-metadata">

**Author:** ![patrickcentral](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/patrickcentral/32/3723_2.png) [@patrickcentral](https://community.particle.io/u/patrickcentral)\
**Post date:** [January 31, 2017, 4:46am UTC](https://community.particle.io/t/getting-the-rfid-rc522-to-work-solved/3571/248 "2017-01-31T04:46:22Z")

</div>

Not bumping this thread due to a problem on my end, just wanted to say that thanks to this thread and @peekay123’s library, I was able to get this ebay kit up and running on a Photon in about 4 minutes!

Any future Googlers looking for a quick start, here’s a summary of this thread:

**Wiring:**

```
-Function- Photon Pin MRFC522 Pin
 Reset ANY (D2) RST
 SPI SS ANY (A2) SDA
 SPI MOSI A5 MOSI
 SPI MISO A4 MISO
 SPI SCK A3 SCK

```

**Code:**  
This will publish an event to the Particle cloud with the ID of whatever device you scan - kind of a RFID hello world, as it doesn’t really do much beyond let you catalog the cards and fobs you have, and ensure you’ve wired it up right. Make sure you add the MFRC522 library through the IDE, I’m not sure how it works if you just paste this with the include statement.

```
// 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;
    }
    
    String cardID = "";
    
    for (byte i = 0; i < mfrc522.uid.size; i++) {
        cardID += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "");
        cardID += String(mfrc522.uid.uidByte[i], HEX);
    }
    Particle.publish("rfid_scan", cardID, 60, PRIVATE);
    mfrc522.PICC_HaltA();
}

```

Now for some RFID fun! Thanks everyone!

---

_[View the full topic](https://community.particle.io/t/getting-the-rfid-rc522-to-work-solved/3571)._
