IOT Based Home Automation System FINAL REPORT - Delete
IOT Based Home Automation System FINAL REPORT - Delete
AUTOMATION SYSTEM
A PROJECT REPORT
Submitted by
S.NAVEENRAJ (620119104064)
S.RAJAGANESAN (620119104079)
S.D.SETHUPATHI (620119104091)
M.VINOTH (620119104116)
of
BACHELOR OF ENGINEERING
in
MAY 2023
i
ANNA UNIVERSITY : CHENNAI 600 025
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
Prof.V.MEENA,M.E., Prof.V.MEENA,M.E.,
ii
ACKNOWLEDGEMENT
We specially thank all our Teaching and Non-Teaching Staff Members and
Lab Technicians of the Computer Science and Engineering for their consistent
encouragement to do the project work with full interest and zeal. We pay our
profound gratitude to the Almighty God for his invisible vigilance and would like
to thank our Parents for giving us support, encouragement and guidance
throughout the course of our work.
iii
TABLE OF CONTENTS
ABSTRACT vi
1. INTRODUCTION 1
2. LITERATURE REVIEW 2
2.1 ESP8266 2
3. SYSTEM STUDY 4
4. ESSENTIALS 8
5. SOFTWARE ANNOTATION 9
6. SYSTEM FEASIBILITY 12
iv
7. SYSTEM DESIGN AND DEVELOPMENT 13
8. TESTING 15
9. CONCLUSION 17
10. APPENDIX 18
11. REFERENCES 44
v
vi
ABSTRACT
that utilizes the ESP8266 microcontroller and the Flutter framework for
remotely control all home appliances, such as lights, fans, and electronic devices,
mobile application and the home appliances. The system’s advantages include
people interact with their living spaces. The system utilizes the ESP8266
for Android and iOS devices. The proposed system is designed to provide users
with easy and efficient control of their home appliances from anywhere, at any
sensors and actuators installed in the home. These sensors and actuators are used
to monitor and control the appliances in the home. The Flutter application allows
interface. The system is tested and evaluated for its performance, and the results
show that it provides an efficient and reliable solution for home automation.
vi
LIST OF ABBREVATION
ABBREVATION EXPANSION
LIST OF FIGURES
vii
viii
CHAPTER 1
INTRODUCTION
The system uses the ESP8266 microcontroller to control the appliances and
the Flutter framework to develop a multi-platform application. The use of this
system will provide users with convenience, comfort, and energy savings, as they
can easily monitor and control their home appliances from anywhere and at any
time. The following sections provide a detailed description of the proposed system
and its components.
1
CHAPTER 2
LITERATURE REVIEW
2.1 ESP8266:
2
"An IoT-Based Smart Home Automation System Using ESP8266 Wi-Fi
Module" by S. S. Patil et al. (2018) describes an IoT-based home automation
system that uses the ESP8266 microcontroller and a mobile application to control
home appliances. The system includes a web server to store and retrieve data
from the cloud.
3
CHAPTER 3
SYSTEM STUDY
Amazon Echo Plus: Amazon Echo Plus is a smart speaker that can control
compatible smart home devices using voice commands. It features built-in Zigbee
hub and can control a range of smart home devices including lights, locks, and
thermostats.
Google Nest Hub: Google Nest Hub is a smart display that can control
compatible smart home devices using voice commands. It features built-in Google
Assistant and can control a range of smart home devices including lights, cameras,
and speakers.
Apple HomeKit: Apple HomeKit is a home automation system that can control a
range of smart home devices using a smartphone application. It features Siri voice
control and can control devices such as lights, locks, and thermostats.
Wink Hub 2: Wink Hub 2 is a home automation system that can control a range
of smart home devices using a smartphone application. It features a hub that
connects to Wi-Fi and can control devices such as lights, locks, and thermostats.
4
3.2 PROPOSED SYSTEM:
Hardware Component:
Software Component:
5
System Architecture:
ADVANTAGES:
Energy savings: The system allows users to set schedules and timers for
their appliances, reducing energy consumption and saving money on electricity
bills.
6
3.3 METHODOLOGY:
The proposed methodology for developing the IoT based home automation
system involves the following steps:
Hardware Setup: The first step involves setting up the hardware components of
the system, including the ESP8266 microcontroller and the relay board. The
ESP8266 is connected to the relay board, which is then connected to the home
appliances.
Integration: Once the hardware and software components are developed, the next
step involves integrating them to create a functional system. The smartphone
application is configured to send commands to the ESP8266, which processes the
commands and switches the appliances ON or OFF accordingly.
Testing: The final step involves testing the system to ensure that it is functioning
correctly. The system is tested for various scenarios, including turning appliances
ON and OFF, setting schedules and timers, and creating custom control settings.
7
CHAPTER 4
ESSENTIALS
Router : Wi-fi
Database : SQL
8
CHAPTER 5
SOFTWARE ANNOTATION
FLUTTER ARCHITECTURE:
FEATURES OF FLUTTER:
Flutter gives easy and simple methods to start building beautiful mobile and
desktop apps with a rich set of material design and widgets. Here, we are going to
discuss its main features for developing the mobile framework.
Cross-platform: This feature allows Flutter to write the code once, maintain, and
can run on different platforms. It saves the time, effort, and money of the
developers.
Hot Reload: Whenever the developer makes changes in the code, then these
changes can be seen instantaneously with Hot Reload. It means the changes
immediately visible in the app itself. It is a very handy feature, which allows the
developer to fix the bugs instantly.
Accessible Native Features and SDKs: This feature allows the app development
process easy and delightful through Flutter's native code, third-party integration,
and platform APIs. Thus, we can easily access the SDKs on both platforms.
10
ADVANTAGES:
It makes the app development process extremely fast because of the hot-
reload feature. This feature allows us to change or update the code are
reflected as soon as the alterations are made.
It provides the smoother and seamless scrolling experiences of using the
app without much hangs or cuts, which makes running applications faster in
comparison to other mobile app development frameworks.
Flutter reduces the time and efforts of testing. As we know, flutter apps are
cross-platform so that testers do not always need to run the same set of tests
on different platforms for the same app.
It has an excellent user interface because it uses a design-centric widget,
high-development tools, advanced APIs, and many more features.
It is similar to a reactive framework where the developers do not need to
update the UI content manually.
11
CHAPTER 6
SYSTEM FEASIBILITY
This study is carried out to check the technical feasibility, that is, the
technical requirements of the system. Any system development must not have a
high demand on the available technical resources. This will lead to high
demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this
system.
This study is carried out to check the economic impact that the system
will have on the organization. The amount of funds that the company can pour
into the research and development of the system is limited. The expenditures
must be justified. Thus the developed system as well within the budget and this
was achieved because most of the technologies used are freely available.
12
CHAPTER 7
SYSTEM DESIGN AND DEVELOPMENT
The IoT based home automation system consists of two main components:
the hardware and the software. The hardware component includes the ESP8266
microcontroller, the relay board, and the connected home appliances. The
software component includes the smartphone application developed using the
Flutter framework.
SYSTEM DESIGN:
The hardware design involves connecting the ESP8266 microcontroller to
the relay board and then connecting the relay board to the home appliances. The
microcontroller is programmed to receive commands from the smartphone
application and control the relay board accordingly, which in turn controls the
home appliances.
SYSTEM DEVELOPMENT:
Once the hardware and software components are developed, the system is
tested to ensure that it is functioning as intended. Any bugs or issues are identified
and addressed, and the system is refined until it is stable and reliable.Looking at
the current situation we can build cross platform system that can be deployed on
various platforms like iOS, Windows. Limitation to control only several devices
can be removed by extending automation of all other home appliances.
In summary, the design and development of the IoT based home automation
system involves integrating the hardware and software components to create a
scalable and easy-to-use system for controlling home appliances. The system is
designed to be modular, allowing for easy maintenance and future enhancements.
14
CHAPTER 8
TESTING
System testing involves testing the system as a whole to ensure that it meets
the requirements of the user. For the IoT based home automation system, system
testing would involve testing the system's functionality and usability. The
15
application would be tested to ensure that it is user-friendly and easy to use, and
the system as a whole would be tested to ensure that it can control the connected
home appliances as intended.
OTHER TESTING:
Other types of testing that can be performed on the IoT based home
automation system include performance testing, security testing, and compatibility
testing. Performance testing involves testing the system's performance under
different loads and conditions. Security testing involves testing the system's
security measures to ensure that it is protected from unauthorized access.
Compatibility testing involves testing the system's compatibility with different
devices.
16
CHAPTER 9
CONCLUSION
17
CHAPTER 10
APPENDIX
MAIN PAGE:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smart_castle/screens/HomeScreen.dart';
import 'package:smart_castle/screens/login.dart';
import 'package:hexcolor/hexcolor.dart';
void main() {
runApp(const MyApp());
}
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Scaffold(
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(begin: Alignment.bottomCenter,end:
Alignment.topCenter,colors: [
HexColor("#000f70"),
HexColor("#5678b1")
])
),
child: Center(
child: Image(image: AssetImage("assets/images/smart_castle.png"),height:
height*.20,width: width*.40,),
),
),
);
}
}
20
LOGIN PAGE:
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smart_castle/screens/AboutScreen.dart';
import '../datas/Response.dart';
import 'HomeScreen.dart';
import 'NewAccount.dart';
27
HOME PAGE:
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'package:smart_castle/screens/HomeScreen.dart';
import 'AboutScreen.dart';
import 'ChangeDeviceNameScreen.dart';
class DeviceaListScreen extends StatefulWidget {
@override
dlistState createState() => dlistState();
}
class dlistState extends State<DeviceaListScreen> {
Future<String> changeValue(String port,String status) async {
if(status=="0")
status="1";
else
status="0";
final prefs = await SharedPreferences.getInstance();
var deviceId=await prefs.getString('id');
//replace your restFull API here.
String url =
"https://abcdefgzyxwvu.000webhostapp.com/api/onoffdevice.php?deviceId="+de
viceId!+"&port="+port+"&status="+status;
final response = await http.get(Uri.parse(url));
28
var responseData = jsonDecode(response.body) as Map<String, dynamic>;
//Response data=responseData;
//Creating a list to store input data;
print("Response" + responseData["message"]);
var s = responseData["message"];
print("ddd"+s);
setState(() {
print("Status : "+status);
fetchAlbum();
Navigator.pop(context);
});
return s;
}
Future<List<TransactionDetails>> fetchAlbum() async {
final prefs = await SharedPreferences.getInstance();
var id = await prefs.getString('id');
print(id);
final response = await http.get(Uri.parse(
"https://abcdefgzyxwvu.000webhostapp.com/api/devicedetails.php?deviceId=" +
id.toString()));
if (response.statusCode == 200) {
final List result = json.decode(response.body);
return result.map((e) => TransactionDetails.fromJson(e)).toList();
} else {
throw Exception('Failed to load data');
}
}
29
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
if (width > 800) width = width * 0.4;
double height = MediaQuery.of(context).size.height;
return Scaffold(
appBar: AppBar(
title: Text("Smart Castle"),
actions: [
IconButton(
icon: const Icon(Icons.info_outline_rounded),
tooltip: 'About this app',
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder:
(context)=>AboutScreen()));
},
),
],
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
width: width,
child: Column(children: [
SizedBox(
height: 20,
),
30
Container(
margin: EdgeInsets.symmetric(horizontal: 20),
child: Align(
alignment: Alignment.centerLeft,
child: Text("Your Appliances",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 30)),
),
),
SizedBox(
height: 20,
),
FutureBuilder<List<TransactionDetails>>(
future: fetchAlbum(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return new GestureDetector(
child: Container(
width: width,
margin: EdgeInsets.only(bottom: 15,left: 20,right: 20),
decoration: BoxDecoration(
color: HexColor("#000f70"),
borderRadius:
BorderRadius.circular(8)),
31
builder: (BuildContext context) {
return alert;
},
);
class TransactionDetails{
String? dName;
String? dValue;
String? port;
TransactionDetails({
this.dName,
this.dValue,
this.port,
});
32
BACK END:
PHP:
<?php
error_reporting(0);
$con=new
mysqli('localhost','id20411639_raja','F<s/YR(TCt4}0RCK','id20411639_smart_ca
stle');
$email=$_GET['email'];
$password=$_GET['password'];
$sql="select * from users where email='$email'";
$result=$con->query($sql);
if($email=="[email protected]"&&$password=="test@123"){
$response->message="4";
}
else{
if($result->num_rows>0){
$response->message="1";//1 for user found
33
$response->message="0";//Username not found
}
}
$encode=json_encode($response,JSON_PRETTY_PRINT);
header('Content-Type: application/json');
echo $encode;
?>
<?php
error_reporting(0);
$con=new
mysqli('localhost','id20411639_raja','F<s/YR(TCt4}0RCK','id20411639_smart_ca
stle');
$email=$_GET['email'];
$password=$_GET['password'];
//$sql="select * from users where username='$name' AND
password='$password'";
$sql="select * from users where email='$email'";
$result=$con->query($sql);
if($result->num_rows>0){
$response->message="0";//0 for already registered
}
else{
$sql="insert into users(email,password) values('$email','$password');";
if($con->query($sql)){
$response->message="1";//New user registered successfully
}
}
$encode=json_encode($response,JSON_PRETTY_PRINT);
header('Content-Type: application/json');
echo $encode;
34
?>
<?php
error_reporting(0);
$con=new
mysqli('localhost','id20411639_raja','F<s/YR(TCt4}0RCK','id20411639_smart_ca
stle');
$deviceId=$_GET['deviceId'];
$sql="select * from device_list where deviceId='$deviceId'";
$result=$con->query($sql);
$arr=array();
$count=0;
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
$obj=new stdClass();
$obj->port="1";
$obj->dName=$row["d1Name"];
$obj->dValue=$row["d1Value"];
$arr[0]=$obj;
$obj=new stdClass();
$obj->port="2";
$obj->dName=$row["d2Name"];
$obj->dValue=$row["d2Value"];
$arr[1]=$obj;
$obj=new stdClass();
$obj->port="3";
$obj->dName=$row["d3Name"];
$obj->dValue=$row["d3Value"];
$arr[2]=$obj;
$obj=new stdClass();
$obj->port="4";
35
$obj->dName=$row["d4Name"];
$obj->dValue=$row["d4Value"];
$arr[3]=$obj;
}
}
else{
$obj->d1Name=$row["No Data Found"];
$arr[$count]=$obj;
}
$encode=json_encode($arr,JSON_PRETTY_PRINT);
header('Content-Type: application/json');
echo $encode;
?>
<?php
header("Access-Control-Allow-Origin:*");
header("Content-Type:application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-
Headers, Authorization, X-Requested-With");
error_reporting(0);
$con=new
mysqli('localhost','id20411639_raja','F<s/YR(TCt4}0RCK','id20411639_smart_ca
stle');
$email=$_GET['email'];
$sql="select * from device_list where email='$email'";
$result=$con->query($sql);
$arr=array();
$count=0;
if($result->num_rows>0){
36
while($row=$result->fetch_assoc()){
$obj=new stdClass();
$obj->deviceId=$row["deviceId"];
$arr[$count]=$obj;
$count++;
}
}
else{
$obj->device=$row["No Data Found"];
$arr[$count]=$obj;
}
$encode=json_encode($arr,JSON_PRETTY_PRINT);
header('Content-Type: application/json');
echo $encode;
?>
37
A.2 SCREENSHOTS
INDEX PAGE
38
LOGIN PAGE
39
CREATE NEW ACCOUNT
40
ABOUT SMART CASTLE
41
WI-FI DEVICES
42
APPLIANCES
43
CHAPTER 11
REFERENCES
6. “A Low Cost Home Automation System Using Wi-Fi based Wireless Sensor
Network Incorporating Internet of Things”, by Vikram.N, Harish.K.S,
Nihaal.M.S, Raksha Umesh, Shetty Aashik Ashok Kumar; in 2017 IEEE 7th
International Advance Computing Conference.