Getting the RFID-RC522 to work! [SOLVED]


Awesome! Thank you so much!


Any idea how long it will take before the webIDE will work? I just tried it and I still get the SOS lights.


!!! I’ll have to test again! Make sure you pull the latest version in your app.


i just got my RFID today and tested it with your new version and it definitly works on my photon (0.45). … Good Timing i guess and Thank you for porting it!


In case someone else could use a quick and easy code to just get the Card’s ID as a string (i saw someone asking anywhere in this Thread) - this works fine for me:

void loop() {

// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {

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("pushover", cardID + " scanned", 60, PRIVATE);




How does one ‘pull’ the latest version in to an app?


@anlek, if you are using the web IDE, remove the library and then re-add it again. Also make sure you are compiling for latest 0.4.5. :smile:


Understood, Thanks!


So I created a new project (I also removed and re-added the MFRC522 library and still getting SOS lights (on the latest 0.4.5 firmware).

#include "MFRC522/MFRC522.h"
#define SS_PIN      SS
#define RST_PIN     A1

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

Any other ideas? I’m quite lost…

Need help learning C/C++: strings, arrays, type conversion, etc

On the webIDE it still states: MFRC522 0.1.1 and not 0.1.2


I think I got it refreshed… sorry for the messages.


Hi, I am working on a time-keeping project using an arduino uno, a lcd display and… a rfid reader RC522.
But I have a problem because the rfid reader uses the same pins as lcd’s . So I was wondering if I could connect RC522 using just the SOUT pin, or maybe there is another possibility to connect these two devices together.


Hi guys, @peekay123, @korneel
I am newbie to spark, i have found the library in the particle IDE and Pin are configure as per the in app comment.
Could you please point me out how to see output data from the card which i place on the MFRC522 chip.
also, Please point me some easy way to send this data to my server url as json data (something like webhook) for the card which i place on the MFRC522.

Thanks in advance :slight_smile:


If you plug your Particle device into your computer via USB and open a serial monitor application (e.g. PuTTY) you can attach to the respective COM port an see the Serial output.

And if you have a line like this in your code

Particle.publish("pushover", cardID + " scanned", 60, PRIVATE);

You can go to and see the output there.

If you want to use a webhook to relay this event to your server you’d best look at the webhooks docs first


Thanks for reply. i will look this webhook docs :slight_smile:


BTW: If you were a bit quick with posting a reply, you don’t need to delete the post and create a new one.
You can just hit the pencil icon in the bottom line of the post to edit your own posts.


@peekay123 I’ve been reading through this thread, and have downloaded your code from GitHub (RC522_RFID). But I’m getting errors when I compile.

Admittedly, this is my first time using libraries and SPI…I’m new to Particle, but have experience with Arduino (you helped me on my first post in fact, Arduino vs. Particle…thank you!).

Here are the errors:

RFID.cpp: In member function ‘void RFID::halt()’:
RFID.cpp:512:13: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
uint8_t status;
RFID.cpp: In member function ‘uint8_t RFID::softSPITranser(uint8_t)’:
RFID.cpp:532:38: error: ‘struct GPIO_TypeDef’ has no member named 'BSRR’
PIN_MAP[_mosiPin].gpio_peripheral->BSRR = PIN_MAP[_mosiPin].gpio_pin; // Data High

RFID.cpp:534:38: error: ‘struct GPIO_TypeDef’ has no member named 'BRR’
PIN_MAP[_mosiPin].gpio_peripheral->BRR = PIN_MAP[_mosiPin].gpio_pin; // Data Low

Any thoughts? I’m thinking maybe I’m not doing something right in the…my App shows the three files:

Am I missing something?

Thanks so much, in advance!


You can replace these calls with the respective commands pinSetFast() / pinResetFast() and pinReadFast() to get rid of the error messages.

    for (uint8_t bit = 0; bit < 8; bit++)  {
      if (data & (1 << (7-bit)))		// walks down mask from bit 7 to bit 0
        pinSetFast(_mosiPin); // Data High
        pinResetFast(_mosiPin); // Data Low
      pinSetFast(_clockPin); // Clock High

      b <<= 1;
      if (pinReadFast(_misoPin))
        b |= 1;

      pinResetFast(_clockPin); // Clock Low


Wow, thanks @ScruffR! That did it! What a quick response, and what an earlybird! :wink:

Really appreciate it!



That’s the advantage of a global community - it’s 2:10pm for me already :wink: