You are on page 1of 9

Electronics Engineering Lab

Semester Project
Wi-Fi Home Automation System

Submitted to: Engr. Ali Hassan Bhatti Section: C


Name CMS Report Performance Viva

Waleed Nasir 394281

Muhammad 366729
Zorain Haider
Muhammad 373472
Usman
Muhammad 365711
Ibrahim

School of Mechanical and Manufacturing Engineering,


NUST
Abstract
This project investigates the progress made in consumer electronics and embedded systems, with a
specific focus on using a mobile application to control electrical appliances in households. The goal is to
develop an automated system that allows for remote control and automation by utilizing a NodeMCU
microcontroller board and a Wi-Fi module. The system employs the NodeMCU, which is based on the
ESP8266 Wi-Fi module, to establish wireless communication between the mobile application and the
control unit. By eliminating the need for physical cables, users can conveniently manage their home
appliances using their smartphones. The design prioritizes affordability, user-friendliness, and easy
installation. The NodeMCU connects with the Wi-Fi module and regulates the switching of electrical
appliances through relays. The mobile application provides a user-friendly interface for individuals to
interact with and control their home appliances. Overall, this project demonstrates the potential of
integrating NodeMCU, Wi-Fi technology, and a mobile application to create a connected home
environment. The wireless capabilities of Wi-Fi enable efficient remote control and automation of
electrical appliances, offering convenience and flexibility to users.

Introduction
Automation, a commonly used term in the field of electronics, has played a significant role in driving
technological advancements. Its user-friendly nature has made it highly valuable, often replacing existing
technologies. For instance, traditional home switches can be prone to sparking and can even lead to fire
accidents in certain situations. Consequently, the concept of home automation has gained substantial
popularity in recent years. It empowers homeowners to control and automate various aspects of their
homes, offering benefits such as enhanced convenience, energy efficiency, and security. One crucial
aspect of a home automation system is the integration of microcontrollers, sensors, and actuators, which
create an intelligent network capable of remote control. In this introduction, we will delve into the
fundamental components of a home automation system, including:

 NodeMCU ESP8266
 4 Relay 5V module
 7805 5V Voltage Regulator IC
 LDR Module
 Light bulbs
 Power Supply (9V Battery)

NodeMCU ESP 8266:


The Node MCU ESP8266 is an affordable and versatile microcontroller board with built-in Wi-Fi
capability, making it an ideal choice for the central component of a home automation system. Powered by
the ESP8266 chip, this board provides a reliable platform for developing Internet of Things (IoT)
applications. With its integrated Wi-Fi connectivity, the Node MCU ESP8266 seamlessly connects with
other smart devices and internet-based services, enabling smooth integration within the home automation
network.
Relay 5V Module:
In home automation systems, the 5V relay serves as an electromechanical switch frequently employed to
regulate high-power devices like lights, fans, and appliances. Its primary function is to bridge the gap
between the low-voltage control signals originating from the microcontroller and the higher voltage
demands of the connected devices. Through the utilization of relays, the microcontroller can conveniently
control the activation and deactivation of these devices from a remote location, providing advanced
control and automation functionalities.

Voltage Regulator IC 7805:


The 7805-voltage regulator IC is widely employed in electronic circuits to maintain a stable and regulated
supply voltage. Within a home automation system, it plays a crucial role in ensuring a consistent and
reliable power supply for the microcontroller and other components. By safeguarding against voltage
fluctuations and surges, the 7805 IC protects these components from potential damage. Specifically, the
7805 IC is responsible for regulating the input voltage to a steady 5 volts, which is often the required
voltage for microcontrollers like the NodeMCU ESP8266.
LDR Module:
An LDR module, also known as a Light Dependent Resistor module, is a component used to detect and
measure light levels in electronic circuits. It consists of a light-sensitive resistor that exhibits changes in
resistance based on the intensity of the incident light. The LDR module is commonly used in applications
such as automatic lighting systems, burglar alarms, and light-sensitive switches. By incorporating an LDR
module into a circuit, the system can respond and adapt to varying light conditions, enabling intelligent
control and automation based on the detected light levels.

Literature Review:
The reviewed home automation system utilizes Wi-Fi technology to enable wireless
communication between home appliances and a mobile phone. It employs an Arduino board and
a Wi-Fi module for this purpose. The Arduino program, written in a high-level interactive
language like C, allows for control and status monitoring of the devices via the established Wi-Fi
connection. To ensure authorized access, the system incorporates password protection. Users can
remotely monitor and control the devices by receiving feedback on their mobile phones
regarding the device status.
On the other hand, the GSM-based home automation system relies on mobile phones and Global
System for Mobile Communication (GSM) technology for communication. Multiple
communication methods, including SMS-based, GPRS-based, and DTMF-based, are considered.
The system architecture involves home sensors and devices connected to the home network,
communicating through GSM and SIM (subscriber identity module). Transducers are utilized to
convert machine functions into electrical signals, which are then processed by a microcontroller.
The sensors in the system convert physical qualities such as sound, temperature, and humidity
into voltage signals. The microcontroller analyzes these signals and sends commands to the GSM
module for communication and control purposes.

How the System works


Wi-Fi based home automation system mainly consist of three modules, the server, the hardware
Interface module, and the software package. The figure below shows the system model layout.
Wi-Fi technology is used by server, and Hardware Interface module to communicate with each
other. The same technology is used to login to the server web-based application. The server is
connected to the internet, so remote users can access server web-based application through the
internet using compatible web browser. Software of the latest home automation system is split to
server application software, and Microcontroller (Arduino) firmware. The Arduino software,
built using C language, using IDE comes with the microcontroller itself. Arduino software is
culpable for gathering events from connected sensors, then applies action preprogramed in the
server. Another job is to report and record the history in the server database. The server
application software package for the proposed home automation system, is a web based
application built using asp.net. The server application software can be accessed from internal
network or from internet if the server has real IP on the internet using any internet navigator
supports asp.net technology. Server application software is culpable of, maintain the whole home
automation system, setup and configuration.
Circuit Diagram

Arduino IDE Code:


#include <ESP8266WiFi.h>
const char* ssid = "Password?"; //enter your wi-fi name
const char* password = "MeNahinBataunga"; //enter the wifi password
unsigned char status_led=0;
WiFiServer server(80);
#define Relay1 12 //D6
int value1;
#define Relay2 14 //D2
int value2;
#define Relay3 4 //D1
int value3;
#define Relay4 5 //D5
int value4;
void setup() {
Serial.begin(115200);
pinMode(Relay1,OUTPUT);
pinMode(Relay2,OUTPUT);
pinMode(Relay3,OUTPUT);
pinMode(Relay4,OUTPUT);
digitalWrite(Relay1,HIGH);
digitalWrite(Relay2,HIGH);
digitalWrite(Relay3,HIGH);
digitalWrite(Relay4,HIGH);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
server.begin();
Serial.println(WiFi.localIP());
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
while (! client.available())
{
delay (1);
}
String req = client.readStringUntil('\r');
client.flush();
if (req.indexOf("/Relay1OFF") != -1) {
digitalWrite(Relay1,LOW);
Serial.println("Relay 1 OFF");
}
else if(req.indexOf("/Relay1ON") != -1)
{
digitalWrite(Relay1,HIGH);
Serial.println("Relay 1 ON");
}
if (req.indexOf("/Relay1OFF") != -1) {
digitalWrite(Relay1,LOW);
Serial.println("Relay 1 OFF");
}
else if(req.indexOf("/Relay1ON") != -1)
{
digitalWrite(Relay1,HIGH);
Serial.println("Relay 1 ON");
}
if (req.indexOf("/Relay2OFF") != -1) {
digitalWrite(Relay2,LOW);
Serial.println("Relay 2 OFF");
}
else if(req.indexOf("/Relay2ON") != -1)
{
digitalWrite(Relay2,HIGH);
Serial.println("Relay 2 ON");
}
if (req.indexOf("/Relay3OFF") != -1) {
digitalWrite(Relay3,LOW);
Serial.println("Relay 3 OFF");
}
else if(req.indexOf("/Relay3ON") != -1)
{
digitalWrite(Relay3,HIGH);
Serial.println("Relay 3 ON");
}
if (req.indexOf("/Relay4OFF") != -1) {
digitalWrite(Relay4,LOW);
Serial.println("Relay 4 OFF");
}
else if(req.indexOf("/Relay4ON") != -1)
{
digitalWrite(Relay4,HIGH);
Serial.println("Relay 4 ON");
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<HTML>");
client.println("<H1> HOME AUTOMATION </H1>");
client.println("<br />");
client.println("<a href=\"Relay1ON\"\"> <button style='FONT-SIZE: 40px; color:
red; HEIGHT: 200px; align: center; WIDTH: 200px; 126px; Z-INDEX: 0; TOP: 200px;'>
LED 1 OFF </button> </a>");
client.println("<a href=\"Relay1OFF\"\"> <button style='FONT-SIZE: 40px; color:
green; HEIGHT: 200px; align: center; HEIGHT: 200px; WIDTH: 300px; 126px; Z-INDEX:
0; TOP: 200px;'> LED 1 ON </button> </a><br>");
client.println("<a href=\"Relay2ON\"\"> <button style='FONT-SIZE: 40px; color:
red; HEIGHT: 200px; align: center; WIDTH: 200px; 126px; Z-INDEX: 0; TOP: 200px;'>
LED 2 OFF </button> </a>");
client.println("<a href=\"Relay2OFF\"\"> <button style='FONT-SIZE: 40px; color:
green; HEIGHT: 200px; align: center; HEIGHT: 200px; WIDTH: 300px; 126px; Z-INDEX:
0; TOP: 200px;'> LED 2 ON </button> </a><br>");
client.println("<a href=\"Relay3ON\"\"> <button style='FONT-SIZE: 40px; color:
red; HEIGHT: 200px; align: center; WIDTH: 200px; 126px; Z-INDEX: 0; TOP: 200px;'>
FAN OFF </button> </a>");
client.println("<a href=\"Relay3OFF\"\"> <button style='FONT-SIZE: 40px; color:
green; HEIGHT: 200px; align: center; HEIGHT: 200px; WIDTH: 300px; 126px; Z-INDEX:
0; TOP: 200px;'> FAN ON </button> </a><br>");
client.println("<a href=\"Relay4ON\"\"> <button style='FONT-SIZE: 40px; color:
red; HEIGHT: 200px; align: center; WIDTH: 200px; 126px; Z-INDEX: 0; TOP: 200px;'>
DOOR CLOSE </button> </a>");
client.println("<a href=\"Relay4OFF\"\"> <button style='FONT-SIZE: 40px; color:
green; HEIGHT: 200px; align: center; HEIGHT: 200px; WIDTH: 300px; 126px; Z-
INDEX:0;
TOP: 200px;'> DOOR OPEN </button> </a>");
client.println("</html>");
delay(1);
}

Conclusion:
In the present era, Android has emerged as a robust open-source operating system, offering remarkable
flexibility to incorporate diverse functionalities tailored to our requirements. Leveraging Android devices,
we can easily create an impressive and cost-effective home automation system that enhances both
security and convenience in our homes. This user-friendly solution significantly improves overall
comfort. As a result, the concept of developing a comprehensive home automation system with remote
control and monitoring capabilities has become a reality. The culmination of this project is a remarkable
collection of home appliances that can be conveniently managed through a smartphone connected via a
Bluetooth module. The successful completion of this endeavor is credited to the dedicated efforts of all
project members and the invaluable assistance received from others. Engaging in this project has been an
enriching experience, offering valuable opportunities for learning and experimentation. We have gained
firsthand knowledge about the intricate process of designing and developing home automation systems.
We take immense pride in exploring this captivating subject as our major project, effectively creating our
own iteration of a home automation system. It has allowed us to deeply engage with a rapidly advancing
field of study and research that has the potential to revolutionize people's lifestyles in the near future.

You might also like