ESP32-Based Smart Home Security System with GSM and Wi-Fi Connectivity
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a smart home security system circuit. The system is built around an ESP32 microcontroller and includes various sensors and modules to monitor environmental conditions and detect security breaches. The system is capable of sending alerts via SMS and displaying information on an OLED screen. The components used in this circuit include a DS3231 RTC module, vibration sensors, a GSM module, a push switch, a PIR motion sensor, a DHT22 temperature and humidity sensor, gas sensors, flame sensors, an OLED display, an IR sensor, and a relay.
Component List
ESP32 38 PINS
- Description: Main microcontroller
- Pins: GND, 23, 22/SCL, 1, 2, 21/SDA, 19, 18, 5, 17/TX2, 16/RX2, 4, 0, 15, D1, D0, CLK, 3V3, EN, VP, VN, 34, 35, 32, 33, 25, 26, 27, 14, 12, 13, D2, D3, 11, 5V/VIN
DS3231 RTC
- Description: Real-time clock module
- Pins: 32K, SQW, SCL, SDA, VCC, GND
SW-420 Vibration Sensor
- Description: Vibration sensor
- Pins: vcc, Ground, Digital output
SIM800L GSM Module
- Description: GSM module for SMS communication
- Pins: 5V, GND, VDD, SIM_TXD, SIM_RXD, RST
2Pin Push Switch
- Description: Push button switch
- Pins: Input +, Output +
PIR Motion Sensor (Wokwi Compatible)
- Description: Motion sensor
- Pins: VCC, OUT, GND
DHT22
- Description: Temperature and humidity sensor
- Pins: GND, VCC, DAT
MQ-2
- Description: Gas sensor
- Pins: GND, VCC, ANALOG, Digital
MQ-7 Breakout
- Description: Carbon monoxide sensor
- Pins: VCC, GND, DO, AO
KY-026 Flame Sensor
- Description: Flame sensor
- Pins: A0, GND, VCC, D0
OLED 1.3"
- Description: OLED display
- Pins: GND, VCC, SCL, SDA
IR Sensor
- Description: Infrared sensor
- Pins: VCC, GND, D0
5v relay
- Description: Relay module
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
Wiring Details
ESP32 38 PINS
- GND: Connected to GND of DS3231 RTC, SIM800L GSM Module, 2Pin Push Switch, PIR Motion Sensor, IR Sensor, OLED 1.3", MQ-2, DHT22, SW-420 Vibration Sensor, KY-026 Flame Sensor, 5v relay
- 22/SCL: Connected to SCL of DS3231 RTC
- 21/SDA: Connected to SDA of DS3231 RTC
- 19: Connected to SCL of OLED 1.3"
- 18: Connected to Output + of 2Pin Push Switch
- 17/TX2: Connected to SIM_RXD of SIM800L GSM Module
- 16/RX2: Connected to SIM_TXD of SIM800L GSM Module
- 4: Connected to SDA of OLED 1.3"
- 15: Connected to DAT of DHT22
- 3V3: Connected to VCC of DS3231 RTC
- 34: Connected to OUT of PIR Motion Sensor
- 35: Connected to AO of MQ-7 Breakout
- 32: Connected to D0 of KY-026 Flame Sensor
- 33: Connected to D0 of KY-026 Flame Sensor
- 25: Connected to D0 of KY-026 Flame Sensor
- 26: Connected to D0 of KY-026 Flame Sensor
- 14: Connected to In of 5v relay
- 12: Connected to ANALOG of MQ-2
- 13: Connected to D0 of IR Sensor
- D2: Connected to Digital output of SW-420 Vibration Sensor
- D3: Connected to Digital output of SW-420 Vibration Sensor
- 5V/VIN: Connected to VCC of SIM800L GSM Module, PIR Motion Sensor, IR Sensor, OLED 1.3", MQ-2, DHT22, SW-420 Vibration Sensor, KY-026 Flame Sensor, 5v relay
DS3231 RTC
- GND: Connected to GND of ESP32 38 PINS
- SCL: Connected to 22/SCL of ESP32 38 PINS
- SDA: Connected to 21/SDA of ESP32 38 PINS
- VCC: Connected to 3V3 of ESP32 38 PINS
SW-420 Vibration Sensor
- Ground: Connected to GND of ESP32 38 PINS
- Digital output: Connected to D2 and D3 of ESP32 38 PINS
- vcc: Connected to 5V/VIN of ESP32 38 PINS
SIM800L GSM Module
- GND: Connected to GND of ESP32 38 PINS
- SIM_RXD: Connected to 17/TX2 of ESP32 38 PINS
- SIM_TXD: Connected to 16/RX2 of ESP32 38 PINS
- 5V: Connected to 5V/VIN of ESP32 38 PINS
2Pin Push Switch
- Input +: Connected to GND of ESP32 38 PINS
- Output +: Connected to 18 of ESP32 38 PINS
PIR Motion Sensor (Wokwi Compatible)
- GND: Connected to GND of ESP32 38 PINS
- OUT: Connected to 34 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
DHT22
- GND: Connected to GND of ESP32 38 PINS
- DAT: Connected to 15 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
MQ-2
- GND: Connected to GND of ESP32 38 PINS
- ANALOG: Connected to 12 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
MQ-7 Breakout
- GND: Connected to GND of ESP32 38 PINS
- AO: Connected to 35 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
KY-026 Flame Sensor
- GND: Connected to GND of ESP32 38 PINS
- D0: Connected to 32, 33, 25, 26 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
OLED 1.3"
- GND: Connected to GND of ESP32 38 PINS
- SCL: Connected to 19 of ESP32 38 PINS
- SDA: Connected to 4 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
IR Sensor
- GND: Connected to GND of ESP32 38 PINS
- D0: Connected to 13 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
5v relay
- GND: Connected to GND of ESP32 38 PINS
- In: Connected to 14 of ESP32 38 PINS
- VCC: Connected to 5V/VIN of ESP32 38 PINS
Documented Code
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <Wire.h>
#include <RTClib.h> // Commented out RTC library
#include <esp_camera.h>
// GSM Module Pins (using hardware Serial1)
#define RX_PIN 16
#define TX_PIN 17
// GSM Phone Number to Send SMS
#define PHONE_NUMBER "+639