Rohan Barnwal
Published

RFID Based Attendance System Using Arduino Ek Wi-Fi

RFID-Based Attendance System using Arduino Ek R4 Wi-Fi is a smart and automated solution to traditional attendance marking systems.

IntermediateFull instructions provided185
RFID Based Attendance System Using Arduino Ek Wi-Fi

Things used in this project

Hardware components

UNO R4 WiFi
Arduino UNO R4 WiFi
×1
Jumper wires (generic)
Jumper wires (generic)
×1
20x4 LCD
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Wiring Connections

RFID Module To Arduino Board

> SDA To D10
> SCK To D13
> MOSI To D11
> MISO To D12
> RST To D9
> GND To GND
> VCC To 3.3v

20x4 I2C LCD TO Arduino Board

> SDA To A4
> SCL To A5
> VCC To 5v
> GND To GND

Buzzer To Arduino Board

> +ve pin To D7
> -ve pin To GND

Code

Code

Arduino
The code initializes the RFID module, 20x4 I2C LCD, and Buzzer. It then waits for an RFID cards to be scanned. When a known card is detected, it marks the student present, displays their name and class on the LCD, and logs the status to the Serial Monitor. A buzzer beep provides instant feedback, and a command via serial input can show full attendance status.

Key Features:
> Uses MFRC522 and LiquidCrystal_I2C libraries
> Display Name, Class, and Present status on LCD
> Buzzer feedback on every successful scan
> Serial Monitor shows real-time logs
> Responds to the typed command "how many students are present:
> Easy to add/edit students via UID array
> Clean LCD transition: Welcome screen & status updates
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define SS_PIN 10
#define RST_PIN 9
#define BUZZER_PIN 7

MFRC522 rfid(SS_PIN, RST_PIN);
LiquidCrystal_I2C lcd(0x27, 20, 4); // Adjust if needed

// Student structure
struct Student {
  byte uid[4];
  const char* name;
  const char* section;
  bool present;
};

// Student list
Student students[] = {
  {{0xD7, 0x84, 0xD5, 0x00}, "AVC", "10A", false},
  {{0x31, 0x0A, 0xF4, 0x00}, "QWE",   "10A", false},
  {{0xE2, 0xD2, 0xD5, 0x00}, "RTY", "10A", false},
  {{0x7E, 0xB6, 0xF3, 0x00}, "UIO",  "10A", false},
  {{0x82, 0x7E, 0xD6, 0x00}, "PAS",     "10A", false}
};

const int studentCount = sizeof(students) / sizeof(Student);
String inputCommand = "";

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  lcd.init();
  lcd.backlight();
  pinMode(BUZZER_PIN, OUTPUT);

  showWelcome(); // Show startup message

  Serial.println("System ready. Scan RFID card or type 'how many student are present'");
}

void loop() {
  checkRFID();
  checkSerialInput();
}

void checkRFID() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
    return;
  }

  beepBuzzer(); // 🔔 Beep on scan

  for (int i = 0; i < studentCount; i++) {
    if (compareUID(rfid.uid.uidByte, students[i].uid)) {
      if (!students[i].present) {
        students[i].present = true;
        showOnLCD(students[i].name, students[i].section);
        Serial.print("Marked present: ");
        Serial.println(students[i].name);
      } else {
        showOnLCD(students[i].name, students[i].section); // Show info again
        Serial.print("Already marked: ");
        Serial.println(students[i].name);
      }
      delay(3000); // 3 seconds delay for message
      showWelcome(); // Back to welcome screen
      break;
    }
  }

  rfid.PICC_HaltA();
}

bool compareUID(byte* a, byte* b) {
  for (int i = 0; i < 4; i++) {
    if (a[i] != b[i]) return false;
  }
  return true;
}

void showOnLCD(const char* name, const char* section) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Name: ");
  lcd.print(name);
  lcd.setCursor(0, 1);
  lcd.print("Class: ");
  lcd.print(section);
  lcd.setCursor(0, 2);
  lcd.print("Status: Present");
}

void showWelcome() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Student Attendance");
  lcd.setCursor(0, 1);
  lcd.print("System");
}

void checkSerialInput() {
  while (Serial.available()) {
    char c = Serial.read();
    if (c == '\n') {
      inputCommand.trim();
      if (inputCommand.equalsIgnoreCase("how many student are present")) {
        showAttendance();
      }
      inputCommand = "";
    } else {
      inputCommand += c;
    }
  }
}

void showAttendance() {
  Serial.println("---- Attendance Report ----");
  for (int i = 0; i < studentCount; i++) {
    Serial.print(students[i].name);
    Serial.print(" - ");
    Serial.println(students[i].present ? "Present" : "Absent");
  }
  Serial.println("---------------------------");
}

void beepBuzzer() {
  digitalWrite(BUZZER_PIN, HIGH);
  delay(200);
  digitalWrite(BUZZER_PIN, LOW);
}

Credits

Rohan Barnwal
31 projects • 35 followers
Rohan Barnwal - maker, hacker, tech enthusiast. I explore new tech & find innovative solutions. See my projects on hackster.io!

Comments