ESP32-Based Smart Home Monitoring System with GSM and Wi-Fi Connectivity
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor environmental conditions and control various devices based on sensor inputs. It uses an ESP32 microcontroller to read data from sensors, control actuators, and communicate with external devices via WiFi and GSM. The system includes temperature sensors, a light sensor, a current sensor, a door sensor, a servo motor, an LED, a buzzer, an SD card module, and an LCD display.
Component List
ESP32 (30 pin)
- Description: A powerful microcontroller with WiFi and Bluetooth capabilities.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
Sim800l
- Description: A GSM module for sending and receiving SMS.
- Pins: NET, RST, VCC, RXD, TXD, GND
DHT 11
- Description: A temperature and humidity sensor.
- Pins: VCC, GND, DATA
Door MC-38
- Description: A magnetic door sensor.
- Pins: S, GND
Module LDR
- Description: A light-dependent resistor module.
- Pins: VCC, GND, DO, AO
LED: Two Pin (white)
- Description: A white LED.
- Pins: cathode, anode
Micro SD Card Module
- Description: A module for reading and writing to micro SD cards.
- Pins: cs, sck, mosi, miso, vcc, gnd
ACS712 Current Sensor 5A 20A 30A
- Description: A current sensor module.
- Pins: 1, 2, GND, OUT, VCC
Buzzer
- Description: A simple buzzer for sound alerts.
- Pins: PIN, GND
5v battery
- Description: A 5V power source.
- Pins: positive, negative
Micro servo 9G
- Description: A small servo motor.
- Pins: GND, +5V, PWM
3.7v battery
- Description: A 3.7V power source.
- Pins: +, -
16x2 I2C LCD
- Description: A 16x2 character LCD with I2C interface.
- Pins: GND, VCC, SDA, SCL
Wiring Details
ESP32 (30 pin)
- D34: Connected to Module LDR (AO)
- D35: Connected to ACS712 Current Sensor (OUT)
- D32: Connected to DHT 11 (DATA)
- D33: Connected to DHT 11 (DATA) and Buzzer (PIN)
- D25: Connected to Micro servo 9G (PWM)
- D27: Connected to Door MC-38 (S)
- D23: Connected to Micro SD Card Module (mosi)
- D22: Connected to 16x2 I2C LCD (SCL)
- TX0: Connected to Sim800l (TXD)
- RX0: Connected to Sim800l (RXD)
- D21: Connected to 16x2 I2C LCD (SDA)
- D19: Connected to Micro SD Card Module (miso)
- D18: Connected to Micro SD Card Module (sck)
- D5: Connected to Micro SD Card Module (cs)
- D15: Connected to LED (anode)
- GND: Connected to DHT 11 (GND), DHT 11 (GND), Door MC-38 (GND), Module LDR (GND), LED (cathode), Micro SD Card Module (gnd), ACS712 Current Sensor (GND), Buzzer (GND)
- 3V3: Connected to DHT 11 (VCC), DHT 11 (VCC), Module LDR (VCC), Micro SD Card Module (vcc), ACS712 Current Sensor (VCC)
Sim800l
- VCC: Connected to 3.7v battery (+)
- GND: Connected to 3.7v battery (-)
- RXD: Connected to ESP32 (RX0)
- TXD: Connected to ESP32 (TX0)
DHT 11
- VCC: Connected to ESP32 (3V3)
- GND: Connected to ESP32 (GND)
- DATA: Connected to ESP32 (D32)
Door MC-38
- S: Connected to ESP32 (D27)
- GND: Connected to ESP32 (GND)
Module LDR
- VCC: Connected to ESP32 (3V3)
- GND: Connected to ESP32 (GND)
- AO: Connected to ESP32 (D34)
LED: Two Pin (white)
- anode: Connected to ESP32 (D15)
- cathode: Connected to ESP32 (GND)
Micro SD Card Module
- cs: Connected to ESP32 (D5)
- sck: Connected to ESP32 (D18)
- mosi: Connected to ESP32 (D23)
- miso: Connected to ESP32 (D19)
- vcc: Connected to ESP32 (3V3)
- gnd: Connected to ESP32 (GND)
ACS712 Current Sensor 5A 20A 30A
- OUT: Connected to ESP32 (D35)
- VCC: Connected to ESP32 (3V3)
- GND: Connected to ESP32 (GND)
Buzzer
- PIN: Connected to ESP32 (D33)
- GND: Connected to ESP32 (GND)
5v battery
- positive: Connected to 16x2 I2C LCD (VCC), Micro servo 9G (+5V)
- negative: Connected to 16x2 I2C LCD (GND), Micro servo 9G (GND)
Micro servo 9G
- PWM: Connected to ESP32 (D25)
- +5V: Connected to 5v battery (positive)
- GND: Connected to 5v battery (negative)
3.7v battery
- +: Connected to Sim800l (VCC)
- -: Connected to Sim800l (GND)
16x2 I2C LCD
- GND: Connected to 5v battery (negative)
- VCC: Connected to 5v battery (positive)
- SDA: Connected to ESP32 (D21)
- SCL: Connected to ESP32 (D22)
Documented Code
#include <WiFi.h>
#include <WebServer.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <Servo.h>
#include <SD.h>
#include <SoftwareSerial.h>
#define DHTTYPE DHT11
#define DHTInsidePin 32
#define DHTOutsidePin 33
#define LDRPin 34
#define CurrentSensorPin 35
#define DoorSensorPin 27
#define ServoPin 25
#define BuzzerPin 26
#define LEDPin 15
#define SD_CS 23
#define GSM_TX 16
#define GSM_RX 17
// WiFi credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";
// Components initialization
DHT dhtInside(DHTInsidePin, DHTTYPE);
DHT dhtOutside(DHTOutsidePin, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo windowServo;
SoftwareSerial gsm(GSM_TX, GSM_RX);
WebServer server(80);
void setup() {
Serial.begin(115200);
gsm.begin(9600);
// Initialize peripherals
lcd.init();
lcd.backlight();
dhtInside.begin();
dhtOutside.begin();
windowServo.attach(ServoPin);
pinMode(DoorSensorPin, INPUT_PULLUP);
pinMode(LDRPin, INPUT);
pinMode(BuzzerPin, OUTPUT);
pinMode(LEDPin, OUTPUT);
// SD card initialization
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
}
// WiFi connection
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected.