Getting the RFID-RC522 to work! [SOLVED]


#206

Awesome! Thank you so much!


#207

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


#208

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


#209

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!


#210

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()) {
	return;
	
}

// Select one of the cards
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);
    
}

Serial.println(cardID);

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

mfrc522.PICC_HaltA();

}


#211

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


#212

@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:


#213

Understood, Thanks!


#214

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
#215

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


#216

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


#217

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.


#218

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:


#219

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 https://dashboard.particle.io/user/logs 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
https://docs.particle.io/guide/tools-and-features/webhooks


#221

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


#222

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.


#223

@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 build.particle.io…my App shows the three files:
RC522-RFID.INO
RFID.CPP
RFID.H

Am I missing something?

Thanks so much, in advance!
J-


#224

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
      else
        pinResetFast(_mosiPin); // Data Low
		
      pinSetFast(_clockPin); // Clock High

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

      pinResetFast(_clockPin); // Clock Low
    }

#225

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

Really appreciate it!

Best-
Jeremy


#226

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