Smart Home

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Course Code: CSE 368

Course Title: Microprocessor and Interfacing Lab

Lab Report On

Smart Home
Submitted By:
Group 6

MD MEHEDI HASAN
Registration No: 2020331075

Md Ahsanul Haque Sazid


Registration No: 2020331027

Members:
Avijit Debnath
Registration No: 2020331025

Khaled Bin
Registration No: 2020331055

Ajor Saha
Registration No: 2020331066

Submitted To:
Abdullah Al Noman
Lecturer
Department of Computer Science & Engineering, SUST
Introduction:

Imagine a smart home equipped with cutting-edge features that enhance


convenience, efficiency, and security. This home includes a smart parking system
that autonomously guides vehicles into the garage. Inside, lighting control is
managed via Wi-Fi and smartphone applications, allowing residents to adjust
brightness and colour to fit their preferences and schedules. Security is fortified
with an advanced theft and gas detection system, employing sensors to monitor
and alert homeowners of any unauthorised access and safety. Moreover, the home
features automatic lighting that activates only in low-light conditions, ensuring
optimal illumination while conserving energy. This thesis explores the integration
of these smart technologies, demonstrating their potential to revolutionise modern
living by providing a seamless, efficient, and secure home environment.

Objective:

The objective of this thesis is to integrate smart parking, advanced lighting control
via Wi-Fi and smartphones, and a robust theft detection system into a seamless,
efficient, and secure smart home environment, aiming to optimize convenience
and energy efficiency while enhancing home security.
Home(front side):

Home(back side):
Hardware Components:

Description of all the equipments used has been provided as follows:

1. Arduino UNO: A microcontroller board based on the ATmega328P with


14 digital input/output pins, 6 analog inputs, a 16 MHz ceramic resonator,
a USB connection, a power jack, an ICSP header, and a reset button.

Figure: Arduino Uno

Function: Arduino UNO works as the brain of the robot; controlling the
motor and sensors as per the programmed instructions.

2. Jumper Cables: For necessary connections in the robot.

Figure: Jumper wires

3. Sonar Sensor: HC SR-04 Ultrasonic Distance Sensor. Uses acoustic


pulses and their echoes to measure the range to an object.
Figure: HC SR-04 Ultrasonic Distance Sensor

Function: Detects obstacles in the robot's path and sends distance data to
the Arduino. This information is used to stop or navigate around obstacles.

Light Sensor: Measures light intensity using a photo-resistor that adjusts its
resistance based on light levels.

Figure: Light Sensor

Function: This sensor is essential for detecting changes in light intensity,


facilitating applications such as automatic brightness adjustment in displays and
energy-efficient lighting systems.

Servomotor: Facilitates precise control of angular or linear position, velocity,


and acceleration within mechanical systems.
Figure: Servomotor

Function: Essential in parking systems, servomotors integrate with sensors and


controllers to accurately manoeuvre vehicles into designated spaces, ensuring
efficient and reliable parking operations.

10k Ohm Resistor for Photo Detection:

Figure: 10k Ohm Resistor

Function: Used in conjunction with a light sensor, this resistor helps stabilise and
adjust the signal output based on the detected light intensity, ensuring accurate
and reliable photo detection in various electronic applications.

External Power Supply: A mobile phone charger as external power supply


medium.
Fig: A mobile phone charger

Function: Used to power supply in relay module, wifi module etc.

LED Lights for Lighting:

Figure: LED Lights

Function: These energy-efficient light-emitting diodes (LEDs) provide


illumination in diverse applications, offering long lifespan, low energy
consumption, and robust performance compared to traditional lighting sources.

ESP8266 NodeMCU:

Description: The NodeMCU is an open-source IoT platform utilising the


ESP8266 Wi-Fi module. It features firmware tailored for the ESP8266 Wi-Fi SoC
and hardware based on the ESP-12 module. It integrates Wi-Fi capability,
supports multiple interfaces (GPIO, SPI, I2C, PWM, UART), and can be
programmed using Lua or the Arduino IDE.
Figure: ESP8266 NodeMCU

Function: As the central controller in the project, the NodeMCU connects to Wi-
Fi networks and processes commands from the Blynk app. It controls peripherals
such as relay modules, enabling seamless communication and automation in IoT
applications.

Relay Module:

Description: The 3-relay module is an electronic device featuring three


independent relays. Each relay is capable of toggling electrical devices on and
off, enabling the control of high-voltage appliances using low-voltage signals
from a microcontroller.

Figure: 3-Relay Module


Functionality: In this project, the 3-relay module serves to manage power to the
lights. Signals from the NodeMCU activate the relay module, which in turn opens
or closes circuits to control the lighting system, facilitating remote operation and
automation.

Gas Detector:

Description: A gas detector is an electronic device designed to detect the


presence of specific gases in the air. It typically includes sensors that respond to
certain gases, alerting users to potentially hazardous levels.

Figure: Gas Detector

Functionality: Used for safety and monitoring purposes, a gas detector in this
project senses the presence of gases such as carbon monoxide or methane. Upon
detection, it triggers alerts or actions to mitigate risks, ensuring the safety of
occupants in indoor environments

Software Requirement:
Arduino IDE:

software is required for the project. Custom programs according to the project's
requirements have been written using the IDE.
Blynk App:

Description: The Blynk app is a mobile application designed for IoT projects,
providing an easy-to-use interface to control and monitor devices over the
internet. It supports various widgets to create custom control panels.

Functionality: The Blynk app allows users to interact with the NodeMCU via the
internet. Users can toggle buttons on the app to send commands to the NodeMCU,
which then controls the relays to switch the lights on or off.

Procedure To Build the Home:

1. Design and Planning:

A. Define Requirements: The project began by outlining the smart home


system's objectives and functionalities, which included automated
lighting control, energy-efficient operations, integration with IoT
platforms for remote management, gas detection for safety, and smart
parking for convenience.

B. Component Selection: Based on these requirements, critical


components were selected: LED lights for efficient lighting, the
ESP8266 NodeMCU for central control and IoT connectivity, a 3-relay
module for electrical device control, a gas detector for air quality
monitoring, and sensors and actuators for implementing smart parking
functionality.

C. Home Construction: A detailed blueprint was created to strategically


position sensors and devices throughout the home. This plan ensured
optimal functionality of each component, facilitating automated
lighting adjustments, energy conservation, real-time gas monitoring for
safety, and smart parking capabilities for seamless vehicle management
within the premises.

2. Programming the Arduino:


A. Setup Arduino IDE: We installed the Arduino IDE on our computer
and connected the Arduino UNO via USB.
B. Write Code: We wrote the code to control the robot's movements.
The main functions included:
● Design and Implementation: We engineered a comprehensive
control system for managing home automation tasks with a focus
on key functionalities:
● Light Control: Developed algorithms to dynamically adjust
lighting based on ambient light levels sensed by IR sensors,
ensuring optimal illumination throughout the day.
● Obstacle Detection and Smart Parking: Integrated sonar
sensors not only for detecting obstacles within the home
environment but also for facilitating smart parking solutions.
This enabled real-time responses such as stopping or adjusting
the system's course to prevent collisions and efficiently manage
vehicle parking within the premises.
● Actuator Management: Integrated relay modules to efficiently
control a variety of electrical devices, including lights and
appliances, thereby promoting energy efficiency and enhancing
user convenience.
● This setup was designed to establish a responsive and efficient
home automation system aimed at elevating comfort, bolstering
security measures, optimising energy consumption, and
providing convenient smart parking solutions for its occupants.
C. Upload Code: We uploaded the code to the Arduino UNO and wifi
module.

3. Home Construction:
We selected cardboard to build a demo home to house all components. The
home included motors, sensors, lights, wires, relay modules, a breadboard,
a Wi-Fi module, etc.

A. To assemble the hardware components on the chassis:

● Arduino UNO: Placed at the back of the house (in the storage room)
for aesthetic purposes.
● Servomotor: Positioned in front of the garage for opening and
closing the door.
● Sonar Sensor (HC-SR04): Mounted at the front of the garage for
clear car/obstacle detection, and also placed at the room’s door for
thief detection.
● Light Sensor: Placed on the roof for optimal light detection.
● LED lights: Installed both inside and outside the room to eliminate
darkness.
● ESP8266 NodeMCU and Relay Module: Both positioned near the
Arduino UNO and the power supply area.
● Gas Detector: Installed inside the house to detect gas leaks and
ensure fire safety.
● External Power Supply: Positioned at the back of the house, near
the Arduino and Relay Module, to ensure uninterrupted power
supply.

Using jumper cables, we connected all components to the Arduino UNO


and Wi-Fi module according to the circuit diagram. We ensured secure and
clean connections to prevent any short circuits or loose connections.

B. Wiring and connections:

Pin Details for Each Component:

1. Gas Sensor (MQ-6)


○ Arduino Pin: A1 (Analog Input)
○ Arduino Pin: 5V (Power)
○ Arduino Pin: GND (Ground)
2. Gas Sensor Indicator LED
○ Arduino Pin: 12 (Digital Output)
○ Arduino Pin: GND (Ground)
3. Ultrasonic Sensor 1 (HC-SR04) (For Parking)
○ TRIG Pin → Arduino Pin: 9
○ ECHO Pin → Arduino Pin: 10
○ VCC → Arduino Pin: 5V
○ GND → Arduino Pin: GND
4. Ultrasonic Sensor 2 (HC-SR04) (For Thief Detection)
○ TRIG Pin → Arduino Pin: 6
○ ECHO Pin → Arduino Pin: 7
○ VCC → Arduino Pin: 5V
○ GND → Arduino Pin: GND
5. Servo Motor
○ Signal Pin → Arduino Pin: 8
○ External Power Source: 5V (Power)
○ Arduino Pin: GND (Ground)
6. Light Sensor (LDR)
○ Analog OUT Pin → Arduino Pin: A0
○ Arduino Pin: 5V (Power)
○ Arduino Pin: GND (Ground)
7. LED Indicators for Light Sensor
○ Green LED
■ Arduino Pin: 2 (Digital Output)
■ Arduino Pin: GND (Ground)
○ Yellow LED
■ Arduino Pin: 3 (Digital Output)
■ Arduino Pin: GND (Ground)
○ Red LED
■ Arduino Pin: 4 (Digital Output)
■ Arduino Pin: GND (Ground)

The Arduino setup integrates several components for environmental


monitoring and control. The gas sensor, connected to pin A1, detects gas
levels, with an indicator LED on pin 12 signaling gas presence. Ultrasonic
Sensor 1 (for parking) uses pins 9 (TRIG) and 10 (ECHO) to measure
distance and control a servo motor on pin 8 based on proximity. Ultrasonic
Sensor 2 (for thief detection) is connected to pins 6 (TRIG) and 7 (ECHO)
for additional distance measurement. A light sensor on pin A0 reads light
levels, with LEDs on pins 2 (green), 3 (yellow), and 4 (red) providing
visual feedback based on the light intensity. The code processes sensor
data, adjusts the servo position, and controls the LEDs while sending
updates to the serial monitor for diagnostics.

A simplified circuit diagram and also a diagram of all the connections has
been given below.
Figure: Connections of the components(without wifi module)

Relay and NodeMcu Pin Details:

● LED Pins:
○ LED Pin 1: D0 (Mapped to ledPin1)
○ LED Pin 2: D1 (Mapped to ledPin2)
○ LED Pin 3: D2 (Mapped to ledPin3)
● Relay Pins:
○ Relay Pin 1: D3 (Mapped to relayPin1)
○ Relay Pin 2: D4 (Mapped to relayPin2)
○ Relay Pin 3: D5 (Mapped to relayPin3)

Functionality:

● V1: Controls LED connected to D0


● V2: Controls LED connected to D1
● V3: Controls LED connected to D2
● V4: Controls Relay connected to D3
● V5: Controls Relay connected to D4
● V6: Controls Relay connected to D5

In this setup, the ESP8266 (NodeMCU) serves as the central controller,


connecting to Wi-Fi and communicating with the Blynk app to manage various
components. LEDs connected to pins D0, D1, and D2 provide visual indicators,
turning on or off based on commands received from the app. Relays connected to
pins D3, D4, and D5 control high-power devices, allowing users to switch
appliances on and off remotely. The Blynk app enables remote control of these
LEDs and relays through virtual pins, while the Serial Monitor is used for
debugging and monitoring system status. This setup allows for convenient remote
operation and real-time feedback on connected devices.

C. Programming the Arduino:


The Arduino is programmed to read the input from the sensors and
act accordingly.
Code link: https://github.com/MehediHasan-75/Smart-Home-
Project/blob/main/integrate.ino

C. Programming the ESP8266 NodeMCU:

1. Integration and Testing:

Initial Tests:

● Gas Sensor: Verified sensor readings to ensure accurate detection of


LPG. Although the gas sensor code is commented out, initial testing
was conducted to check its response and LED indicator functionality.
● Ultrasonic Sensors: Tested both ultrasonic sensors for distance
measurement accuracy. Confirmed proper operation by checking that
the servo motor responded correctly to distance readings from the first
sensor.
● Servo Motor: Ensured that the servo motor adjusted its angle correctly
based on the distance measured by the first ultrasonic sensor.
● Light Sensor and LEDs: Checked light sensor readings and verified
that the LEDs responded appropriately to changes in ambient light.

Integrated Testing:

● After confirming the functionality of individual components, the entire


system was tested to evaluate its integrated behavior. This included
checking how well the sensors and actuators worked together in real-
time scenarios. Adjustments were made to sensor positions and code to
optimize performance and reliability.

Troubleshooting:

● Addressed issues related to sensor readings and motor control.


Troubleshooting involved debugging incorrect readings and ensuring
accurate responses from all sensors and actuators. The code was fine-
tuned to enhance the system’s responsiveness and precision.

2. Iteration and Improvement:


Performance Optimization:

● Iterative Testing: Conducted iterative tests to optimize the system’s


performance. Made incremental adjustments to both hardware and
software, including fine-tuning the distance-based servo motor control
and improving light sensor responsiveness.
● Algorithm Refinement: Enhanced the logic for distance measurement
and light sensing to improve the accuracy and efficiency of the system.
Refined the control responses based on sensor data to ensure more
precise operation.

Stability and Reliability:

● Consistency Testing: Ensured the system operated reliably over


extended periods and under various conditions. Made adjustments to
improve system stability, including validating sensor accuracy and
actuator performance during prolonged use.

Final Assembly:

● Component Securing: Finalized the assembly by securely mounting


all components and ensuring all connections were stable. Prepared the
system for demonstration and practical use, confirming that it met all
operational requirements.
Through these steps, we successfully developed and optimized the integrated
system, ensuring it met performance standards and operated effectively for its
intended applications.

6. Blynk App Integration:


To integrate the Blynk app in your IoT project, ensure you have the following
software:
1. Blynk Mobile App
a. Platform: iOS and Android
2. Blynk Library for Arduino IDE
a. Installation: Via Arduino IDE Library Manager.
3. Arduino IDE
a. Version: Latest version
4. ESP8266 Board Package
a. Installation: Add the URL to Arduino IDE Board Manager
5. Blynk Authentication Token
a. Generation: From the Blynk app after creating a new project
6. Wi-Fi Credentials
a. Details: SSID (network name) and password of your Wi-Fi network

Github link of the project:


https://github.com/MehediHasan-75/Smart-Home-Project

Conclusion:
In the process of smartening the home, we encountered challenges that
contributed to refining the final product. This project showcases the integration
of various electronic components to achieve home automation. It highlights the
practical applications of IoT and serves as a foundational exercise in
understanding autonomous systems and sensor integration principles.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy