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

Wi-Fi Controlled Access System with ESP32, RFID, and Keypad

View and Edit Project In Cirkit DesignerImage of Wi-Fi Controlled Access System with ESP32, RFID, and Keypad

Circuit Documentation

Summary

This circuit is designed to interface an ESP32 microcontroller with various input and output devices, including a membrane matrix keypad, pushbuttons, LEDs, an RFID reader, an SD card module, and an OLED display. The circuit is capable of reading RFID tags, logging data to an SD card, displaying information on an OLED screen, and handling user input through a keypad and pushbuttons. The ESP32 also connects to Wi-Fi for data uploading.

Component List

  1. Membrane Matrix Keypad

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

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

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

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

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

    • 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
    • Description: A development board for the ESP32 microcontroller.
  7. SD Module

    • Pins: CS, SCK, MOSI, MISO, VCC, GND
    • Description: An SD card module used for data storage.
  8. Rocker Switch

    • Pins: 1, 2
    • Description: A simple on/off switch.
  9. 0.96" OLED

    • Pins: GND, VDD, SCK, SDA
    • Description: A small OLED display used for visual output.

Wiring Details

Membrane Matrix Keypad

Pushbutton 1

Pushbutton 2

Pushbutton 3

Pushbutton 4

LED: Two Pin (red) 1

LED: Two Pin (red) 2

Resistor 1

Resistor 2

Resistor 3

Resistor 4

Resistor 5

RFID-RC522

SD Module

Rocker Switch

0.96" OLED

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