0% found this document useful (0 votes)
75 views59 pages

Final PDF - To Be Hard Bind

The document describes a home automation project that allows users to control basic home functions like appliances and security through a mobile app from anywhere. It uses low-cost ESP8266 and Raspberry Pi Zero for wireless connectivity and control of devices. The project aims to save energy and provide better security through automated and remote control of devices over the internet.

Uploaded by

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

Final PDF - To Be Hard Bind

The document describes a home automation project that allows users to control basic home functions like appliances and security through a mobile app from anywhere. It uses low-cost ESP8266 and Raspberry Pi Zero for wireless connectivity and control of devices. The project aims to save energy and provide better security through automated and remote control of devices over the internet.

Uploaded by

Shobhit Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

PANSIM-SMARTFOX

Report submitted in partial fulfillment of the requirement for the degree of

B.Tech

in
Information Technology

Under the supervision

of

Dr. Pooja Mudgil


Assistant Professor

Information Technology

by

Shreya Bhardwaj (11620803120)


Harit Dheer (21020803120)
Archit Saxena (21220803120)

Department of Information Technology


Bhagwan Parshuram Institute of Technology
PSP-4, Sec-17, Rohini, Delhi-89

MAY 2024
DECLARATION

This is to certify that Report titled “Pansim-Smartfox”, is submitted by us in partial fulfillment of the
requirement for the award of degree of B.Tech in Information Technology to BPIT Rohini Delhi
affiliated to GGSIP University, Delhi. It comprises of our original work. The due acknowledgement has
been made in the report for using other’s work.

Date: 03/05/2024 Shreya Bhardwaj (11620803120)

Archit Saxena (21220803120)

Harit Dheer (21020803120)

ii
Certificate by Supervisor

This is to certify that Report titled “Pansim-Smartfox” is submitted by Harit Dheer (21020803120),
Archit Saxena (21220803120) and Shreya Bhardwaj (11620803120) in partial fulfillment of the
requirement for the award of degree of B.Tech in Information Technology to BPIT Rohini affiliated to
GGSIP University, Delhi. It is a record of the candidates own work carried out by them under my
supervision. The matter embodied in this Report is original and has not been submitted for the award of
any other degree.

Date: 03/05/2024 Dr. Pooja Mudgil

iii
Certificate by HOD

This is to certify that Report titled “Pansim-Smartfox” is submitted by Harit Dheer (21020803120),
Archit Saxena (21220803120) and Shreya Bhardwaj (11620803120), under the guidance of Prof.
Abhishek Swaroop in partial fulfillment of the requirement for the award of degree of B.Tech in
Information Technology to BPIT Rohini affiliated to GGSIP University, Delhi. The matter embodied in
this Report is original and has been dully approved for the submission.

Date: 03/05/2024 Prof. Abhishek Swaroop

iv
ACKNOWLEDGEMENT
We would like to thank each and every one who has helped us in any way in the completion of our
Summer Training Project. It would not have been possible without the support. I would especially
like to thank our mentor Mr. Abhishek Swaroop without whose guidance and support this project
would not have been possible.

Shreya Bhardwaj (11620803120)

Archit Saxena (21220803120)

Harit Dheer (21020803120)

v
LIST OF FIGURES

Figure No. Figure Title Page No.


2.1 The Secure Home Automation System Preview 14
3.1 A home automated app overview 16
3.2 A remotely controlled home automation 17
4.1 4-channel relay 25
4.2 Smart switch with DC converter 26
4.3 ESP-32 kit 27
4.4 Use Case Diagram 28
4.5 E-R Diagram 28
4.6 Initial Stage 31
4.7 First Stage 32
4.8 Second Stage 32
4.9 Third Stage 32
4.10 Forth Stage 33
4.11 Last Stage 34
4.12 A mobile app stage 34
4.13 0-level Data Flow Diagram 35
4.14 1-level Data Flow Diagram 35
4.15 2-level Data Flow Diagram 35
5.1 A home automated app overview 39
6.1 The splash screen of the Pansim Smartfox App 43
6.2 Login Page of the Pansim Smartfox App 43
6.3 Home Page of the Pansim Smartfox App 44
6.4 The Switches Page of the Pansim Smartfox App 44

LIST OF TABLES

Table No. Table Title Page No.


3.1 Our Proposed objective of system 22
4.1 Overall Flow Timeline 30
4.2 IP-based Scanner Timeline 30
4.3 Smart-Switch Timeline 31

vi
Contents
Page No.
Acknowledgement v
List Of Figures vi
List Of Table vi
Chapter 1 INTRODUCTION 8
1.1 Introduction to Home Automation System 8
Chapter 2 RELATED WORK 11
Chapter 3 PROBLEM STATEMENT 15
3.1 Motivation 15
3.2 Problem Statement 17
3.3 Objectives 20
Chapter 4 SYSTEM ANALYSIS AND DESIGN 23
4.1 Software Requirements Specifications 23
4.2 Use Case Diagrams 28
4.3 Activity/Flow Diagrams 30
Chapter 5 PROPOSED WORK 36
5.1 Overview 36
5.2 BLE Communication Protocol 36
5.3 ESP32 Integration and Firebase 37
5.4 Switch Control Algorithm 37
5.5 User Interface Design 38
5.6 Security and Privacy Measures 38
Chapter 6 IMPLEMENTATION/RESULTS 40
6.1 System Implementation 40
6.2 Experimental Setup 40
6.3 Results and Observations 41
6.4 Performance Analysis 41
6.5 Scalability and Robustness 42
6.6 Screenshots 42
Chapter 7 CONCLUSION AND FUTURE WORK 45
7.1 Conclusion 45
7.2 Contributions and Implications 45
7.3 Future work 46
7.4 Benefits of project 46
7.5 Limitations and challenges 49
7.6 Summary 50
REFERENCES 51
APPENDIX 52

vii
ABSTRACT

We live in an exciting time where more and more everyday items “things” are becoming smart! “Things”
have sensors and can communicate with other “things” and can provide control to more “things”. The
Internet of Things, IoT, is upon us in a huge way and people are rapidly inventing new gadgets that
enhance our lives. The price of microcontrollers with the ability to talk over a network keeps dropping and
developers can now think and build things inexpensively.
This IoT based home automation project is done using low-cost custom build ESP8266 WiFi Module, and
Raspberry pi zero. A system that uses mobile app to control basic home functions and features
automatically through internet from anywhere around the world, an automated home is sometimes called a
smart home. It is meant to save the electric power and provide better security service. The home
automation system differs from other systems by allowing the user to operate the system from anywhere
around the world through internet connection without breaking any convention usability.
This project provides significant electric power saving solution at homes and at the offices with help of
dynamic control of electric supply over internet using smart switch, and another is a low- cost wireless
plug and use surveillance system with live streaming over internet connection and in-build video storage
capacity.
Project contains both hardware and software development where hardware program is built using C and
python language on Arduino IDE, whereas mobile application is built using Flutter, Android studio.

viii
CHAPTER-1
INTRODUCTION
1.1 Introduction to Home Automation System

Home monitoring system and control system are a device that is implemented using Internet
of Things. The Internet of Things is the inter-networking of physical devices, vehicles,
buildings, and other items embedded with electronics, software, sensors, actuators, and
network connectivity that enable these objects to collect and exchange data. The home
monitoring system monitors doors and windows of your home and notifies you of any new
access of your property via a data feed. Home monitoring system consists of sensors to detect
intrusion and captures and sends multiple pictures of the intruder to the user anywhere
through Internet. The system is implemented via the use of IOT, which is the interconnection
of machines via Internet for advanced connectivity. This paper presents a low cost and
flexible le home control and monitoring system using an embedded micro-web server, with
IP connectivity for accessing and controlling devices and appliances remotely. The proposed
system does not require a dedicated server PC with respect to similar systems and offers a
novel communication protocol to monitor and control the home environment with more than
just the switching functionality Home automation is the control of any or all electrical devices
in our home or office. There are many different types of home automation system available.
These systems are typically designed and purchased for different purposes. In fact, one of the
major problems in the area is that these different systems are neither interoperable nor
interconnected. There are number of issues involve when designing a home automation
system. It should also provide a user-friendly interface on the host side, so that the devices
can be easily setup, monitored and controlled. In smart home systems, the internet is also use
to ensure remote control. For years, the internet has been widely used for the processes such
as surfing on the pages, searching information, chatting, downloading and installation. By the
rapid developments of new technologies, monitoring, controlling services have been started
to be served along with internet as an instrument providing interaction with machinery and
devices. The system can be use in several places like banks, hospital, labs and other
sophisticated automated system, which dramatically reduced the hazards of unauthorized
entry. The main reason to develop this system is to save time and man power along with
maintaining security and convenience.
The world has seen tremendous growth in telecom technology during the last decade.

9
As a result of this, a multitude of new applications of the Information & Communication
Technologies have emerged and changed the way we live, work, play, interact and even
think. This has created a lot of momentum in many spheres that impact our lives. Latest trend
is Machine-to-Machine (M2M) communication / Internet of Things (IoT) which has led to a
new world of possibilities and opportunities. Smart Home is one of the focus areas in this
initiative as is evident from the large number of IoT / M2M enabled nodes being created for
this sector. While ‘Smart’ inherently means ‘connected’ in IoT world, Smart Homes could
have multiple meanings for different people and even different situations. A Smart Home is a
user’s private space and each user may have different needs. The users spend a significant
amount of time at their homes and may have different expectations depending on their
background, taste, affordability and availability of common services. A Smart Home is an
aggregation of all the needs of its occupants while they are inside and also when they are not.
Remote control, Security, surveillance, remote monitoring of premises including monitoring
those who are sick, young, elderly, etc. are all requirements of users. In This document of
Telecom Engineering Centre describes M2M/IoT Enablement in Homes to consider the
diverse needs of users as stated in previous paragraphs. It introduces the subject with brief
illustration of M2M communication and its framework for Smart Homes. The report
identifies key challenges: lack of standards and non-availability of high speed and reliable
Internet services, indigenous manufacturing, etc. Standards will allow for a level playing field
for all participants that will benefit the customers. In the end, way forward has been
suggested wherein action points on various aspects like adoption of standards, development
of devices, certification mechanism etc. have been brought out. It may be mentioned here that
the needs relevant to individual apartments, homes, and small establishments like shops or
small-scale industries operating from small buildings are covered in this document.

10
Chapter 2
RELATED WORK

1. Home Automation Systems

Home automation, driven by the advancements in IoT technologies, has transformed the way
we interact with our living spaces. From controlling lights and thermostats remotely to
automating security systems, home automation systems offer convenience, comfort, and
energy efficiency. Various hardware platforms and communication protocols are employed in
these systems to cater to diverse user needs.

In recent years, the proliferation of smart devices and interconnected ecosystems has
accelerated the adoption of home automation. Consumers now have access to a wide range of
products and solutions designed to make their homes smarter and more responsive to their
needs.

2. ESP SmartFox

ESP SmartFox emerges as a pivotal IoT framework developed by Espressif Systems, offering
a robust foundation for building sophisticated IoT applications using ESP32 and ESP8266
microcontrollers. With its rich set of tools and APIs, ESP SmartFox simplifies device
provisioning, facilitates seamless cloud connectivity, and enables remote device management.
Moreover, its support for multiple communication protocols, including Wi-Fi, Bluetooth, and
MQTT, underscores its versatility across various IoT use cases.

The architecture of ESP SmartFox ensures scalability and interoperability, allowing


developers to create interconnected ecosystems of smart devices that seamlessly interact with
each other and with cloud-based services. This flexibility makes ESP SmartFox an ideal
choice for developers and enthusiasts looking to build innovative and feature-rich IoT
solutions.

3. Existing Home Automation Solutions

The integration of ESP SmartFox into existing home automation solutions has unlocked a
myriad of possibilities for seamless device integration and enhanced functionality.
Leveraging the capabilities of ESP32 and ESP8266 microcontrollers, these solutions offer

11
advanced features such as remote device monitoring and control, energy management, and
integration with popular voice assistants like Amazon Alexa and Google Assistant.

Notable examples of existing home automation solutions that harness the power of ESP
SmartFox include:

• Tasmota: An open-source firmware known for its MQTT-based control and


compatibility with a wide range of ESP8266 and ESP32 based devices. Tasmota
enables seamless integration with popular home automation platforms such as Home
Assistant and OpenHAB, empowering users with flexible and customizable control
over their smart devices.

• Home Assistant: A leading open-source home automation platform renowned for its
extensive compatibility with IoT devices. Through native integration with ESP
SmartFox or MQTT, Home Assistant provides users with a unified interface to
manage and automate their smart home devices effortlessly.

• Node-RED: A versatile flow-based programming tool that enables users to create


custom automation flows for ESP SmartFox devices. Node-RED's visual
programming interface simplifies the creation of complex automation scenarios and
facilitates seamless integration with third-party services, enhancing the functionality
and interoperability of ESP SmartFox-based systems.

These solutions exemplify the synergy between ESP SmartFox and existing home
automation platforms, offering users unparalleled flexibility and control over their
smart home environments.

4. Research and Development

The research and development efforts surrounding ESP SmartFox have focused on exploring
its potential in various home automation applications and addressing key challenges related to
energy efficiency, security, and scalability. By conducting empirical studies and developing
innovative solutions, researchers have contributed to the ongoing evolution and improvement
of the ESP SmartFox framework.

Studies on energy-efficient scheduling algorithms, secure communication protocols, and


scalable device provisioning techniques have yielded valuable insights into optimizing the
performance and reliability of ESP SmartFox-based systems. These findings not only

12
enhance the usability and effectiveness of ESP SmartFox in real-world deployments but also
pave the way for future innovations in the field of home automation.

5. Commercial Home Automation Products

Commercial home automation products and solutions leveraging ESP SmartFox have
proliferated in the market, offering consumers a diverse array of smart home experiences.
These products boast plug-and-play functionality, allowing users to effortlessly set up and
configure their smart devices using intuitive mobile applications or web interfaces.

Integration with cloud-based services further enhances the accessibility and convenience of
these products, enabling users to remotely monitor and control their home automation
systems from anywhere in the world. Whether it's managing household appliances,
optimizing energy usage, or enhancing home security, commercial home automation products
powered by ESP SmartFox deliver unparalleled versatility and reliability.

The increasing demand for convenience, energy efficiency, and enhanced security in
residential spaces underscores the need for advanced home automation solutions. Traditional
manual controls and disjointed systems lack the ability to provide centralized, intuitive
management of home environments. Such a system must also offer remote access
capabilities, ensuring homeowners can manage and monitor their properties from any
location.
6. Integration with Internet of Things (IoT):

Many recent home automation systems are deeply integrated with IoT technologies, allowing
for enhanced connectivity and smarter management of household devices. This integration
enables systems to control lighting, climate, entertainment systems, and security features
through simple user interfaces on smartphones or voice commands. The work in this area
focuses on improving user interaction and ensuring seamless connectivity among devices
from different manufacturers.
7. Energy Efficiency and Management:

Home automation systems are increasingly designed to promote energy efficiency, utilizing
sensors and smart algorithms to optimize the consumption of resources like electricity and
water. These systems can adapt to user behaviors and environmental conditions to minimize
waste. For example, smart thermostats adjust heating and cooling based on occupancy and
weather predictions, while smart lighting systems adjust brightness according to the time of

13
day and presence of natural light.
8. Security and Privacy Enhancements:

As the home automation industry grows, so does the concern for security and privacy.
Significant research and development work is dedicated to safeguarding these systems from
unauthorized access and cyber threats. This includes the use of advanced encryption methods,
secure communication protocols, and regular software updates to handle vulnerabilities.
Additionally, there is an emphasis on user privacy, with systems designed to perform
effectively without intruding on personal spaces or storing sensitive information without
consent.

Fig 2.1 The Secure Home Automation System Preview

14
CHAPTER 3
PROBLEM STATEMENT

3.1 Motivation

The rapid advancement of Internet of Things (IoT) technologies has revolutionized various
aspects of our lives, with home automation emerging as a prominent application domain. The
integration of smart devices and interconnected systems has enabled homeowners to remotely
monitor, control, and automate their living spaces, offering unprecedented convenience,
comfort, and energy efficiency.

Despite the growing popularity of home automation solutions, several challenges persist in
the current landscape. Traditional home automation systems often suffer from fragmentation,
compatibility issues, and complex setup procedures, hindering widespread adoption and
usability. Moreover, the lack of standardized frameworks and protocols poses barriers to
interoperability and scalability, limiting the seamless integration of diverse smart devices into
cohesive ecosystems.

In this context, the motivation behind our project lies in addressing these challenges and
advancing the state-of-the-art in-home automation through the utilization of ESP RainMaker,
an innovative IoT framework developed by Espressif Systems. By harnessing the capabilities
of ESP32 and ESP8266 microcontrollers, ESP RainMaker offers a comprehensive suite of
tools and APIs for streamlined device provisioning, cloud connectivity, and remote
management.

Our project seeks to leverage the capabilities of ESP RainMaker to develop a robust and user-
friendly home automation solution that overcomes the limitations of existing systems. By
providing seamless integration with a wide range of smart devices and protocols, our solution
aims to empower homeowners with greater control, flexibility, and customization options for
managing their smart home environments.

Furthermore, our project aligns with the broader objectives of advancing IoT research and
development, contributing to the ongoing evolution of ESP RainMaker and promoting its
adoption in real-world applications. Through empirical studies, experimentation, and
validation, we aim to demonstrate the effectiveness and practicality of ESP RainMaker in
addressing the challenges of home automation and enhancing the overall user experience.

15
In summary, the motivation behind our project stems from the pressing need to overcome the
limitations of existing home automation solutions and leverage the capabilities of ESP
RainMaker to create a more seamless, interoperable, and user-centric smart home experience.

Fig 3.1 A home automated app overview

Harness the power of technology to transform your living space into a smarter, more efficient
home. Embrace the innovation of home automation to enhance comfort, security, and energy
management. Dive into creating a connected environment where convenience and control are
at your fingertips.

16
3.2 Problem Statement

Home automation, also known as a smart home, is a significant innovation brought about by
the ongoing industrial revolution. It is reshaping the residential landscape by providing
enhanced control over home environments, optimizing comfort, convenience, and energy
efficiency. As people spend a substantial amount of their time at home, the importance of
integrating technology to enhance this experience cannot be overstated. Despite the
availability of various smart home designs and control systems, these can broadly be
classified into two categories: local control systems and remotely controlled systems. This
document expands upon these systems, detailing their functions, the challenges they face, and
areas needing improvement.

Fig 3.2 A remotely controlled home automation

17
Detailed Description of Control Systems:

1. Local Control Systems:


Local control systems utilize in-home controllers, which may be either stationary or equipped
with wireless communication technologies. These systems connect to a central hub or
gateway within the home, allowing users to manage devices through physical or local digital
interfaces.

Enhanced privacy, as data does not typically leave the local network.

Less reliance on external networks means fewer disruptions due to connectivity issues.

Limited control when the user is away from home.

Potentially complex setup and maintenance for non-technical users.

2. Remotely Controlled Systems:


These systems allow for remote operation via the internet, enabling users to control their
home environment from any location using mobile devices or computers.

Greater flexibility and convenience in monitoring and controlling home functions from long
distances.

Ideal for users with frequent travel demands.

Dependence on stable internet service can render systems inoperative during outages.

3. Security and Privacy:


Both types of systems are susceptible to security vulnerabilities, though remotely controlled
systems face greater risks due to their connectivity to the internet.

Privacy concerns arise from the potential for unauthorized access and data breaches, which
could expose sensitive user information.

4. Interoperability:
The lack of standard protocols and interfaces between devices from different manufacturers
complicates the integration of new devices into existing systems.

5. Cost Implications:
The economic impact of installing and maintaining smart home technologies can be
significant, potentially limiting their adoption to higher-income households.

18
6. Technical Complexity:
The need for technical knowledge to install, configure, and troubleshoot smart home systems
can deter average users, impacting the usability and overall user experience.

7. Reliability and Dependency:


Systems, especially those controlled remotely, rely heavily on continuous and reliable
internet connectivity, highlighting a dependency that may not be sustainable in all geographic
or economic conditions.

8. Regulatory and Standardization Issues:


The lack of standardized regulations across different regions and countries can complicate the
distribution and operational compliance of home automation systems. Varied requirements
for wireless communications, data security, and device interoperability pose barriers to
seamless global deployment.

Establishing universal standards and regulatory guidelines for home automation technologies
would streamline development, enhance system compatibility, and foster global market
growth.

9. Technological Advances and Innovations:


The pace of technological change can render home automation systems quickly outdated.
Users may hesitate to invest in technology that could be superseded in a short time, leading to
reluctance in adopting current systems.

Continuous innovation in the field, including the integration of AI and machine learning, can
lead to more intelligent and self-updating home automation systems. These advancements
could make systems more intuitive and capable of anticipating user needs, thereby enhancing
user experience and system utility.

19
3.3 Objectives

The objectives of a home automation system typically revolve around enhancing the
convenience, efficiency, safety, and manageability of residential environments. Here’s a
detailed list of such objectives:

1. Increase Convenience and Comfort:

• To automate routine household tasks, like adjusting thermostats, turning lights


on or off, and managing appliances, to make everyday life more convenient.

• To allow users to control their home environments remotely using mobile


devices or voice commands, enhancing ease of use and accessibility.

2. Enhance Home Security:

• To improve home security by integrating advanced monitoring and


surveillance systems, including motion sensors, cameras, and automated
alarms.

• To enable real-time alerts and remote monitoring capabilities for homeowners,


allowing them to respond quickly to security breaches or emergencies.

3. Optimize Energy Management:

• To reduce energy consumption and lower utility costs by efficiently managing


resources like heating, cooling, and lighting based on usage patterns and
environmental data.

• To integrate sustainable technologies, such as solar panels and energy storage


systems, into the home automation system to promote greener living.

4. Improve Safety:

• To incorporate safety features that detect potential hazards, such as smoke,


fire, water leaks, or gas leaks, providing early warnings and automatic shut-off
capabilities.

• To enhance the safety of vulnerable groups (like the elderly or those with
disabilities) through automated systems that assist in daily activities and alert
caregivers in case of an emergency.

20
5. Ensure Scalability and Flexibility:

• To design systems that are easily scalable and adaptable to accommodate


additional devices or functionalities as technology advances or user needs
change.

• To support a wide range of devices and platforms, ensuring compatibility


across different manufacturers and systems.

6. Enhance System Reliability and Maintainability:

• To ensure the system operates reliably under various conditions and minimizes
downtime through robust design and fail-safe operations.

• To make systems easy to maintain and update, including simple interfaces for
troubleshooting and configuring settings.

7. Promote User-Friendly Interaction:

• To develop intuitive interfaces that all household members can use with
minimal training, including children and the elderly.

• To offer customization options that let users tailor the system to their personal
preferences and lifestyle.

8. Facilitate Remote Health Monitoring and Assistance:


• To integrate health monitoring devices within the home automation system to
assist in tracking health metrics such as heart rate, blood pressure, and sleep
patterns, particularly beneficial for elderly or individuals with chronic
conditions.
• Provides real-time data to residents and healthcare providers, enabling prompt
responses to health emergencies. Enhances the capability of the home to
support telemedicine consultations and remote care, thus extending the safety
and well-being of residents within their homes.

9. Integrate with Electric Vehicle (EV) Charging Systems:


• To incorporate smart management of electric vehicle charging stations within
the home automation system, optimizing energy .

21
• Supports the growing adoption of electric vehicles by providing convenient,
efficient, and intelligent charging solutions at home. Facilitates energy
management by leveraging non-peak hours for charging, which can
significantly reduce electricity costs and strain on the grid during high-demand
periods.

Table 3.1 Our Proposed objective of system

22
CHAPTER 4
SYSTEM ANALYSIS AND DESIGN

4.1 SOFTWARE REQUIREMENTS SPECIFICATIONS

4.1.1 Software Requirements Overview:

1. Custom IoT Device Management Application:

• Develops a proprietary application for streamlining the onboarding and


configuration processes of ESP32 IoT devices.

• Empowers users with an intuitive interface for effortless device setup and
management.

• Enables seamless integration with various IoT devices and sensors, enhancing
versatility.

2. Remote Device Administration and Real-Time Monitoring:

• Incorporates features for remote device management and real-time monitoring


via smartphones or web interfaces.

• Allows users to remotely monitor device status, sensor data, and performance
metrics in real-time.

• Facilitates proactive troubleshooting and maintenance, ensuring optimal


device functionality.

3. OTA Firmware Update Integration:

• Implements Over-The-Air (OTA) firmware update functionality for ESP32


devices.

• Enables users to remotely update device firmware without physical access,


enhancing convenience and scalability.

• Ensures security and reliability during firmware updates through robust


authentication and validation mechanisms.

23
4. Custom Arduino Programming Support for ESP32:

• Integrates support for Arduino programming environment tailored to ESP32


development.

• Offers a familiar and user-friendly interface through the Arduino IDE,


simplifying code development and debugging.

• Expands Arduino libraries and functionalities to accommodate the unique


capabilities of ESP32 hardware.

5. IoT Application Prototyping Acceleration:

• Accelerates the prototyping of IoT applications on ESP32 hardware through


optimized development workflows.

• Provides comprehensive support for peripherals, sensors, and communication


protocols required for IoT applications.

• Facilitates rapid iteration and experimentation, reducing time-to-market for


IoT solutions.

24
4.1.2 Hardware Requirements Overview

1. 5 Volt 4-Channel Relay: This electromechanical switch serves as a pivotal


component in the system, allowing for the control of various household appliances. By
utilizing a small amount of current to control a larger flow of current, the relay effectively
manages the power supply to connected devices, enabling remote operation and automation.

Fig 4.2 4-channel relay

2. 220V AC to 5V DC Converter: Acting as the power hub of the system, this


converter transforms the standard alternating current (AC) from household outlets into the
direct current (DC) required to power sensitive electronic components like the ESP32
microcontroller and other low-voltage elements. Its efficient conversion process ensures
stable and reliable power delivery to the entire system.

25
Fig 4.3 Smart Switch with DC converter

3. LEDs: These light-emitting diodes play a crucial role in providing visual feedback to
users regarding the status of the connected appliances. Through their illumination, users can
easily discern whether a particular appliance is powered on or off, enhancing usability and
user experience.

4. Screw Terminal: Serving as the nexus for electrical connections, the screw terminal
facilitates secure and robust attachment of wires from the ESP32 microcontroller, relay, and
appliance circuits. Its user-friendly design simplifies installation and maintenance tasks,
ensuring dependable connectivity throughout the system.

5. ESP32: As the brain of the system, the ESP32 microcontroller orchestrates the entire
operation by managing communication protocols such as Wi-Fi and Bluetooth, as well as
executing commands for device control. Its versatile capabilities enable seamless integration
with various IoT applications, making it an ideal choice for smart home automation projects.

26
Fig 4.4 ESP-32 kit

6. Transistors (BC547): These semiconductor devices act as electronic switches,


enabling the ESP32 microcontroller to control the activation and deactivation of the relay. By
modulating the current flow through the relay's coil, the transistors enable precise and
efficient management of appliance power, enhancing energy efficiency and system
responsiveness.

7. Diodes (4007): Incorporated into the circuitry for protection purposes, these diodes
safeguard sensitive components against voltage spikes and reverse current, mitigating the risk
of damage or malfunction. Their role in ensuring circuit integrity is essential for the long-
term reliability of the system.

8. Wires: Serving as the conduits for electrical signals and power distribution, wires
establish the necessary connections between system components, enabling seamless
communication and functionality. Their quality and configuration directly impact the
performance and safety of the overall system architecture.

9. 220-ohm Resistance: By limiting the current flow through the LEDs, these resistors
protect the diodes from potential damage caused by excessive current draw, prolonging their
operational lifespan and maintaining consistent luminosity for visual indication purposes.

10. 100k Quarter Watt Resistance: This resistor component is employed to fine-tune
circuit parameters such as voltage levels or current thresholds, ensuring optimal performance
and stability across different operating conditions. Its inclusion enhances the adaptability and
versatility of the system design.

27
11. Female Berg Pin: Providing a standardized interface for connecting external
devices to the ESP32 microcontroller, the female Berg pin facilitates seamless integration and
interoperability within the system architecture. Its compatibility with a wide range of
peripherals enhances the expandability and versatility of the overall system.

12. 4-Pin Connector: Employed to establish reliable connections between various


modules or subsystems within the system, the 4-pin connector enhances modularity and ease
of assembly. Its robust design ensures secure interconnection, facilitating efficient installation
and maintenance workflows.

4.2 Use Case Diagrams & ER- Diagram

A use case diagram for a home automation system visually represents the interactions
between users (actors) and the system, showcasing specific functionalities or actions users
can perform. Actors, such as homeowners or guests, are depicted alongside use cases, which
represent tasks like controlling lights or adjusting the thermostat. Relationships between
actors and use cases illustrate who can perform which actions within the system. The system
boundary encloses all actors and use cases, delineating the scope of the home automation
system. Overall, the diagram provides a clear overview of user interactions and system
functionalities, aiding stakeholders in understanding the system's behaviour and
requirements.

A use case diagram for a home automation system serves as a visual representation of how
users and the system interact to achieve specific tasks or functionalities. Actors, representing
users or external systems, are depicted alongside use cases, which outline actions such as
controlling devices or setting schedules. Relationships between actors and use cases illustrate
the roles users play in the system and the tasks they can perform. The system boundary
defines the scope of the home automation system, clarifying its interactions with external
entities. Through this diagram, stakeholders gain insights into the system's functionality, user
roles, and interactions, facilitating the understanding of requirements and system behaviour.

28
Fig 4.5 Use Case Diagram

Fig 4.6 E-R Diagram

29
4.3 Activity/Flow Diagrams

4.3.1 Overall Flow Timeline

Table 4.1 Overall Flow Timeline

Phase -1 - Development of IP-based Scanner Cam. This development was chosen at first
because it required low amount of time for research to analysis and select perfect hardware
which is highly efficient and robust in design as it was used as plug and play. Total three
Iterative cycles were required to refine the device in to perfect working condition

Table 4.2 IP-based Scanner Cam Timeline

30
Phase -2 - Development of Smart-Switch. This development was chosen at second because
it required high amount of time to develop due to two different platform. Total six Iterative
cycles were required to refine the device in to perfect working condition.

Table 4.3 Smart-switch Timeline

4.3.2 Overall Activity Diagrams


Initial case - Smart-switch is connected to web server using local Wi-Fi network over
internet. And mobile application can be connected to switch and set server through
local Wi-Fi network or over GSM internet connect as shown in Fig 4.6.

Fig 4.6 Initial Stage

31
1st Case - when switch is turn on manually. Switch send request to server and
update thestatus; web server also update status of mobile app by sending back request
to mobile application.same process also repeats for turn off request.

Fig 4.7 First Stage

2nd Case - when switch is turn on from mobile app when switch is in same Wi-Fi network. Mobile
app send direct request to smart switch and update status, same request is alsosent to server.

Fig 4.8 Second Stage

3rd Case - when switch is turn on from mobile app when connect over internet. Mobile app
sent request to web server and Switch get update from web server.

32
Fig 4.9 Third Stage

4th Case - When Switch is turn on from mobile app when to internet services off-line and
mobile is connected to same network.

Fig 4.10 Fourth Stage

Last Case - When smart switch is off line. Even then switch can be turn on and off manually

33
Fig 4.11 Last Stage

Mobile application flow and development.

Fig 4.12 A mobile app stage

34
Fig 4.13 0-level Data Flow Diagram

Fig 4.14 1-level Data Flow Diagram

Fig 4.14 2-level Data Flow Diagram

35
CHAPTER 5
PROPOSED WORK

5.1 Overview

The proposed work heralds a new era in home automation, pushing boundaries to deliver an
unprecedented user experience. This project represents a fusion of state-of-the-art technologies,
blending Bluetooth Low Energy (BLE), Flutter application development, and Firebase
integration into a cohesive ecosystem for controlling household appliances. By harnessing
these cutting-edge tools, our goal is to redefine how users interact with their homes, offering
unparalleled convenience, efficiency, and customization. Through meticulous design and
implementation, we aim to empower users with unparalleled control over their smart devices,
revolutionizing their daily routines and elevating their quality of life.

Our vision is not just about automating tasks but creating an intuitive and seamless
environment where technology seamlessly integrates into everyday life. By leveraging BLE,
Flutter, and Firebase, we strive to create a harmonious ecosystem that adapts to users' needs,
providing them with a personalized and effortless living experience.

5.2 BLE Communication Protocol

Central to our project is the development of a robust BLE communication protocol, designed to
ensure seamless connectivity between the user's device and the home automation system. This
protocol acts as the backbone of the system, facilitating secure and efficient data exchange in
real-time. Through BLE, the Flutter application establishes a secure connection with the ESP32
microcontroller, enabling bidirectional communication for transmitting crucial information
such as Wi-Fi credentials and Firebase authentication tokens. This integration of BLE
technology guarantees responsive and reliable communication, laying the groundwork for a
seamless user experience.

Expanding on the BLE communication protocol involves delving into its technical intricacies,
such as data packet structure, error handling mechanisms, and encryption protocols. By
elaborating on these aspects, we can provide a comprehensive understanding of how BLE
facilitates seamless interaction between the user's device and the home automation system.

36
Once the BLE connection is established, the Flutter application transmits crucial network
credentials, including Wi-Fi SSID and password, as well as Firebase authentication tokens, to
the ESP32 microcontroller. This data transmission process is securely encrypted to prevent
unauthorized access and ensure the integrity of sensitive information. By providing the
necessary credentials, users grant the ESP32 access to their local Wi-Fi network and Firebase
Realtime Database, enabling seamless interaction between the home automation system and
external services.

5.3 ESP32 Integration with Firebase

A highlight of our project is the seamless integration of the ESP32 microcontroller with the
Firebase Realtime Database, a cloud-based platform that facilitates real-time data
synchronization and manipulation. By leveraging Firebase's robust infrastructure, the ESP32
establishes a secure connection to the cloud, enabling bidirectional communication with the
Firebase Realtime Database. This integration empowers our home automation system to store
and retrieve appliance status updates, user preferences, and other relevant information in real-
time, ensuring seamless coordination between hardware and software components. Harnessing
the power of Firebase enhances the scalability, reliability, and interoperability of our system,
paving the way for a more connected and intelligent home environment.

Expanding on ESP32 integration with Firebase involves discussing authentication mechanisms,


data synchronization protocols, and error handling strategies. By providing detailed insights
into these aspects, we can showcase the technical sophistication of our system and its ability to
leverage cloud-based services for enhanced functionality and performance.

5.4 Switch Control Algorithm

At the core of our project lies a sophisticated switch control algorithm implemented on the
ESP32 microcontroller. This algorithm serves as the brain of our home automation system,
interpreting user inputs from the Flutter application and translating them into actionable
commands for controlling connected appliances. Through iterative refinement and
optimization, the algorithm ensures responsive and efficient operation, enhancing user
satisfaction and convenience. Leveraging advanced control logic, the algorithm orchestrates the
activation or deactivation of the corresponding relays, thereby controlling the power supply to
associated appliances. This algorithmic prowess forms the backbone of our system's

37
functionality, enabling users to effortlessly control their appliances with precision and
reliability, thereby transforming the way they interact with their living spaces.

Expanding on the switch control algorithm involves discussing its architecture, decision-
making processes, and optimization techniques. By delving into these aspects, we can illustrate
the intricacies of our system's intelligence and its ability to adapt to user preferences and
environmental conditions.

5.5 User Interface Design

A crucial aspect of the proposed home automation system is its user interface design, which
plays a vital role in shaping the user experience. This section explores the principles and
methodologies behind the design of the Flutter application, focusing on usability, accessibility,
and aesthetics. Through intuitive interfaces and seamless navigation, users can effortlessly
control their smart home devices, monitor appliance status, and customize automation routines
to suit their preferences. By prioritizing user-centric design principles, we ensure that the home
automation system is accessible and intuitive for users of all ages and technical backgrounds,
enhancing convenience and usability in managing household tasks.

5.6 Security and Privacy Measures

Ensuring the security and privacy of user data is paramount in the design of the home
automation system. This section discusses the security measures and protocols implemented to
safeguard sensitive information and protect against potential threats. From encryption
algorithms and authentication mechanisms to access control policies and intrusion detection
systems, multiple layers of security are employed to mitigate risks and ensure data
confidentiality and integrity. By prioritizing security and privacy measures, we instill trust and
confidence in users, fostering adoption and acceptance of the home automation system in real-
world environments.

38
Fig 5.1 A home automated app overview

39
CHAPTER 6
IMPLEMENTATION/RESULTS

6.1 System Implementation

The practical implementation of our home automation system involved a meticulous blend of
hardware and software integration, culminating in a seamless user experience. On the hardware
side, we meticulously assembled a robust control circuit comprising the ESP32
microcontroller, relay modules, transistors, and other electronic components. Each component
was carefully selected and integrated to ensure compatibility, reliability, and efficiency. Factors
such as power requirements, signal compatibility, and form factor were given special
consideration to facilitate seamless integration with existing household infrastructure.

Simultaneously, the software component of our system was developed using the Flutter
framework, enabling the creation of a cross-platform application with an intuitive user
interface. The development process involved iterative refinement, with a focus on user
experience and functionality. Through seamless integration of hardware and software
components, our home automation system was brought to life, offering users unparalleled
control over their smart devices.

Expanding on the system implementation involves delving into the intricacies of hardware
assembly, software development methodologies, and integration challenges. By providing
detailed insights into each phase of the implementation process, we can offer a comprehensive
understanding of the effort and expertise required to bring our vision to fruition.

6.2 Experimental Setup

To evaluate the functionality and performance of our home automation system, an extensive
experimental setup was devised to simulate real-world usage scenarios. This setup
encompassed a diverse array of household appliances, including lights, fans, air conditioners,
and electronic devices, each interfaced with the ESP32 microcontroller via dedicated relay
modules. The Flutter application was deployed on compatible devices, enabling users to
remotely interact with the system.

40
The experimental setup was meticulously configured to replicate typical usage patterns and
environmental conditions, ensuring comprehensive testing of the system's capabilities. Factors
such as network latency, device compatibility, and power consumption were carefully
monitored and analysed throughout the testing phase.

Expanding on the experimental setup involves discussing the rationale behind appliance
selection, configuration procedures, and testing methodologies. By providing detailed insights
into the experimental setup, we can offer a transparent and reproducible framework for
evaluating our home automation system's performance.

6.3 Results and Observations

The results obtained from the experimental phase provide compelling evidence of the
effectiveness and reliability of our home automation system. Users were able to seamlessly
control connected appliances remotely, with minimal latency and near-instantaneous feedback
between user inputs and appliance responses. Observations regarding system responsiveness
underscored the fluid and intuitive user experience facilitated by our system.

Furthermore, the system's energy efficiency capabilities were evaluated, with promising results
indicating potential savings in electricity consumption and improved sustainability. Through
rigorous testing and analysis, we gained valuable insights into the system's reliability,
responsiveness, and overall user satisfaction.

Expanding on the results and observations involves discussing performance metrics, statistical
analysis, and user feedback. By providing a comprehensive overview of the experimental
findings, we can offer valuable insights into the real-world implications and benefits of our
home automation system.

6.4 Performance Analysis

In addition to presenting results and observations, a comprehensive performance analysis


provides deeper insights into the system's behaviour and capabilities. This section delves into
various performance metrics such as response time, throughput, and resource utilization,
offering quantitative assessments of the system's efficiency and reliability. By analysing
performance data collected during experimental trials, we identify bottlenecks, optimize
algorithms, and fine-tune parameters to enhance overall system performance.

41
6.5 Scalability and Robustness

As the home automation system evolves, scalability and robustness become critical
considerations to accommodate growing user demands and ensure continuous operation under
varying conditions. This section explores strategies for enhancing system scalability and
robustness, such as modular architecture design, fault tolerance mechanisms, and load
balancing techniques. By anticipating future scalability challenges and designing for robustness
from the outset, we lay the foundation for a system that can seamlessly adapt and scale to meet
evolving user needs and environmental conditions. Through comprehensive testing and
validation, we validate the system's scalability and robustness, ensuring its resilience and
reliability in the face of changing requirements and operating conditions.

6.6 Screenshots

Accompanying screenshots captured during the experimental phase offer visual evidence of our
home automation system in action. These screenshots showcase the intuitive interface of the
Flutter application, allowing users to effortlessly toggle switches and monitor appliance status
remotely. Additionally, screenshots of the Firebase Realtime Database interface demonstrate
the system's ability to synchronize appliance status updates in real-time, ensuring seamless
coordination between hardware and software components.

By providing a visual narrative of the system's functionality, these screenshots offer valuable
insights into the user experience and overall performance of our home automation system.
Furthermore, video recordings of the system in operation offer a dynamic perspective,
showcasing real-time interaction and demonstrating the system's capabilities in a variety of
usage scenarios.

Expanding on the screenshots involves providing detailed annotations and descriptions to


highlight key features and functionalities. By offering a visual walkthrough of the system's
interface and operation, we can enhance the reader's understanding and appreciation of our
home automation solution.

42
Fig 6.1 The splash screen of the Pansim Smartfox App Fig 6.2 Login Page of the Pansim Smartfox App

43
Fig 6.3 Home Page of the Pansim Smartfox App Fig 6.4 The Switches Page of the Pansim Smartfox App

44
CHAPTER 7
CONCLUSION AND FUTURE WORK

7.1 Conclusion

In conclusion, the successful implementation of our home automation system marks a


significant advancement in the domain of smart home technology. Through the seamless
integration of hardware and software components, we have created a platform that empowers
users with unparalleled control over their living spaces. This system enhances convenience,
efficiency, and overall quality of life, demonstrating its reliability, responsiveness, and energy
efficiency through meticulous design and testing. The integration of cutting-edge technologies
such as BLE, Flutter, and Firebase underscores its adaptability and scalability, promising a
more connected and intelligent home environment. Looking ahead, further advancements and
enhancements will build upon this foundation, unlocking new avenues for innovation and
improvement in home automation.

Expanding on the conclusion involves reflecting on the broader implications of our system's
successful implementation, such as its potential to transform daily routines, improve energy
management, and enhance overall well-being. By discussing specific examples and scenarios,
we can illustrate the tangible benefits and real-world impact of our home automation solution.

7.2 Contributions and Implications

Our home automation system makes significant contributions to the advancement of smart
home technologies, offering users a versatile and intuitive platform for managing household
appliances. Beyond its immediate benefits, the system has broader implications for energy
conservation, accessibility, and sustainability. Empowering users to make informed decisions
about energy usage and enhancing accessibility for individuals with disabilities or special
needs promotes inclusivity and environmental responsibility. Additionally, seamless
integration with external services such as Firebase opens up new possibilities for data-driven
insights and automation, enabling users to optimize their living spaces for comfort, efficiency,
and convenience.

45
By providing concrete examples, we can highlight the practical applications and societal
impact of our home automation solution.

7.3 Future Work

Looking ahead, several avenues for future research and development offer exciting
opportunities to enhance our home automation system. Integrating advanced machine learning
algorithms for predictive analytics and proactive automation could optimize energy usage and
enhance user comfort. Expanding support for voice recognition and natural language
processing would improve accessibility and usability, enabling intuitive interaction with smart
home devices. Additionally, exploring applications of emerging technologies like edge
computing and decentralized networks could enhance scalability, reliability, and security.

Expanding on future work involves discussing specific research directions and potential
innovations that could further enhance our home automation system. By outlining these
opportunities, we can inspire future research efforts and drive innovation in the field of smart
home technology.

7.4 Benefits of the project: Enhancing Convenience, Safety, and Efficiency

7.4.1 Introduction

The home automation project represents a transformative leap in the way we interact
with our living spaces. Its benefits extend far beyond mere convenience, encompassing
aspects of safety, efficiency, accessibility, and sustainability. In this comprehensive
exploration, we delve deep into each facet, unravelling the myriad ways in which our
project enriches the lives of users and contributes to a more connected, intelligent, and
harmonious home environment.

7.4.2 Energy Conservation and Efficiency

At the heart of our home automation project lies a commitment to energy conservation
and efficiency. By enabling users to remotely control appliances, the system empowers
them to avoid unnecessary wastage of power. Through intuitive interfaces and seamless
integration with smart devices, users can effortlessly monitor and manage energy
consumption, leading to significant reductions in electricity usage and associated costs.
In this section, we explore the tangible benefits of energy conservation, from lower

46
utility bills to reduced carbon emissions, and delve into the underlying technologies and
strategies that drive efficiency gains.

7.4.3 Accessibility and Independence

For individuals with physical disabilities or elderly persons, the home automation
project represents a gateway to newfound independence and empowerment. Through its
intuitive interfaces and remote-control capabilities, users can overcome barriers to
accessibility and manage their home environment with ease. We delve into real-life
stories of individuals whose lives have been transformed by the project, highlighting the
profound impact it has had on their daily routines, sense of autonomy, and overall well-
being.

7.4.4 Safety and Security

Safety is paramount in any home environment, particularly where young children are
present. Our home automation project offers enhanced safety features that minimize the
risk of accidents associated with electrical appliances. Through remote monitoring and
control capabilities, parents and caregivers can ensure a safe and secure environment
for their loved ones, even when they're away from home. We explore the various safety
features and protocols embedded within the system, from automated shutdowns to
proactive alerts, and discuss their effectiveness in preventing accidents and mitigating
risks.

7.4.5 User-friendly Interface and Convenience

Central to the success of our home automation project is its user-friendly interface,
which caters to individuals of all ages and technical backgrounds. Through the Flutter
application, users can effortlessly toggle switches, monitor device status, and create
customized automation routines to streamline their daily routines. We delve into the
design principles and usability testing methodologies that underpin the interface,
showcasing how it enhances convenience and simplifies household management tasks.

7.4.6 Educational and Environmental Impact

Beyond its immediate benefits, the home automation project has far-reaching
implications for education and sustainability.

47
Introducing students to concepts of technology, electricity, and automation. Hands-on
experience with the system fosters curiosity, creativity, and critical thinking skills,
preparing students for future careers in STEM fields. Additionally, the project
contributes to sustainability efforts by promoting energy-efficient practices and
reducing carbon emissions associated with electricity consumption. Through real-world
case studies and testimonials, we highlight the educational and environmental impact of
the project and its role in shaping a more sustainable future.

7.4.7 Customization and Scalability

One of the key strengths of our home automation project lies in its modular design,
which allows for easy customization and scalability. Whether adding new appliances,
integrating additional sensors, or incorporating advanced features, the system can be
adapted to evolving requirements, ensuring long-term usability and satisfaction. We
delve into the flexibility and versatility of the system, showcasing how users can tailor
it to suit their unique needs and preferences, and explore potential future developments
and enhancements.

7.4.8 Integration and Interoperability

As part of a broader smart home ecosystem, our project seamlessly integrates with other
smart devices and platforms, offering users a cohesive and interconnected automation
experience. Through integration with virtual assistant platforms such as Google
Assistant and Alexa, users can enjoy enhanced convenience and interoperability,
enabling voice-controlled operation and automation routines. We explore the
interoperability features and protocols that facilitate seamless integration with third-
party devices and platforms and discuss the potential benefits of a more connected and
interoperable smart home ecosystem.

7.4.9 Integration with Smart Home Ecosystems

As part of a broader smart home ecosystem, the project can seamlessly integrate with
other smart devices and platforms, offering users a cohesive and interconnected home
automation experience. Integration with virtual assistant platforms such as Google
Assistant and Alexa further enhances convenience and interoperability, enabling voice-
controlled operation and automation routines.

48
7.4.10 Improved Quality of Life

Ultimately, the home automation project aims to improve the quality of life for users by
simplifying daily routines, enhancing safety and security, and promoting energy
efficiency and sustainability. By harnessing the power of technology to streamline
household management tasks, the project empowers users to create a more comfortable,
convenient, and connected living environment.

7.4.11 Conclusion

In conclusion, the benefits of our home automation project are manifold, spanning
convenience, safety, efficiency, accessibility, education, and sustainability. Through its
innovative design, intuitive interfaces, and seamless integration with smart devices, the
project empowers users to create a more comfortable, convenient, and connected living
environment. As we look towards the future, we remain committed to advancing the
boundaries of home automation technology, driving innovation, and unlocking new
possibilities for a smarter, more sustainable world.

7.5 Limitations and Challenges

Despite its strengths, our home automation system faces certain limitations and challenges that
warrant consideration. Interoperability issues may arise due to variations in device
compatibility and standards, requiring careful integration and compatibility testing. Security
and privacy concerns must be addressed through robust measures to safeguard sensitive data
and protect against potential vulnerabilities. Furthermore, reliance on external services like
Firebase introduces dependencies that may impact reliability and performance, especially in
scenarios with limited internet connectivity or service disruptions.

Expanding on limitations and challenges involves discussing strategies for mitigating these
issues, such as standardization efforts, encryption protocols, and contingency plans for network
outages. By exploring potential solutions, we can demonstrate our commitment to addressing
these challenges and ensuring the continued effectiveness of our home automation system.

49
7.6 Summary

In summary, our home automation system represents a significant advancement in smart home
technology, offering users unprecedented levels of control, convenience, and efficiency.
Through meticulous design, rigorous testing, and continuous innovation, we have demonstrated
its potential to transform the way people interact with their living spaces. As we continue to
explore new frontiers and unlock new possibilities, we remain committed to realizing the
vision of a smarter, more connected world. Together, we can harness the power of technology
to enrich and empower lives in meaningful and transformative ways.

Expanding the final conclusion involves reinforcing key themes and messages, such as the
transformative potential of our system, the importance of ongoing innovation, and the
collective effort required to realize our vision of a smarter, more connected world. By leaving
readers with a compelling vision of the future, we can inspire action and drive positive change
in the realm of smart home technology.

50
REFERENCES
For Journals:
[1]- Simon Monk, (2014). Programming Arduino Next Steps: Going Further with Sketches.
Cenveo Publisher Services.
[2]- Brian W. Evanes, (2007). Arduino Programming Notebook. Creative Commons.
Retrieved from
http://playground.arduino.cc/uploads/Main/arduino_notebook_v1-1.pdf
[3]- Arduino Mega 2560. (2015) Retrieved from
https://www.arduino.cc/en/Main/ArduinoBoardMega2560
Copyright by Creative Commons Attribution ShareAlike 3.0.
[4]- Atmel ATmega 2560. (2015) Retrieved from
http://www.atmel.com/devices/atmega2560.aspx
Copyright by Atmel Corporation
[5]- Arduino Ethernet Shield. (2015) Retrieved from
https://www.arduino.cc/en/Main/ArduinoEthernetShield
Copyright by Creative Commons Attribution ShareAlike 3.0.
For Books:

[6]- Sunfounder Arduino Learning (2015) Retrieved from


http://www.sunfounder.com/index.php?c=case_incs&a=typelist#Arduino
Copyright by sunfounder.com
[7]- Getting Started Android developers (2015) Retrieved from
https://developer.Android.com/training/index.html
8]- Massimo Banzi, Michael Shiloh, (2015). "Getting Started with Arduino: The Open Source
Electronics Prototyping Platform". Maker Media, Inc.
[9]- Jeremy Blum, (2013). "Exploring Arduino: Tools and Techniques for Engineering
Wizardry". Wiley.
[10]- John Boxall, (2013). "Arduino Workshop: A Hands-On Introduction with 65 Projects".
No Starch Press.
[11]- Arduino Official Documentation. (2022) Retrieved from
https://www.arduino.cc/reference/en
[12]- Arduino and Raspberry Pi Interfacing, (2016). "Creating Arduino and Raspberry Pi
projects". Maker Media, Inc.

51
APPENDIX

(A) ARDUINO ESP-KIT CONTROL PROGRAM

#include <Arduino.h>

#include <WiFi.h>

#include <EEPROM.h>

#include <Firebase_ESP_Client.h>

#include <WiFiManager.h>

#include <ESP_DoubleResetDetector.h>

// WiFi credentials and Firebase configuration

#define WIFI_SSID "YourSSID"

#define WIFI_PASSWORD "YourPassword"

#define API_KEY "YourFirebaseAPIKey"

#define DATABASE_URL "your-database-url.firebaseio.com"

// Hardware pin definitions

#define S6 35 // Input sensor

#define R6 2 // Output relay

FirebaseData fbdo;

FirebaseAuth auth;

FirebaseConfig config;

void setup() {

Serial.begin(115200);

WiFiManager wm;

wm.autoConnect("AutoConnectAP");

config.api_key = API_KEY;

config.database_url = DATABASE_URL;

Firebase.begin(&config, &auth);

52
pinMode(S6, INPUT_PULLUP);

pinMode(R6, OUTPUT);

void loop() {

static unsigned long lastDatabaseManipulation = 0;

unsigned long currentMillis = millis();

if (currentMillis - lastDatabaseManipulation >= 2000) {

lastDatabaseManipulation = currentMillis;

manipulateDatabase();

}
}

void manipulateDatabase() {

if (WiFi.status() == WL_CONNECTED) {

with_internet();

} else {

without_internet();

}
}

void with_internet() {

String path = "/UsersData/" + String(auth.token.uid.c_str()) +


"/Appliances";

FirebaseJson json;

int sensorState = digitalRead(S6);

String applianceState = sensorState == LOW ? "1" : "0";

json.set("/appliance2", applianceState);

Firebase.RTDB.updateNode(&fbdo, path, &json);

void without_internet() {

digitalWrite(R6, !digitalRead(S6))};

53
(B) APPLICATION APP PROGRAM (main.dart)

import 'dart:convert';

import 'dart:io';

import 'package:flutter/material.dart';

import 'package:flutter_blue_plus/flutter_blue_plus.dart';

import 'package:hive_flutter/hive_flutter.dart';

import 'package:firebase_auth/firebase_auth.dart';
import 'package:permission_handler/permission_handler.dart';

class Addevice extends StatefulWidget {

const Addevice({Key? key}) : super(key: key);

@override

State<Addevice> createState() => _AddeviceState();

class _AddeviceState extends State<Addevice> {

User? user = FirebaseAuth.instance.currentUser;

List<BluetoothDevice> devicesList = [];

late BluetoothDevice targetDevice;

final String SERVICE_UUID = "fff0";

final String CHARACTERISTIC_UUID = "fff1";

Box passBox = Hive.box('passBox');

@override

void initState() {

super.initState();

_checkPermissionsAndEnableBluetooth();

startBluetoothScan();

Future<void> _checkPermissionsAndEnableBluetooth() async {

54
PermissionStatus bluetoothStatus = await
Permission.bluetooth.request();

if (bluetoothStatus == PermissionStatus.granted && Platform.isAndroid)


{

await FlutterBluePlus.turnOn();

} else if (bluetoothStatus == PermissionStatus.denied) {

openAppSettings();

}
}

void startBluetoothScan() {

FlutterBluePlus.startScan(timeout: Duration(seconds: 4));

FlutterBluePlus.scanResults.listen((results) {

setState(() => devicesList = results.map((result) =>


result.device).toList());

});

void connectWithESP(int index) async {

targetDevice = devicesList[index];

await targetDevice.connect();

BluetoothService service = await targetDevice.discoverServices().then(


(services) => services.firstWhere((service) =>
service.uuid.toString().toLowerCase() == SERVICE_UUID.toLowerCase())

);

BluetoothCharacteristic? characteristic =
service.characteristics.firstWhere(

(c) => c.uuid.toString().toLowerCase() ==


CHARACTERISTIC_UUID.toLowerCase()

);

if (characteristic != null) {

List<int> credentialsData =
utf8.encode("${user!.email},${passBox.get('pass')}");
await characteristic.write(credentialsData, withoutResponse: true);

Navigator.pushNamed(context, '/devices_success');

} else {
Navigator.pushNamed(context, '/devices_fail');

55
}

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(title: Text('Nearby Bluetooth Devices')),

body: ListView.builder(

itemCount: devicesList.length,

itemBuilder: (context, index) => ListTile(

title: Text(devicesList[index].name),
trailing: ElevatedButton(onPressed: () => connectWithESP(index),
child: Text("Connect")),

),

),

);

(C) PROGRAM TO CONTROL SWITCHES

import 'dart:async';

import 'dart:ui';

import 'package:flutter/material.dart';

import 'package:firebase_auth/firebase_auth.dart';

import 'package:hive_flutter/hive_flutter.dart';

import 'package:firebase_database/firebase_database.dart';

class DevicesSuccess extends StatefulWidget {

const DevicesSuccess({Key? key}) : super(key: key);

@override

State<DevicesSuccess> createState() => _DevicesSuccessState();

56
class _DevicesSuccessState extends State<DevicesSuccess> {

final Box passBox = Hive.box('passBox');

late DatabaseReference _databaseReference;

late List<dynamic> _appliances;

StreamSubscription<DatabaseEvent>? _subscription;

@override

void initState() {

super.initState();

_databaseReference = FirebaseDatabase.instance.ref();

_subscribeToAppliancesData();

void _subscribeToAppliancesData() {

User? user = FirebaseAuth.instance.currentUser;

_subscription =
_databaseReference.child('UsersData/${user?.uid}/Appliances')

.onValue.listen((event) {

if (event.snapshot.value is Map) {

Map<String, String> appliancesMap = (event.snapshot.value as


Map).cast<String, String>();

setState(() {

_appliances = appliancesMap.entries.map((e) => {'name': e.key,


'status': e.value == '1' ? 'on' : 'off'}).toList();

});

});

void _toggleSwitchStatus(Map<String, dynamic> appliance) async {

String newStatus = appliance['status'] == 'on' ? '0' : '1';

await
_databaseReference.child('UsersData/${FirebaseAuth.instance.currentUser?.ui
d}/Appliances/${appliance['name']}')

.set(newStatus);

57
@override

void dispose() {

_subscription?.cancel();

super.dispose();

@override

Widget build(BuildContext context) {

return Scaffold(

body: Stack(

children: [

Container(
decoration: BoxDecoration(image: DecorationImage(image:
AssetImage('assets/home.jpg'), fit: BoxFit.cover)),

child: BackdropFilter(

filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),

child: Container(color: Colors.black.withOpacity(0.5)),

),

),

Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Text("PANSIM HOME AUTOMATION", style: TextStyle(fontWeight:


FontWeight.bold, fontSize: 30, color: Colors.white)),

Expanded(

child: GridView.count(

crossAxisCount: 2,

children: _appliances.map((appliance) => GestureDetector(

onTap: () => _toggleSwitchStatus(appliance),

child: Container(

decoration: BoxDecoration(color: appliance['status']


== 'on' ? Colors.green.shade600 : Colors.white),

child: Center(child: Text('Switch', style:


TextStyle(color: Colors.white, fontWeight: FontWeight.bold))),

),

58
)).toList(),

),

),

GestureDetector(

onTap: () async {

await FirebaseAuth.instance.signOut();

await passBox.delete('pass');

Navigator.pushNamed(context, "/login");

},

child: Container(

decoration: BoxDecoration(color: Colors.green.shade600),

child: Center(child: Text("Logout", style:


TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize:
18))),
),

),

],

),

],

),

);

59

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