Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Smart Access Control System with RFID, Keypad, and OLED Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Access Control System with RFID, Keypad, and OLED Display

Circuit Documentation

Summary

This document provides a detailed overview of a circuit design that includes various components such as a membrane matrix keypad, pushbuttons, LEDs, resistors, an RFID module, an ESP32 microcontroller, an SD module, and an OLED display. The circuit is designed to interface with these components to perform various tasks, including reading RFID tags, displaying information on an OLED screen, and logging data to an SD card. The ESP32 microcontroller is programmed to handle these tasks and communicate with the components.

Component List

  1. Membrane Matrix Keypad

    • Description: A 4x3 matrix keypad used for user input.
    • Pins: Row 1, Row 2, Row 3, Row 4, Column 1, Column 2, Column 3
  2. Pushbutton

    • Description: A simple pushbutton used for user input.
    • Pins: Pin 1, Pin 2, Pin 3, Pin 4
  3. LED: Two Pin (red)

    • Description: A red LED used for visual indication.
    • Pins: Anode, Cathode
  4. Resistor

    • Description: A resistor with a resistance of 200 Ohms.
    • Pins: Pin 1, Pin 2
  5. RFID-RC522

    • Description: An RFID module used for reading RFID tags.
    • Pins: SDA, SCK, MOSI, MISO, IRQ, GND, RST, 3.3V
  6. ESP32 Devkit V1

    • Description: A development board based on the ESP32 microcontroller.
    • Pins: 3V3, GND, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, VIN
  7. SD Module

    • Description: An SD card module used for data storage.
    • Pins: CS, SCK, MOSI, MISO, VCC, GND
  8. OLED Display 2.42"

    • Description: A 2.42-inch OLED display used for visual output.
    • Pins: GND, VCC, SCK, SDA, RES, DC, CS

Wiring Details

Membrane Matrix Keypad

Pushbutton 1

Pushbutton 2

Pushbutton 3

LED: Two Pin (red)

Resistor 1

Resistor 2

Resistor 3

RFID-RC522

ESP32 Devkit V1

SD Module

OLED Display 2.42"

Documented Code

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <HTTPClient.h>
#include "FS.h"
#include "SD.h"
#include <SPI.h>
#include <MFRC522.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include <time.h>
#include <sntp.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <ArduinoJson.h>  // Include the ArduinoJson library
#include <Keypad.h>

// Length of password + 1 for null character
#define Password_Length 8

// Character to hold password input
char Data[Password_Length];
// Password

// Counter for character entries
byte data_count = 0;

// Character to hold key input
char customKey;

// Constants for row and column sizes
const byte ROWS = 4;
const byte COLS = 3;

// Array to represent keys on keypad
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

// Connections to Arduino
byte rowPins[ROWS] = {33, 25, 26, 27}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {14, 12, 13}; //connect to the column pinouts of the keypad

// Create keypad object
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

#define SS_PIN  5    // SDA pin esp32=5
#define RST_PIN 2   // RST pin  esp32=22
#define SD_CS 4      // CS pin for SD card
#define Wifi_LED 32

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for SSD1306 display connected using I2C
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int buttonPin = 15;           // GPIO pin for the push button
int counter = 0;                    // Counter variable
int lastButtonState = HIGH;         // Last button state (HIGH because of pull-up)
int buttonState;                    // Current button state
unsigned long lastDebounceTime = 0; // Last time the button state changed
unsigned long debounceDelay = 5;   // Debounce time in milliseconds
bool incremented = false;           // Flag to check if counter has already incremented

// Define pin for the button
const int buttonPin2 = 34;
String URL = "http://103.148.212.44/backend/api/task-log"; 
// Variables to hold the current and last button state
bool currentButtonState2 = HIGH; // Assuming HIGH means not pressed
bool lastButtonState2 = HIGH;
bool working_status = true; // Initial working status
bool updated_working_status = false;
bool updated_counter = false;
bool data_upload = true;

// Define pins for the buttons
const int buttonPin3 = 35; // Maintenance
bool currentButtonState3 = HIGH; // Assuming HIGH means not pressed
bool lastButtonState3 = HIGH;

unsigned long lastDebounceTime3 = 0;
unsigned long debounceDelay3 =