💳 RFID Attendance System
Scan RFID tags, track timestamps with an RTC, and log data to an SD card.
Overview
This project integrates three separate SPI and I2C modules into a cohesive system. It reads an RFID card's unique ID, fetches the current date/time, and logs it to a text file on a MicroSD card.
What you'll learn: SPI communication with RC522 and SD modules, I2C with DS3231 RTC, file handling (read/write), and string manipulation.
Estimated time: 2-3 hours. Difficulty: ⭐⭐⭐ Intermediate.
Components Needed
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Mega 2560 | 5V Logic | 1 | Lots of pins and memory |
| RC522 RFID Module | SPI Interface, 3.3V | 1 | Includes cards/fobs |
| DS3231 RTC Module | I2C Interface | 1 | Keeps time when powered off |
| MicroSD Card Module | SPI Interface | 1 | Formats as FAT32 |
| Breadboard & Wires | 1 | Many wires required |
Step-by-Step Tutorial
1
Format SD Card
Ensure your MicroSD card is formatted to FAT32 before inserting it into the module.
2
Wire the SPI Bus (Mega)
The Mega uses pins 50 (MISO), 51 (MOSI), and 52 (SCK) for SPI. Both the SD module and RC522 share these pins.
3
Wire Chip Selects (CS)
Assign unique CS pins. E.g., SD Card CS → Pin 53, RC522 SDA(SS) → Pin 49.
4
Wire the RTC
Connect DS3231 SDA → Pin 20, SCL → Pin 21 on the Mega.
5
Code Integration
Upload the combined sketch. When a card is scanned, it will print to Serial and write a log entry to
log.txt on the SD card.SPI devices share MISO, MOSI, and SCK, but MUST have distinct CS (Chip Select) pins. Ensure you only pull one CS pin LOW at a time in code.
Code / Configuration
rfid_attendance.ino
INO
// RFID Attendance System - Volt X
#include <SPI.h>
#include <MFRC522.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#define SS_PIN 49
#define RST_PIN 48
#define SD_CS_PIN 53
MFRC522 rfid(SS_PIN, RST_PIN);
RTC_DS3231 rtc;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
}
if (!SD.begin(SD_CS_PIN)) {
Serial.println("SD Card failed");Reviews & Ratings
—0 reviews
Sign in to leave a review
Loading reviews...