/*
Project: RFID Access with ESP8266 / ESP32 und Arduinos
Author: Thomas Edlinger for www.edistechlab.com
Date: Created 21.05.2020
Version: V1.0
Angepasst: JTM
Datum: 10.6.2024
-RC522 -ESP32 S3
VCC 3.3V
RST GPIO 6
GND GND
MISO GPIO 13
MOSI GPIO 11
SCK GPIO 12
SDA (SS/NSS) GPIO 10
IRQ
-
*/
//Diese Pins müssen angepasst werden (GPIO Pin von der Liste oben)
#define RST_PIN 6
#define SS_PIN 10
#include <SPI.h>
#include <MFRC522.h>
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(115200);
SPI.begin();
mfrc522.PCD_Init();
}
void accessGranted() {
Serial.println(" Access Granted ");
Serial.println();
delay(3000);
}
void accessRefused() {
Serial.println(" Access Refused ");
delay(3000);
}
void loop() {
//Serial.println(" test");
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
//Zeigt die UID im serial monitor
Serial.println();
Serial.print(" UID tag :");
String content= "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
content.toUpperCase();
Serial.println();
Serial.print(" PICC type: ");
MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
Serial.println(mfrc522.PICC_GetTypeName(piccType));
if (content.substring(1) == "1F F8 5D 48" || content.substring(1) == "B2 38 DB 0E") {
accessGranted();
}
else {
accessRefused();
}
delay(500);
}