0% found this document useful (0 votes)
9 views24 pages

Wi-Fi Home Automation Project Overview

Project

Uploaded by

shivangiladde822
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views24 pages

Wi-Fi Home Automation Project Overview

Project

Uploaded by

shivangiladde822
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Tables of Contents

 Student Information
 Introduction
 Project Specifications
o Function Requirements
o Non-Functional Requirements
 Hardware Architecture
o 4.1 List of Hardware components used
 Software Architecture
 Code
 Results
 Future work

1|Page
Topic : Home Automation using Wi-Fi Module
1. Student Information:
 Student name: Ambika
 University Name and Location: Lingaraj Appa Engineering college
Bidar
 University Serial Number (USN) if any: 3LA23LVS01
 Submission Date: 13-01-2025

2. Introduction
 Internet of Things (IOT) is changing the way we live in our home and operate
our things at home.
 The Appliance is getting connected to internet is quite easy to automate the
appliances operation at homes.
 In future we are expecting to have homes without physical switches and all
the bulbs, fans and appliance will be switched on/off using mobile application.
 Some of these may also operate automatically based on the need.
 This project takes two simple things at home (electric bulb and fan) and
control of these through a mobile application or they automatically switch on
or off when there is a need.

2|Page
3. Project Specifications:
a. Function Requirements:
 This project controls two home appliances, a light and a fan connected to a
230v supply through relays.
 The controller board is connected to the home appliances through Wi-Fi
network.
 Auto or Manual control mode can be selected on the mobile phone.

Auto mode:

 When a person enters the room and if no day light in the room, then the bulb
will be switch on.
 When the person moves out, the bulb will switch off.
 When the temperature in the room goes beyond a threshold the fan will stop.

Manual mode:

 The fan and bulb can be switched on and off through the mobile phone
connected to the same home network (home router) by browsing to the
appropriate IP address.
 The bulb and fan cannot be controlled manually if it’s in auto mode.

[Link]-Function Requirements:
Performance requirement:

Automatic mode:
 The bulb should switch on after the entry of human in the room within a
minute
 Fan should switch on as soon as the threshold is detected within 1
minute.

3|Page
Manual control mode:
 The bulb should switch on within 1 minute of pressing the button on the
mobile phone.
 Fan should switch on within 1 minute of pressing the button on the mobile
phone.

Environment requirement: The system should work in the


temperature range 0 degree to 60 degree centigrade.

4. Hardware Architecture:

This system uses an ESP32 microcontroller, connected sensors, and relays to


monitor environmental conditions and control devices like a lamp and fan in
automatic mode or manual mode. The system can switch between these modes
based on user requirements.

4|Page
1. Initialization Phase
Microcontroller Setup:
The ESP32 initializes all sensors (DHT11, LDR, and ultrasonic).
The relay module is configured, ensuring all connected devices (lamp and fan)
start in the OFF state.
Wi-Fi is set up for remote communication and control.
2. Automatic Mode
In automatic mode, the ESP32 uses sensor data to control the fan and lamp
without user input:
a) Fan Control
Input: Temperature reading from the DHT11 sensor.
Logic:
If the temperature exceeds a predefined threshold (e.g., 30°C), the fan turns
ON.
If the temperature drops below the threshold, the fan turns OFF.
Output: Activates the relay connected to the fan.
b) Lamp Control
Input: Light intensity reading from the LDR sensor.
Logic:
If the ambient light level is below a certain threshold (e.g., in the evening), the
lamp turns ON.
If it's bright (e.g., during the day), the lamp turns OFF.
Output: Activates the relay connected to the lamp.

5|Page
c) Distance Monitoring (Optional)
Input: Distance from the ultrasonic sensor.
Logic:
Can trigger additional actions, such as turning devices on/off when an object
is detected within a specific range.
Example:
If a person comes close to the system, it could toggle the lamp or fan.
3. Manual Mode
In manual mode, the user can directly control the fan and lamp via a mobile
app, web interface, or physical switches.
Input: Commands sent through Wi-Fi to the ESP32.
Logic:
The user sends ON/OFF commands for the fan and lamp.
The ESP32 processes the command and activates/deactivates the appropriate
relay.
Output: Relays respond to the user’s commands, controlling the connected
devices.
4. Wi-Fi Communication
The ESP32 connects to a Wi-Fi network and acts as a server or client to
receive instructions or send data.
Example actions:
User sends a command to switch the fan ON.
ESP32 responds with confirmation (e.g., "Fan is ON").

6|Page
It can also display sensor readings (temperature, humidity, distance, light
intensity) on the user interface.
5. Safety Features
Relay Fail-Safe: If the system loses power or the microcontroller resets, the
relays can default to OFF to prevent unexpected activation.
Overload Protection: Ensure the relays can handle the power requirements of
the lamp and fan.
Wi-Fi Timeout: If Wi-Fi communication is lost, the system continues to run
in automatic mode.
6. Example Use Cases
Automatic Room Cooling:
The fan automatically turns on if the temperature exceeds 30°C.
Lighting Control:
The lamp turns on at night and off during the day.
Remote Control:
A user can override the system remotely to manually turn devices on/off.

a. List of Hardware Components used


1. Ultra sonic sensor
2. WIFI Module (ESP32)
3. LDR sensor
4. DHT 11
5. 2 Channel Relay
6. Lamp
7. Fan
8. Adapters (12v and 5v)
7|Page
1. Ultra sonic sensor:

 An ultrasonic sensor is a kind of electronic device that uses ultrasonic sound


waves to detect the distance between two objects and transforms the reflected
sound into an electrical signal. Ultrasonic waves move quicker than audible
sound (i.e., the sound that humans can hear).
 A sensor converts the physical action to be measured into an electrical
equivalent and processes it so that the electrical signals can be easily sent and
further processed. The sensor can output whether an object is present or not
present (binary) or what measurement value has been reached (analog or
digital).
 Range: They DO NOT measure farther than about 70 feet (21 meters). They
DO NOT measure at very high repetition rates. Due to speed of sound
limitations the fastest rate is 200 Hz at a max distance of about 24 inches.
They DO NOT work as accurately in vapour environments that change the
speed of sound from that of air.

2. Wi-Fi module:
8|Page
 ESP32 is a chip that provides Wi-Fi and (in some models) Bluetooth
connectivity for embedded devices – in other words, for IoT devices. While
ESP32 is technically just the chip, the modules and development boards that
contain this chip are often also referred to as “ESP32” by the manufacturer.
 Range: Drone Bridge for ESP32 for the popular ESP32 modules from
Espresso Systems offers a transparent and bi-directional serial to Wi-Fi
bridge. In addition it features a custom ESP-NOW implementation which
allows for ranges of up to 1km.
 Engineered for mobile devices, wearable electronics and IoT applications,
ESP32 achieves ultra-low power consumption with a combination of several
types of proprietary software. ESP32 also includes state-of-the-art features,
such as fine-grained clock gating, various power modes and dynamic power
scaling.

3. LDR Sensor:
9|Page
 LDR full form Light Dependent Resistor. LDR is a simple device that can be
used to detect light levels and respond to light. When there's more light, its
resistance goes down, and when there's less light, its resistance goes up. LDR
light sensor is also known as a photo resistor, photocell, or photoconductor.
 LDRs are tiny light-sensing devices also known as photo resistors. An LDR is
a resistor whose resistance changes as the amount of light falling on it
changes. The resistance of the LDR decreases with an increase in light
intensity. This property allows us to use them for making light sensing
circuits.
 The working principle of an LDR is photoconductivity, which is nothing but
an optical phenomenon. When the light is absorbed by the material then the
conductivity of the material enhances.

4. DHT 11 :

 The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor.
It uses a capacitive humidity sensor and a thermostat to measure the
surrounding air and spits out a digital signal on the data pin (no analog input
pins needed). It's fairly simple to use but requires careful timing to grab data.
 The output of the DHT11 is in the form of a digital signal on a single data pin.
The sensing update frequency is to be measured at every 2sec (0.5Hz).
10 | P a g e
 DHT11's power supply is 3-5.5V DC. When power is supplied to the sensor,
do not send any instruction to the sensor in within one second in order to pass
the unstable status. One capacitor valued 100nF can be added between VDD
and GND for power filtering.

5. 2 Channel Relay

 The 2 Channels Relay Module is a convenient board which can be used to


control high voltage, high current load such as motor, solenoid valves, lamps
and AC load. It is designed to interface with microcontroller such as Arduino,
PIC and etc.
 The primary function of a relay module is to switch electrical devices or
systems on and off. It also serves to isolate control circuits, ensuring that low-
power devices, such as microcontrollers, can safely control higher voltages
and currents.
 A relay is an electrical switch controlled by an electromagnet. This
electromagnet can operate in either AC or DC systems, allowing the relay to
control the flow of current in various applications.

11 | P a g e
6. Lamp

 Use a 60 to 80-watt light bulb for detail-oriented tasks. Avoid cool


fluorescent bulbs that emit harsh lighting that can strain your eyes and make
you feel tired. Opt for warm halogen bulbs that are close to natural daylight
and place less strain on your eyes.
7. Fan :

 DC fan are powered with a potential of fixed value such as the voltage of a
battery, it is used for cooling motors and transmissions, for cooling and drying
people, also used in cooling of IC in CPU.

8. Adapters (12v and 5v):

 Providing a modest voltage of 5V, they efficiently power everyday gadgets


like smart phones, tablets, USB hubs, and small electronic devices. The 5V
standard gained prevalence due to its compatibility with USB devices, a
widely used interface for charging and data transfer
 A 12V DC power supply is an adapter designed to supply precisely 12 Volts
of direct current to a device.
12 | P a g e
5. Software Architecture:

This is a flowchart diagram outlining the structure of a program. Here's a


breakdown of the components:

1. Main Program

The central node that branches into different modules or functions.

2. Functions Called by Main Program

setRelay()
Contains sub-functions:
serialSetup()
DHTsetup()
relaySetup()
LDRsetup()
ultraSonicSensorSetup()
wifiSetup()
handleManualMode()
handleAutoMode()
13 | P a g e
Contains sub-functions:
getTemp()
getDistance()
isItLight()
checkClient()

Detailed Explaination:

1. Main Program

 Acts as the entry point for the program, where the setup and primary
operations begin. It orchestrates the initialization, mode selection, and
continuous execution of the system.

2. Set relay()

 Likely responsible for setting up and controlling relay switches, commonly


used to manage external devices like lights, motors, or appliances.
 Serial Setup()
 Configures the serial communication (e.g., UART) for debugging or
communicating with external devices like microcontrollers or computers.
 DHT setup()
 Initializes a DHT sensor (used for temperature and humidity readings).
 Relay Setup()
 Prepares the relay module by configuring the pins and ensuring the relays
are in a known state (e.g., off initially).

LDR setup ()

 Configures an LDR (Light Dependent Resistor) sensor to measure ambient


light levels.

3. Ultrasonic Sensor Setup ()

14 | P a g e
 Configures ultrasonic sensors, often used for distance measurement by
emitting sound waves and calculating the time taken for the echo to return.

4. Wi-Fi Setup ()

 Sets up the Wi-Fi module to connect the system to a network. This is often
necessary for remote monitoring, control, or data transfer.

5. Handle manual mode ()

 Enables the manual operation of the system, allowing the user to directly
control relays or sensors through an interface (e.g., switches or an app).

6. Handle auto mode ()

 Executes the automatic control logic, making decisions based on sensor


inputs without user intervention.
 Get Temp()
 Reads temperature data from the DHT sensor.
 Get Distance()
 Fetches distance readings from the ultrasonic sensor.
 Is It Light()
 Determines the light level using the LDR sensor to decide whether it's dark
or bright.

7. Check Client ()

 Handles client requests, typically used in networked applications to check


for commands or data requests from a user interface (e.g., a mobile app or
web dashboard).

Overall Program Structure:


Initialization Phase:
 Calls setup functions (Wi-Fi Setup(), set Relay(), etc.) to prepare the system's
hardware and software.

Operation Phase:

15 | P a g e
 Continuously runs either in Manual Mode (handle Manual Mode ()) or Auto
Mode (handle Auto Mode ()).
Networking Phase:
 Maintains connectivity and responds to user commands via check Client ().

a. Code
#include <ESP32WiFi.h>
// Add wifi access point credentials
const char* ssid = "Home_auto";
const char* password = "12345678";
Wi-Fi Server server(80);// Set port to 80
String header; // This stores the HTTP request
// Declare the pins to which the appliances are connected via relays
int app1 = D1; //appliance 1
int app2 = D2; //appliance 2`
//you can add more more appliances below.
String app1state = "off";// state of appliance1
String app2state = "off";// state of appliance2
void setup() {
[Link](115200);
// Set the pin mode of the pins to which the LEDs are connected and turn
them low to prevent fluctuations
pinMode(app1, OUTPUT);
pinMode(app2, OUTPUT);
digitalWrite(app1, LOW);
digitalWrite(app2, LOW);
//connect to access point
[Link](ssid, password);
[Link]("Connecting to ");
[Link](ssid);
while ([Link]() != WL_CONNECTED) {
delay (500);
16 | P a g e
[Link](".");
}
// Print local IP address and start web server
[Link]("");
[Link]("WiFi connected.");
[Link]("IP address: ");
[Link]([Link]());// this will display the Ip address of the Pi which
should be entered into your browser
[Link]();
}
void loop(){
WiFiClient client = [Link](); // Listen for incoming clients
if (client) { // If a new client connects,
String currentLine = ""; // make a String to hold incoming data
from the client
while ([Link]()) { // loop while the client's connected
if ([Link]()) { // if there's bytes to read from the client,
char c = [Link](); // read a byte, then
[Link](c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if ([Link]() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200
OK)
// and a content-type so the client knows what's coming, then a blank
line:
[Link]("HTTP/1.1 200 OK");
[Link]("Content-type:text/html");
[Link]("Connection: close");
[Link]();

17 | P a g e
// turns the GPIOs on and off
if ([Link]("GET /app1/on") >= 0) {
[Link]("App 1 on");
app1state = "on";
digitalWrite(app1, HIGH);
} else if ([Link]("GET /app1/off") >= 0) {
[Link]("App 1 off");
app1state = "off";
digitalWrite(app1, LOW);
} else if ([Link]("GET /app2/on") >= 0) {
[Link]("App 2 on");
app2state = "on";
digitalWrite(app2, HIGH);
} else if ([Link]("GET /app2/off") >= 0) {
[Link]("App 2 off");
app2state = "off";
digitalWrite(app2, LOW);
}
// Display the HTML web page
[Link]("<!DOCTYPE html><html>");
[Link]("<head><meta name=\"viewport\" content=\"width=device-
width, initial-scale=1\">");
[Link]("<link rel=\"icon\" href=\"data:,\">");
// CSS to style the on/off buttons
// Feel free to change the background-color and font-size attributes to
fit your preferences
[Link]("<style>html { font-family: Helvetica; display: inline-block;
margin: 0px auto; text-align: center;}");
[Link](".button { background-color: #195B6A; border: none; color:
white; padding: 16px 40px;");
[Link]("text-decoration: none; font-size: 30px; margin: 2px; cursor:
pointer;}");

18 | P a g e
[Link](".button2 {background-color: #77878A;}</style></head>");
// Web Page Heading
[Link]("<body><h1>ESP32 Web Server</h1>");
// Display current state, and ON/OFF buttons for GPIO 5
[Link]("<p>app1 - State " + app1state + "</p>");
// If Appliance 1 is off, it displays the ON button
if (app1state == "off") {
[Link]("<p><a href=\"/app1/on\"><button
class=\"button\">ON</button></a></p>");
} else {
[Link]("<p><a href=\"/app1/off\"><button class=\"button
button2\">OFF</button></a></p>");
}
// Display current state, and ON/OFF buttons for GPIO 4
[Link]("<p>app2 - State " + app2state + "</p>");
// If Appliance 2 is off, it displays the ON button
if (app2state == "off") {
[Link]("<p><a href=\"/app2/on\"><button
class=\"button\">ON</button></a></p>");
} else {
[Link]("<p><a href=\"/app2/off\"><button class=\"button
button2\">OFF</button></a></p>");
}
[Link]("</body></html>");
// The HTTP response ends with another blank line
[Link]();
// Break out of the while loop
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}

19 | P a g e
} else if (c != '\r') { // if you got anything else but a carriage return
character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
[Link]();
[Link]("Client disconnected.");
[Link]("");
}
}
6. Results:
Experiment Set-up:

1. Key Components and Their Role

20 | P a g e
 ESP32 Microcontroller: The brain of the system, which reads data from
sensors, processes commands, and controls relays.
 Relays: Acts as switches to control high-power devices like a lamp or fan.
 Sensors:
o DHT11: Measures temperature and humidity for controlling the fan.
o LDR: Measures light intensity to turn the lamp ON/OFF automatically.
 Wi-Fi: Connects the ESP32 to a local network, enabling communication with
a user interface (like a browser or app).

2. Modes of Operation
a. Manual Mode (User-Controlled)

How it Works:

 The user sends commands (e.g., turn the lamp ON or OFF) via a web browser
or app.
 These commands are received by the ESP32 over Wi-Fi and processed.
 The ESP32 toggles the appropriate relay to control the lamp or fan.

Example:

 Visit the ESP32's web server (IP address).


 Use URLs like /lamp/on or /fan/off to control the devices.
 The server confirms actions (e.g., "Lamp ON") and updates the device's state.

3. Wi-Fi Communication
 Setup:
o The ESP32 connects to your Wi-Fi network using your SSID and
password.
o Once connected, it assigns an IP address, which you can use to access
the system.

 Web Server:
21 | P a g e
 The ESP32 hosts a small web server that listens for user commands.
 Example routes:
 /lamp/on: Turns the lamp ON.
 /lamp/off: Turns the lamp OFF.
 /fan/on: Turns the fan ON.
 /fan/off: Turns the fan OFF.
 /status: Returns real-time sensor readings (e.g., temperature, light

4. Code Breakdown
Setup Function:

 Configures pins for relays, sensors, and the Wi-Fi connection.


 Starts the web server and sets up routes (URLs) for controlling devices.

Loop Function:

 Continuously monitors sensors:

 Reads temperature from the DHT11 and light levels from the LDR.
 Turns devices ON/OFF automatically based on the sensor readings.

5. Practical Example

Scenario 1: Manual Control

 Open a web browser and go to the ESP32's IP address (e.g., [Link]).


 Enter the URL /lamp/on to turn the lamp ON.
 Enter /fan/on to turn the fan ON.
 The ESP32 responds to each command and updates the relay states.

Scenario 2: Automatic Control

 If the room temperature goes above 30°C, the ESP32 detects this from the
DHT11 sensor and automatically turns ON the fan.

22 | P a g e
 If the room becomes dark (low light intensity detected by LDR), the ESP32
turns ON the lamp.

6. Advantages of the System

1. Automation: Reduces the need for manual operation.


2. Remote Control: Devices can be controlled from anywhere in the Wi-Fi
network.
3. Energy Efficiency: Ensures appliances only operate when needed (e.g., fan
only runs when it's hot)

7. Enhancements

 Integrate with cloud services (e.g., Google Firebase, Blynk) for remote control
from anywhere in the world.
 Add voice control using assistants like Alexia or Google Assistant.
 Expand to more devices (e.g., controlling multiple rooms or appliances).

7. Future Work
 Using this system as a framework. The system can be expanded to include
various other options which could include home security features like
capturing the photo of a person moving around the house and storing it onto
the cloud.
 This will reduce the data storage that using the CCTV camera which will
record all the time and stores it. The system can be expanded for energy
monitoring or weather stations. This kind of a system with respective changes
can be implemented in the hospitals for disable people or in industries where
human invasion is impossible or dangerous and it can also be implemented for
environmental monitoring.
 Future scope for the home automation systems involves making homes even
smarter. Homes can be interfaced with sensors including motion sensors, light
sensors and temperature sensors and provide automated toggling of devices
based on conditions.
 Home automation offers a global standard for interoperable products. The
home automation market is primarily driven by growing need for effective
solutions in various domestic applications such as lighting, safety and
security, energy management, entertainment, heating, ventilation, and air
conditioning.
23 | P a g e
 The Home automation using Internet of Things has been experimentally
proven to work satisfactorily by connecting
 Simple appliances to it and the appliances were successfully controlled
remotely through internet. The designed system not only monitors the sensor
data like temperature, gas, light, motion sensor but also actuates a process
according to the requirement. For example, the switch gets dark. It also stores
the sensor parameters in the cloud (Gmail) in a timely manner. This will help
the user to analyze the condition of various parameters in the home anytime
anywhere.
 The home automation using Internet of Things has been experimentally
proven to work satisfactorily by connecting

Simple appliances to it and the appliances were successfully controlled remotely


through Internet. Home automation is undeniably a resource which can make a
home environment automated. People can control their electrical devices via
these home automation devices and set up controlling actions through mobile. In
future this product may have high potential for marketing. Further it can be
demonstrated from computer instead of mobile phones for controlling appliances
of any large places like industries, hospitals, institutions etc., centrally.

24 | P a g e

You might also like