Final Report Prakash (EC23I2013)
Final Report Prakash (EC23I2013)
System
rakash-ec23i2013
P
DL.Raghu-ec23b1130
P.Pramod kumar-ec23i1013
ABSTRACT:-
he Smart Home Automation System integrates six core modules powered by Arduino
T
or ESP32 microcontrollers, enhancing home safety and convenience. These include car
parking assistance using ultrasonic sensors, a burglar alarm with PIR and microwave
sensors, and a keypad-RFID based door lock controlled by a servo motor. Each module
uses relevant sensors and actuators to automate specific household tasks efficiently
and securely.
dditional features include a fire and gas alert system using KY-026 and MQ-2 sensors,
A
which triggers alarms and sends email notifications. The smart dustbin module
promotes hygiene with an auto-opening lid using a servo motor and ultrasonic sensors.
Lastly, a real-time time and temperature display module employs the DHT22 and RTC
to provide accurate environmental data. Together, these modules create a responsive
and automated home environment.
Introduction:-
he rapid advancement of embedded systems, sensors, and IoT technology has made
T
smart home automation both practical and accessible. These systems integrate various
components—such as microcontrollers, sensors, and wireless communication
modules—to intelligently manage and automate household operations. Their goal is to
improve daily life by offering enhanced safety, convenience, and energy efficiency.
odern households face challenges like break-ins, fire and gas hazards, inefficient
M
waste handling, and temperature regulation. Traditional methods often lack real-time
responsiveness and require manual input, highlighting the need for a smarter, more
reliable, and cost-effective home automation solution.
Literature Survey:-
ome automation has progressed remarkably over the past two decades, thanks to
H
advances in microcontrollers, sensors, wireless communication, and IoT. Numerous
studies and projects have explored solutions targeting various aspects of smart homes,
including safety, energy efficiency, and comfort. This review highlights key findings from
prior work relevant to the current project.
rduino-based systems are popular in early smart home prototypes due to their
A
affordability and ease of use. For instance, in 2017, a simple setup using Arduino UNO
and Bluetooth allowed remote appliance control, though it lacked advanced sensor
integration and internet connectivity. ESP32 offers a significant upgrade by enabling IoT
functionalities.
Intrusion detection commonly relies on PIR sensors, which detect motion based on
infrared radiation. However, they have limitations in coverage and sensitivity. Microwave
sensors like the RCWL-0516 provide 360° detection and better performance through
obstacles. Combining both sensors improves accuracy and reliability.
igital door locks often use RFID tags and keypads for access control. Studies have
D
shown that integrating these with servo motors and LCDs creates secure and
user-friendly entry systems. Multi-factor authentication strengthens overall security.
as and fire safety systems typically use MQ-2 and KY-026 sensors. These can detect
G
various gases and flames, triggering alarms and sometimes sending notifications via
email or SMS. This ensures both local and remote alerts for better safety.
mart dustbins became popular during the COVID-19 era for promoting contactless
S
hygiene. Projects using ultrasonic sensors and servo motors automatically open lids
when a hand is near, preventing contamination and enhancing usability in homes and
public places.
nvironmental monitoring is vital for comfort and safety. The DHT22 sensor measures
E
temperature and humidity accurately, while the DS3231 RTC module tracks real-time
data. Displaying this information on LCDs or dashboards helps users make informed
decisions, such as adjusting ventilation.
Methodology:-
he Smart Home Automation System is designed based on a modular and integrated
T
design methodology, in which every subsystem tackles a unique function of smart home
automation—security, safety, convenience, and environment monitoring. The approach
is to divide the project into six functional blocks, which are developed individually with
suitable sensors, actuators, and microcontrollers, and then assembled into a single
framework.
Flowchart:-
Algorithms:-
. Initialize the ultrasonic sensor, buzzer, and LED pins.
1
2. Send a 10µs HIGH pulse to the Trigger pin of the ultrasonic sensor.
. W
3 ait for the Echo pin to go HIGH and measure the duration of the received pulse.
4. Calculate distance using the formula:
Distance (cm) = (Echo time in µs × Speed of sound) / 2
(Note: Speed of sound ≈ 0.034 cm/µs)
5. If the calculated distance is less than 15 cm:
○ Turn ON the buzzer and/or LED.
6. Else:
○ Keep the buzzer and LED OFF.
7. Repeat the above steps continuously in a loop.
Flowchart:-
Algorithms:-
. Initialize LCD, keypad, RFID, and servo motor.
1
2. Prompt users to enter a password or scan card.
3. If password matches or RFID is valid:
○ Rotate servo to open.
○ Show “Access Granted”.
4. Else:
○ Show “Access Denied”.
5. After a delay, lock the door again.
Algorithm:-
.
1 Initialize GPIO pins for input (PIR, RCWL sensors) and output (buzzer, LED).
2. Start a continuous monitoring loop.
3. Read digital signals from both PIR and RCWL motion sensors.
4. If either sensor detects motion (i.e., output is HIGH):
a. Turn ON the buzzer and LED to alert.
b. Wait for a short delay (e.g., 1–2 seconds).
. Turn OFF the buzzer and LED.
5
6. Repeat the process (go back to step 3).
Flowchart:-
Algorithms:-
1. Initialize all components: MQ-2 gas sensor, KY-026 flame sensor, LCD display, buzzer,
and ESP32 (for email functionality).
2. Continuously monitor the analog output from the MQ-2 sensor.
3. Continuously check the digital output from the KY-026 sensor.
4. Ifgas concentration exceeds thresholdORflame is detected:
a. Activate the buzzer to alert nearby individuals.
b. Display a danger warning on the LCD (e.g., “Gas/Flame Detected!”).
c.IfESP32 is configured: send an alert email using the SMTP client.
5. Else:
a. Display “Status: Safe” on the LCD.
b. Keep the buzzer turned off.
6. Repeat the process continuously.
Flowchart:-
Algorithms:-
Flowchart:-
Algorithms:-
Hardware Components:-
● Microcontrollers:-
Arduino UNO, ESP32
● Actuators:-
Buzzers, Servo Motors, LEDs
● Sensors:-
Ultrasonic, PIR, RCWL-0516, KY-026, MQ-2, DHT22
● Modules:-
DS3231 RTC, 16x2 LCD, 4x4 Keypad, RFID
ESP32:-
● rovides precise short-range distance measurement.
P
● Easy integration with microcontrollers.
● Non-contact operation, ideal for hygienic applications like dustbins.
● Low cost and readily available.
PIR Sensor:-
● rovides precise short-range distance measurement.
P
● Easy microcontroller interfacing.
● Non-contact operation, ideal for hygiene.
● Low cost and readily available
P
● rovides accurate angle rotation (0°–180°).
● Requires low torque for small doors/lids.
● Compact and power-efficient design.
Buzzers:-
Issues audible warnings in case of emergency
●
● Low power consumption
● Small and inexpensive
LED:-
V
● isual feedback
● Simple to use and debug systems
● Inexpensive and reliable
SCL A5
ECHO 6
ECHO 10
SCK 18
MOSI 23
MISO 19
RST 22
R2 14
R3 26
R4 27
C1 32
C2 33
C3 25
C4 15
SCL 2
// Thresholds
#define FLAME_THRESHOLD 500
#define GAS_THRESHOLD 300
#define DUSTBIN_DISTANCE 15
#define PARKING_DISTANCE 15
// Objects
LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 rtc;
Servo dustbinServo;
// Variables
bool alarmActive = false;
unsigned long lastUpdateTime = 0;
const unsigned long updateInterval = 1000;
void setup() {
Serial.begin(9600);
void setupSmartDustbin() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
dustbinServo.attach(SERVO_PIN);
dustbinServo.write(0);
}
void setupTimeTempDisplay() {
Wire.begin();
lcd.init();
lcd.backlight();
dht.begin();
}
void setupSmartParking() {
pinMode(PARKING_TRIG_PIN, OUTPUT);
pinMode(PARKING_ECHO_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
}
void smartDustbin() {
long duration = triggerUltrasonic(TRIG_PIN, ECHO_PIN);
int distance = duration * 0.034 / 2;
Serial.print("Dustbin Distance: ");
Serial.println(distance);
void timeTempDisplay() {
unsigned long currentMillis = millis();
if (currentMillis - lastUpdateTime >= updateInterval) {
lastUpdateTime = currentMillis;
lcd.clear();
lcd.setCursor(0, 1);
if (isnan(temp) || isnan(humidity)) {
lcd.print("DHT Error");
} else {
lcd.print(temp, 1);
lcd.print("C ");
lcd.print(humidity, 0);
lcd.print("%");
}
}
}
void smartParkingAlert() {
long duration = triggerUltrasonic(PARKING_TRIG_PIN, PARKING_ECHO_PIN);
int distance = duration * 0.034 / 2;
Serial.print("Parking Distance: ");
Serial.println(distance);
// Servo
#define SERVO_PIN 7
/*
Revised Wiring (PIR_1 removed):
1. RFID Reader (MFRC522)
SDA -> Pin 21
SCK -> Pin 18
MOSI -> Pin 23
MISO -> Pin 19
RST -> Pin 22
VCC -> 3.3V
GND -> GND
7. Buzzer
Positive -> Pin 16
Negative -> GND
8. LED
Anode -> Pin 4 (with resistor) // NOT NEEDED
Cathode -> GND
void connectWiFi() {
Serial.print("Connecting to WiFi...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 20) {
Serial.print(".");
delay(500);
attempts++;
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("\nWiFi connected. IP: " + WiFi.localIP().toString());
} else {
erial.println("\nFailed to connect to WiFi.");
S
}
}
void initializeHardware() {
myServo.attach(servoPin);
// Initialize custom I2C bus for LCD
//I2C LCD.begin(LCD_SDA_PIN, LCD_SCL_PIN);
Wire.begin(LCD_SDA_PIN, LCD_SCL_PIN);
lcd.begin(16,2);
lcd.backlight();
pinMode(pirPin, INPUT); // Only one PIR now
//pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(pushButtonPin, INPUT_PULLUP);
pinMode(alertLedPin, OUTPUT);
PI.begin();
S
mfrc522.PCD_Init();
delay(4); // Short delay for RFID init
}
void unlockDoor() {
locked = false;
myServo.write(90);
updateLockStatus();
}
void lockDoor() {
locked = true;
myServo.write(0);
updateLockStatus();
}
bedtls_md_init(&ctx);
m
mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(md_type), 0);
mbedtls_md_starts(&ctx);
mbedtls_md_update(&ctx, (const unsigned char*)input.c_str(), input.length());
mbedtls_md_finish(&ctx, hash);
mbedtls_md_free(&ctx);
MTP_Message message;
S
message.sender.name = "ESP32";
message.sender.email = sender_email;
message.subject = "ESP32 Security Alert";
message.addRecipient(Recipient_name, Recipient_email);
igitalWrite(alertLedPin, pushButtonState);
d
if (pushButtonState && digitalRead(pirPin) == HIGH) {
digitalWrite(buzzerPin, HIGH);
sendMessage();
} else {
digitalWrite(buzzerPin, LOW);
}
}
void setup() {
Serial.begin(115200);
connectWiFi();
initializeHardware();
updateLockStatus();
}
void loop() {
handleRFID();
char key = keypad.getKey();
if (key) handleKeypadInput(key);
handlePushButton();
}
Result:-
he Smart Home Automation System performed seamlessly, with all modules operating
T
as intended. Features such as distance sensing, motion detection, door locking, fire and
gas alerts, automatic dustbin operation, and real-time time-temperature display were
fully functional. The system proved to be efficient, dependable, and well-suited for smart
home applications.
Conclusion:-
References:-