#include
#include
#include
#include
// WiFi credentials
char ssid[] = "Your_WiFi_Name"; // Replace with your WiFi SSID
char pass[] = "Your_WiFi_Password"; // Replace with your WiFi Password
// RFID setup
#define RST_PIN 22
#define SS_PIN 21
MFRC522 rfid(SS_PIN, RST_PIN);
// Servo setup
#define SERVO_PIN 13
Servo myServo;
// Known UIDs (replace with your actual card UIDs)
byte card1[4] = {0xDE, 0xAD, 0xBE, 0xEF}; // Replace with your card's UID
byte card2[4] = {0xBA, 0xAD, 0xF0, 0x0D}; // Replace with your card's UID
BlynkTimer timer;
// Compare UID with allowed card
bool checkUID(byte *uid, byte *validUID) {
for (byte i = 0; i < 4; i++) {
if (uid[i] != validUID[i]) return false;
}
return true;
}
// Servo movement
void moveServo() {
myServo.wri">
#include
#include
#include
#include
// WiFi credentials
char ssid[] = "Your_WiFi_Name"; // Replace with your WiFi SSID
char pass[] = "Your_WiFi_Password"; // Replace with your WiFi Password
// RFID setup
#define RST_PIN 22
#define SS_PIN 21
MFRC522 rfid(SS_PIN, RST_PIN);
// Servo setup
#define SERVO_PIN 13
Servo myServo;
// Known UIDs (replace with your actual card UIDs)
byte card1[4] = {0xDE, 0xAD, 0xBE, 0xEF}; // Replace with your card's UID
byte card2[4] = {0xBA, 0xAD, 0xF0, 0x0D}; // Replace with your card's UID
BlynkTimer timer;
// Compare UID with allowed card
bool checkUID(byte *uid, byte *validUID) {
for (byte i = 0; i < 4; i++) {
if (uid[i] != validUID[i]) return false;
}
return true;
}
// Servo movement
void moveServo() {
myServo.wri">
#include
#include
#include
#include
// WiFi credentials
char ssid[] = "Your_WiFi_Name"; // Replace with your WiFi SSID
char pass[] = "Your_WiFi_Password"; // Replace with your WiFi Password
// RFID setup
#define RST_PIN 22
#define SS_PIN 21
MFRC522 rfid(SS_PIN, RST_PIN);
// Servo setup
#define SERVO_PIN 13
Servo myServo;
// Known UIDs (replace with your actual card UIDs)
byte card1[4] = {0xDE, 0xAD, 0xBE, 0xEF}; // Replace with your card's UID
byte card2[4] = {0xBA, 0xAD, 0xF0, 0x0D}; // Replace with your card's UID
BlynkTimer timer;
// Compare UID with allowed card
bool checkUID(byte *uid, byte *validUID) {
for (byte i = 0; i < 4; i++) {
if (uid[i] != validUID[i]) return false;
}
return true;
}
// Servo movement
void moveServo() {
myServo.wri">
#define BLYNK_TEMPLATE_ID "Your_Template_ID"
#define BLYNK_TEMPLATE_NAME "Your_Template_Name"
#define BLYNK_AUTH_TOKEN "Your_Blynk_Auth_Token"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <SPI.h>
#include <MFRC522.h>
#include <ESP32Servo.h>
// WiFi credentials
char ssid[] = "Your_WiFi_Name"; // Replace with your WiFi SSID
char pass[] = "Your_WiFi_Password"; // Replace with your WiFi Password
// RFID setup
#define RST_PIN 22
#define SS_PIN 21
MFRC522 rfid(SS_PIN, RST_PIN);
// Servo setup
#define SERVO_PIN 13
Servo myServo;
// Known UIDs (replace with your actual card UIDs)
byte card1[4] = {0xDE, 0xAD, 0xBE, 0xEF}; // Replace with your card's UID
byte card2[4] = {0xBA, 0xAD, 0xF0, 0x0D}; // Replace with your card's UID
BlynkTimer timer;
// Compare UID with allowed card
bool checkUID(byte *uid, byte *validUID) {
for (byte i = 0; i < 4; i++) {
if (uid[i] != validUID[i]) return false;
}
return true;
}
// Servo movement
void moveServo() {
myServo.write(90);
delay(1500);
myServo.write(0);
}
// Blynk button (V0)
BLYNK_WRITE(V0) {
int state = param.asInt();
if (state == 1) {
moveServo();
}
}
// Check RFID
void checkRFID() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;
Serial.print("UID tag: ");
for (byte i = 0; i < rfid.uid.size; i++) {
Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
if (checkUID(rfid.uid.uidByte, card1) || checkUID(rfid.uid.uidByte, card2)) {
Serial.println("Access granted");
moveServo();
Blynk.logEvent("rfid_detected", "RFID Access Detected");
} else {
Serial.println("Access denied");
}
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
myServo.attach(SERVO_PIN);
myServo.write(0);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(500L, checkRFID);
Serial.println("Ready - scan RFID card or press Blynk button");
}
void loop() {
Blynk.run();
timer.run();
}