student attendence system — ESP32 simulation

group project fir exhibition

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by saketsuman5356.

Components

Sketch code

#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// =====================================================
//                  PIN CONFIGURATION
// =====================================================

// ---------- GROVE 125KHz RFID ----------
#define RFID_RX 16
#define RFID_TX 17

// ---------- SD CARD ----------
#define SD_CS   14
#define SD_SCK  18
#define SD_MISO 19
#define SD_MOSI 23

// ---------- LCD ----------
#define LCD_SDA 21
#define LCD_SCL 22

// ---------- DHT11 ----------
#define DHT_PIN 26
#define DHT_TYPE DHT11

// ---------- OTHER SENSORS ----------
#define PIR_PIN   27
#define LDR_PIN   34
#define MQ135_PIN 35

// ---------- OUTPUTS ----------
#define BUZZER_PIN 25
#define GREEN_LED  32
#define RED_LED    33

// ---------- ESP32-CAM UART ----------
// Different pins so they do NOT conflict with RFID.
#define CAM_RX 13
#define CAM_TX 15


// =====================================================
//                    OBJECTS
// =====================================================

HardwareSerial RFIDSerial(1);
HardwareSerial CameraSerial(2);

LiquidCrystal_I2C lcd(0x27, 16, 2);

DHT dht(DHT_PIN, DHT_TYPE);


// =====================================================
//                 FUNCTION DECLARATIONS
// =====================================================

String readRFID();

void createAttendanceFile();

void saveAttendance(
  String uid,
  float temperature,
  float humidity,
  int ldr,
  int mq135,
  int pir
);

void readSensors(
  float &temperature,
  float &humidity,
  int &ldr,
  int &mq135,
  int &pir
);

void successSignal();

void errorSignal();

void cameraCapture(String uid);

void showReady();


// =====================================================
//                       SETUP
// =====================================================

void setup() {

  // USB Serial Monitor
  Serial.begin(115200);

  delay(500);

  Serial.println();
  Serial.println("================================");
  Serial.println(" SMART ATTENDANCE SYSTEM");
  Serial.println("================================");


  // ===================================================
  // GROVE RFID
  // ===================================================

  // 9600 baud, 8 data bits, no parity, 1 stop bit
  RFIDSerial.begin(
    9600,
    SERIAL_8N1,
    RFID_RX,
    RFID_TX
  );

  Serial.println("Grove RFID initialized");


  // ===================================================
  // ESP32-CAM SERIAL
  // ===================================================

  CameraSerial.begin(
    115200,
    SERIAL_8N1,
    CAM_RX,
    CAM_TX
  );

  Serial.println("Camera serial initialized");


  // ===================================================
  // OUTPUT PINS
  // ===================================================

  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);

  digitalWrite(BUZZER_PIN, LOW);
  digitalWrite(GREEN_LED, LOW);
  digital

More projects by saketsuman5356