// This #include statement was automatically added by the Particle IDE.
#include <MFRC522.h>
#define SS_PIN A5
#define RST_PIN D2
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
long lastPublishedAt = 0;
int publishAfter = 10000;
void setup() {
// Initialize serial communications with the computer
Serial.begin(9600);
mfrc522.setSPIConfig(); // sets up SPI config
mfrc522.PCD_Init(); // Initialize RC522 card
Serial.println("Start Scanning");
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
Serial.println("New card Detected");
// Read tapped card data
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
//Dump all card data to Serial
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
publishevent();
}
void publishevent()
{
if( lastPublishedAt + publishAfter < millis() )
{
Particle.publish( "maverick/2019/rfidok/" );
lastPublishedAt = millis();
}
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .