Final Thesis
Final Thesis
Home Automation
Author
Supervisor
Author
Supervisor
Author
Supervisor:
June 2024
Undertaking
I certify that research work titled “Blockchain Driven IoT Based Smart and Secure Home
Automation” is my own work. The work has not been presented elsewhere for assessment.
Where material has been used from other sources it has been properly acknowledged / referred.
Dedicated to my family, whose unwavering support and encouragement have been my guiding light. To my mentors
and teachers, for their invaluable wisdom and guidance throughout this journey. And to my friends and colleagues,
for their camaraderie and inspiration that made every challenge more manageable.
Abstract
Wi-Fi module. Integrated with various sensors and actuators, it controls home appliances such as
lights and fans, with security features enhanced by blockchain technology. A local HTTP server
facilitates real-time monitoring via a web interface for both automatic and manual operation.
Hardware components include the ESP32 module, sensors (LDR, PIR, temperature), actuators
(fans, lights, door lock), and an ESP32 camera module. These work together to collect data and
enable device control. Software-wise, a local HTTP server provides real-time access, while
The system, managed by the ESP32 module, supports automatic and manual modes, with
Testing validates accuracy, responsiveness, and security, demonstrating reliability under various
conditions. The thesis highlights blockchain's potential in fortifying home automation security,
suggesting future improvements like expanding device control and enhancing user interfaces,
while exploring machine learning for smarter automation. This research showcases blockchain's
We would like to express our deepest gratitude to all those who have provided us with the
support and guidance throughout the duration of our final year project.
First and foremost, we are extremely grateful to our supervisor, [Dr. Munira Batool], for their
invaluable advice, continuous support, and patience during our research. Their immense
knowledge and plentiful experience have encouraged us in all the time of our academic research
and daily life.
We would also like to thank the Department of Electrical Engineering at the University of
Engineering and Technology, Taxila, for providing us with a conducive environment and all the
necessary facilities for the research.
Special thanks to our parents and families for their love, patience, and understanding. Their
encouragement has been a source of inspiration and strength for us.
We are also thankful to our friends and fellow students who have assisted us in various aspects
of our project. Their willingness to help and their enthusiastic participation made our journey
more enjoyable and enriching.
Finally, we would like to acknowledge each member of our group: [Muhammad Awais Ul Haq
Awaisi], [Aleena Minhal Awan], and [Hammad Nazir]. The collaboration and teamwork among
us have been a crucial factor in the successful completion of this project. Each member’s
dedication and hard work are deeply appreciated.
Thank you all for making this journey a memorable and rewarding experience.
CHAPTER 1: INTRODUCTION
In today's rapidly evolving world, our homes are becoming smarter and more connected than
revolutionizing the way we live by integrating technology into our daily lives. Imagine being
able to control the lights, thermostat, security cameras, and even kitchen appliances in your home,
all from your smartphone or tablet. This level of convenience and control is made possible by
advancements in technologies like the Internet of Things (IoT), wireless communication, and
smart sensors.
Home automation systems offer a plethora of benefits, from enhancing comfort and efficiency to
improving security within households. For instance, you can adjust the temperature in your home
while you're away, ensuring that it's just right when you return. Or you can receive real-time
alerts on your phone if there's any unusual activity detected by your security cameras. These
systems provide peace of mind and convenience, allowing users to manage their homes from
However, as our homes become more interconnected and dependent on internet connectivity,
they also become more vulnerable to cybersecurity threats. Traditional home automation systems
often rely on centralized servers to store and process data. While convenient, this centralization
creates potential single points of failure, making these systems attractive targets for cyberattacks.
If a hacker were to breach the central server, they could gain unauthorized access to sensitive
data or even take control of home devices, posing significant privacy and security risks.
1
Figure 1:cybersecurity threats in home automation systems.
1.1.2 Motivation:
The increasing frequency and sophistication of cyberattacks targeting home automation systems
highlight the urgent need for enhanced security measures. As more and more devices in our
homes become connected to the internet, the potential attack surface for hackers grows larger.
Ensuring the security and integrity of these interconnected systems is paramount to protecting
Blockchain technology offers a promising solution to these security challenges. Known for its
decentralized, transparent, and tamper-proof nature, blockchain has the potential to revolutionize
the way we secure home automation systems. By decentralizing data storage and employing
The motivation behind this research project is twofold. Firstly, it aims to address the pressing
need for enhanced security in smart homes by exploring the potential of blockchain technology.
2
research seeks to develop innovative solutions to protect home automation systems from cyber
threats.
Secondly, this project aims to bridge the gap between theory and practice by designing and
Through rigorous experimentation and evaluation, the efficacy and feasibility of integrating
blockchain with IoT devices will be assessed. The ultimate goal is to empower homeowners with
a secure and resilient home automation system that not only enhances convenience but also
In essence, the motivation behind this research project is rooted in a commitment to harnessing
the transformative potential of blockchain technology to create a safer and more secure future for
smart homes. By marrying the capabilities of blockchain with the versatility of IoT devices, this
endeavor aims to pave the way for a new era of intelligent living where users can enjoy the
3
1.2 Problem Statement
Despite the numerous advantages of home automation systems, their widespread adoption is
servers for data storage and control, making them susceptible to various cyber threats such as
hacking, unauthorized access, and data breaches. The consequences of these security issues can
be severe, including privacy invasions, unauthorized control over home devices, and potential
Given these challenges, there is an urgent need for a home automation system that ensures data
integrity and prevents unauthorized access. This project aims to address these critical security
using the ESP32 module as the central controller, the system can securely manage and monitor
various home devices. Blockchain integration will ensure that all data transactions are recorded
in a temper-proof manner, significantly enhancing the security and reliability of the system.
1.3 Objectives
1. Develop a Secure Home Automation System: Utilize the ESP32 Wi-Fi module in
conjunction with various sensors and actuators to create a comprehensive and secure
2. Implement Real-Time Monitoring and Control: Develop a local HTTP server on the
ESP32 to facilitate real-time data access and control through a web interface, allowing
4
3. Enhance Security with Blockchain: Integrate the ESP32 camera module with the IOTA
blockchain to ensure the security and integrity of captured images and other sensitive
data.
4. Provide Flexible Control Options: Enable both automatic and manual control modes
for home devices, giving users the flexibility to choose their preferred method of
operation.
5. Ensure Scalability and Cost-Effectiveness: Design the system to be easily scalable and
cost-effective, making it accessible to a wide range of users and suitable for various home
automation applications.
7. Integrate Voice Control: Incorporate voice control functionality using services like
8. Enable Data Analytics: Implement data analytics tools to provide users with insights on
9. Enhance User Interface: Develop an intuitive and user-friendly interface that makes it
10. Support Multiple Users: Allow multiple users to have access to the system with
11. Implement Secure Firmware Updates: Ensure that firmware updates can be securely
downloaded and installed to keep the system up to date with the latest security patches.
5
12. Facilitate Remote Troubleshooting: Enable remote diagnostics and troubleshooting to
The significance of this study lies in its potential to revolutionize the home automation industry
by addressing one of its most critical challenges: security. By integrating blockchain technology
with IoT devices, the proposed system offers a higher level of security compared to traditional
home automation systems. This enhanced security can prevent unauthorized access and ensure
The use of the ESP32 module, known for its versatility and affordability, makes the proposed
system accessible to a broad audience. The ESP32’s capability to interface with a wide range of
sensors and actuators allows for the creation of a comprehensive and scalable home automation
solution tailored to meet diverse user needs. Additionally, the integration of blockchain
technology ensures that the system can provide a secure and reliable method for data storage and
6
This project not only contributes to the academic field by exploring the intersection of
blockchain and IoT technologies, but also provides practical solutions for enhancing the security
and functionality of home automation systems. The findings of this study can be applied to
various domains, including smart homes, smart cities, and industrial automation, where security
Furthermore, this project showcases how advanced technologies can be integrated to create
innovative solutions that address real-world problems. By demonstrating the practical benefits of
combining blockchain and IoT, this study encourages further research and development in this
promising area.
The proposed home automation system utilizes the ESP32 Wi-Fi module as the central controller,
interfacing with various sensors and actuators to manage and monitor home devices. The ESP32
7
is chosen for its robust features, including Wi-Fi and Bluetooth connectivity, ample processing
1. Sensor and Actuator Network: This includes light sensors (LDR), motion sensors (PIR),
temperature sensors, and actuators such as relays for controlling lights, fans, and door
locks. These devices are connected to the ESP32, which processes sensor data and
2. Local HTTP Server: The ESP32 hosts a local HTTP server that facilitates real-time data
access and control through a web interface. Users can interact with the system via a
3. Blockchain Integration: The system integrates the ESP32 camera module with the
IOTA blockchain. Captured images and other critical data are stored on the blockchain,
ensuring data integrity and preventing tampering. The blockchain acts as a secure and
decentralized ledger for all transactions, enhancing the overall security of the system.
The integration of these components results in a home automation system that not only provides
convenience and efficiency but also ensures robust security. By leveraging the decentralized
nature of blockchain, the system eliminates single points of failure and reduces the risk of
1. Hardware Setup: The ESP32 module is configured to interface with various sensors and
8
device, ensuring accurate data collection and reliable control mechanisms. The hardware
setup includes wiring the sensors and actuators to the ESP32 and configuring the
2. Software Development: The firmware for the ESP32 is developed using the Arduino
IDE. This includes writing code to read sensor data, control actuators, and manage
communication between the ESP32 and the local HTTP server. The server handles HTTP
requests, processes data, and updates the web interface in real-time. The software
development process also involves implementing security measures to protect the system
3. Blockchain Integration: The integration of the ESP32 camera module with the IOTA
blockchain involves setting up the necessary libraries and protocols for data transmission.
Captured images are hashed and stored on the blockchain, with metadata recorded to
ensure traceability and verification. The blockchain integration ensures that all data
4. Testing and Validation: The system is tested under various conditions to evaluate its
performance, reliability, and security. This includes testing sensor accuracy, control
unauthorized access and ensuring data integrity. The testing process involves simulating
different scenarios and analyzing the results to identify any potential issues or areas for
improvement.
5. Deployment: Once the system has been thoroughly tested and validated, it is deployed in
a real-world environment. The deployment process includes setting up the hardware and
software components, configuring the network settings, and providing users with access
9
to the web interface. The system is monitored to ensure that it operates smoothly and
Developing a secure and efficient home automation system involves several challenges,
including:
between the ESP32 and connected devices is paramount. To tackle this, we optimize the
firmware and utilize robust communication protocols. By doing so, the system can handle
various network conditions and ensure accurate and efficient data transmission.
➢ Managing Data Security: Protecting sensitive data from unauthorized access and
solution by providing a secure and immutable ledger for data transactions. Additionally,
encryption and other security measures are implemented to safeguard data both at rest
and in transit.
10
➢ Scalability and Flexibility: Designing the system to be easily scalable and adaptable to
different user needs requires careful planning and a modular approach. Leveraging the
ESP32's versatile features and support for various peripherals facilitates achieving this
goal. The system can seamlessly expand by adding more sensors and actuators, and it can
wide range of users is essential. The web interface is designed with intuitiveness in mind,
allowing users to effortlessly monitor and control their home devices. Real-time data
updates and customizable system settings further enhance the user experience.
➢ Cost-Effectiveness: Balancing advanced features and security with the overall cost of the
system is a critical consideration. Utilizing the affordable and widely available ESP32
firmware design and power management techniques, the system maximizes energy
➢ Fault Tolerance: Building resilience against hardware failures and network disruptions
is crucial for maintaining system uptime and reliability. The system incorporates
11
redundancy and error-handling mechanisms to mitigate the impact of failures and ensure
continuous operation.
such as user authentication and access permissions, to protect personal data from
standards is essential for ensuring legal compliance and user trust. The system is designed
with adherence to relevant regulations, such as data protection laws and industry-specific
is crucial for enhancing user convenience and system maintenance. The system provides
remote access functionalities, allowing users to monitor and troubleshoot devices from
➢ Continuous Updates and Maintenance: Ensuring the longevity and security of the
system requires regular updates and maintenance. The system is equipped with
mechanisms for seamless updates and patches, enabling timely deployment of bug fixes,
security enhancements, and new features to keep the system up-to-date and resilient
12
Figure 6: Challenges and Solution to an IoT based automated home
While the proposed system demonstrates significant improvements in home automation security,
intelligent automation based on user behavior and preferences can further enhance the
system’s functionality. For example, the system can learn the user’s daily routines and
adjust the settings accordingly, providing a more personalized and efficient experience.
possibly incorporating mobile app support, can improve user experience and accessibility.
A mobile app can provide users with easy access to the system from anywhere, allowing
13
❖ Broader Blockchain Applications: Exploring the use of other blockchain technologies
and applications can provide additional security features and enhance the overall
robustness of the system. For example, smart contracts can be used to automate certain
tasks and ensure that they are executed securely and reliably.
❖ Integration with Other Smart Home Systems: Integrating the proposed system with
other smart home systems and platforms can provide additional features and improve
interoperability. This can include integration with voice assistants, smart lighting systems,
❖ Energy Efficiency: Investigating ways to improve the energy efficiency of the system
can reduce its overall impact on the environment. This can include optimizing the power
❖ User Privacy: Ensuring that the system protects user privacy is essential. Future work
can focus on implementing additional privacy measures, such as anonymizing data and
1.9 Conclusion
This project aims to develop a secure and efficient home automation system by integrating IoT
devices with blockchain technology. By leveraging the capabilities of the ESP32 module and the
security features of blockchain, the proposed system addresses the critical security challenges
faced by traditional home automation systems. The findings of this study not only contribute to
the academic field but also provide practical solutions for enhancing the security and
functionality of home automation systems, paving the way for future innovations in this area.
14
The proposed system offers a comprehensive and scalable solution for home automation,
providing users with the ability to monitor and control their home devices securely and
efficiently. The integration of blockchain technology ensures that all data transactions are secure
and verifiable, reducing the risk of unauthorized access and data manipulation. The use of the
ESP32 module makes the system accessible and affordable, while its versatility allows for a wide
range of applications.
Overall, this project demonstrates the potential of combining IoT and blockchain technologies to
create innovative solutions that address real-world problems. By enhancing the security and
functionality of home automation systems, this study encourages further research and
development in this promising area, ultimately contributing to the advancement of smart home
15
CHAPTER 2: LITERATURE REVIEW
control to homeowners. These smart systems use sensors and wireless connectivity to allow
homeowners to remotely operate appliances like door locks, light bulbs, and power switches.
However, with the rapid growth in the number of these smart devices, significant security
concerns have emerged. These devices often have limited storage and processing power, making
them vulnerable to attacks. Traditional security measures have proven inadequate in addressing
the unique challenges posed by these smart home devices. As a result, researchers are focusing
on developing new security solutions. One promising approach is the use of blockchain
offers a secure alternative to traditional centralized security models, which have notable
shortcomings in meeting the security demands of smart homes. However, further research and
development are required to address the implementation challenges and optimize blockchain
protocols for IoT environments. Future work should focus on developing lightweight consensus
Discussion on the rise of smart home technology and associated security risks. It covers the need
for robust security mechanisms to protect smart home environments from cyber threats and
identifies the inadequacy of current security solutions for IoT devices in smart homes. Also
highlights the vulnerabilities inherent in traditional security models due to the limited
security framework for smart home systems enhanced the security and resilience of IoT devices
16
by leveraging blockchain's features. The research paper highlights that the exponential growth of
IoT devices in smart homes has outpaced the development of adequate security measures. It
points out that traditional centralized security solutions are not well-suited for the distributed
nature of smart home environments, making a strong case for blockchain's decentralized
approach. The report takes these insights and applies them to a real-world context. By focusing
on the ESP32 Wi-Fi module, a popular choice for IoT devices due to its cost-effectiveness and
versatility, the report provides a tangible implementation strategy. It outlines how blockchain can
be used to create a secure and scalable framework, addressing the challenges of device
authentication, secure communication, and data integrity. The document acknowledges the
technical challenges of integrating blockchain with IoT devices and calls for lightweight
consensus mechanisms, further explores specific algorithms and optimizations that can reduce
the computational burden on IoT devices. This includes exploring proof-of-stake or delegated
proof-of-stake consensus mechanisms, which are less resource-intensive than traditional proof-
of-work. The paper suggests directions for future research and development, such as enhancing
the interoperability of blockchain-based systems with existing smart home protocols and
standards. It also emphasizes the need for rigorous testing and validation to ensure that the
proposed solutions can withstand real-world conditions and threats. The research paper provides
a comprehensive view of the potential for blockchain technology to enhance smart home security
and translates these theories into practical solutions, demonstrating how blockchain can be
effectively integrated with IoT devices to create a secure smart home environment. Further
research and innovation will be crucial to overcoming the remaining technical challenges and
17
Figure 7:Smart House Basic Blocks
The proliferation of IoT devices such as smart locks, bulbs, and switches presents significant
security challenges. These devices are connected to the home network and can be controlled
remotely, making them attractive targets for cyberattacks. The limited resources in smart home
devices make them vulnerable to attacks, necessitating enhanced security measures. Common
issues include unauthorized access, data breaches, and manipulation of device functionalities.
The paper proposes blockchain technology as a potential solution to enhance the security of
smart home systems due to its decentralized and immutable nature. Blockchain can provide a
secure framework for IoT devices by leveraging cryptographic techniques to ensure data
integrity and authenticity. So, research also examines existing smart home automation systems,
blockchain technology in IoT, and the ESP32 Wi-Fi module. Reviews the current state of
research in both fields and identifies gaps that the proposed framework aims to address. The
research paper's findings offer a detailed model and address specific technical aspects, such as
18
the use of the ESP32 module and practical implementation strategies. Blockchain has emerged as
a major focus of research lately. It's like a digital ledger that's decentralized and secure due to
cryptography. Basically, it lets us make trusted transactions without needing a middleman. Each
transaction is recorded as a block, and these blocks are linked together in a chain with a digital
signature. Since everyone in the system maintains and updates the ledger together, it's really hard
Blockchain works through a Peer-to-Peer network where every user can join securely. When
someone new joins, they get a full copy of the ledger. When a new transaction happens, it's
added to the ledger after being verified by everyone in the network. This verification process,
called Proof-of-Work, involves solving complex puzzles using powerful computers. This ensures
To keep things fair, the difficulty of these puzzles adjusts automatically based on how many
transactions are happening. This prevents anyone from gaining too much control over the
network. In simpler applications, the difficulty is kept low to ensure quick responses.
Blockchain can be implemented in different ways. There's the public blockchain, where anyone
can access and contribute to the ledger. Then there's the private blockchain, where only certain
chosen entities have access. Lastly, there's the consortium blockchain, which combines aspects
of both public and private blockchains. It's like a mix of decentralization and controlled access,
19
making it suitable for various applications, including ensuring security and privacy in smart
20
Homes. Therefore, various approaches to using blockchain technology in smart homes have been
proposed, addressing security, privacy, efficiency, and environmental concerns. Each system
offers different benefits and challenges, reflecting the ongoing exploration of blockchain's
Security Framework for IoT is proposed using blockchain to create a secure communication
platform for IoT devices in a distributed environment. Smart District Model combines IoT with
blockchain for a power grid access system where users can trade energy using solar panels over
blockchain. Energy Chain is designed as a secure energy trading scheme for automated homes
using blockchain, emphasizing the system's security and efficiency. Used a smart home system
to outline blockchain's core components, conducted security and privacy analysis, and found it
suitable for low-resource IoT devices. a blockchain-based smart door lock system using three
users as nodes for proof-of-work, though it didn't address scenarios with only one user. Smart
Factory IoT is proposed a five-layer IoT architecture using blockchain for smart factories,
Blockchain (ELIB) is developed a model using blockchain, cloud, and smart contracts for IoT
systems, reducing processing time but potentially increasing costs. Furthermore, Ethereum-
Based Smart Home is Addressed confidentiality, integrity, and authentication issues using
owner, ensuring data security and protection against DDoS attacks but noted centralization
21
concerns. Efficient and Secure Framework is proposed a five-layer framework focusing on
secure data transmission using blockchain, adaptable for various applications including smart
blockchain and smart contracts to improve smart home security, with local miners processing
transactions. Utilize Ethereum to build smart contracts for smart home applications, though noted
Green Cloud Computing and Consortium Blockchain is Combined consortium blockchain with
cloud computing for smart home security, focusing on environmental efficiency. Data Privacy
Model is designed as a consortium blockchain model for data privacy in smart homes, evaluated
The core components in the recently proposed blockchain- based smart home architectures
alongside the achieved security have been summarized in the table 2 below:
22
Table 2: Summary of recently proposed Blockchain based Smart Home architectures.
• Decentralization: Eliminates single points of failure, making the system more robust against
attacks.
• Transparency: Provides a transparent transaction history, which can be audited to detect and
• Immutability: Ensures that once data is recorded, it cannot be altered, preventing tampering
The dissertation "Blockchain-Based Security Framework for the Internet of Things and Home
of blockchain technology to enhance the security of IoT devices and networks. The research
highlights the increasing prevalence of IoT devices and the associated security risks. With
millions of IoT devices connected to home and corporate networks, the need for robust security
measures has never been more critical. The dissertation sets out to address these challenges by
23
proposing a blockchain-based framework that leverages the decentralized and immutable
properties of blockchain technology to secure IoT environments. The dissertation delves into the
evolution and current challenges of blockchain technology. It examines the original limitations
of blockchain, and the technical responses developed to overcome these issues. The review also
covers the security challenges specific to IoT devices, such as vulnerabilities to cyberattacks and
devices. Existing IoT security solutions are analyzed, highlighting their strengths and
weaknesses. It sets the stage for the proposed blockchain-based security framework by
identifying the gaps in current solutions and emphasizing the potential of blockchain to address
these gaps. The core of the dissertation's proposal is the blockchain-based whitelisting
mechanism for consumer IoT devices and home networks. Methods for integrating blockchain
with IoT devices and networks are detailed, demonstrating how this approach can enhance
security by preventing unauthorized access and mitigating cyber threats. Building on the
Intelligence (CTI) network. This system aims to enable real-time sharing of threat information
among various stakeholders, including consumers, businesses, and service providers. By utilizing
blockchain, the CTI network ensures the integrity and privacy of shared data, while also enabling
automated network responses to identified threats. The methods for collecting, analyzing, and
sharing threat intelligence are discussed, along with the statistical analysis of the results obtained
24
"In this new system, each smart home has a special device called a 'miner' that manages all
communication within and outside the home. This miner also keeps a secure record of all
Now, think about how Airbnb works. People rent out their homes, right? Well, imagine using
blockchain and smart devices to make that process even smoother. Instead of waiting for the
owner to hand over keys, tenants can request to stay, pay using digital currency, and then access
Smart homes also let tenants control things like lights and appliances, and security cameras can
stream live footage for safety. Sometimes, tenants might use too much electricity or water. With
this system, owners can track usage and charge accordingly, all recorded securely on the
blockchain.
For the tech stuff, we're using AngularJS for the user interface, NodeJS for the backend, and a
system called Ethereum Test RPC to simulate the blockchain. This system also connects with
When a tenant checks out, they just scan a code, which notifies the owner. Then, based on other
bookings, the system updates the blockchain to keep everything secure. Only when the owner
25
Figure 10: Network and logical diagram.
Typically, IoT solutions consist of sensors and actuators connected to a microcontroller that
proposed solution.
At the bottom layer, the perception/actuation layer includes sensors, actuators, hardware modules,
and microcontrollers. Sensors detect environmental stimuli and convert them into electrical
signals, while actuators change the surroundings based on microcontroller commands. This layer
can use various sensors and actuators depending on the IoT solution's goals. Microcontrollers,
with computing capabilities, are integrated into boards for easy manipulation and system
integration.
Data collected by microcontrollers is sent to the upper layer for data analytics and decision-
26
such as bandwidth, coverage extension, quality of service, cost, energy consumption, and battery
life. Standard wireless technologies like WiFi and IoT communication protocols like Bluetooth
and ZigBee are commonly used for connectivity.The middleware layer stores and processes data
to extract information, often using server solutions to handle multiple device accesses. Data is
stored in relational or non-relational databases like MySQL and NoSQL. Device communication
friendly interface for accessing and displaying IoT process information, allowing users to
interact with the application. Finally, the business layer focuses on statistical analysis to create
strategies for investment opportunities and future services and application design.Not all IoT
applications fully implement this standardized architecture. Some projects may eliminate certain
layers for cost-effectiveness or introduce specific layers to meet their functionalities. However,
network and middleware layers are commonly included in many IoT projects due to their
essential functions. The business layer is often seen in IoT projects focusing on profit rather than
a user-centric approach.This work uses the IoT architecture to develop a Smart Lab platform
27
2.2.3 Enabling Technologies [3]:
The IoT device landscape has seen significant growth, especially in residential settings where
users can customize their setups. Works in this area can be categorized into homemade-smart
projects, market product solutions, and practical environmental integrated framework projects.
Market product solutions like Echo Dot, Nest Mini, and Home Pod offer voice-controlled
personal assistants that integrate with IoT devices for indoor environment control, such as lights,
plugs, air conditioners, locks, and curtains. However, these devices are sold individually with
Homemade smart house projects rely on online tutorials and easy-to-access hardware kits. While
they showcase indoor environmental applications, they often lack practical implementation.
Some prototypes demonstrate home control systems through mobile apps, allowing remote
approaches for hardware control with a universal user interface. These projects often use
28
protocols like MQTT for exchanging information and commands. For example, a Smart Campus
project integrates IoT devices for real-time data collection, analysis, and decision-making. The
The MQTT protocol operates on a publish/subscribe architecture model, where clients can
publish information to topics and subscribe to topics of interest. A broker server manages
processing, memory, and bandwidth consumption, making it efficient for IoT applications.
Figure 13: Communication architecture between devices using the MQTT-based server Broker as an information
centralizer.
The dissertation concludes by discussing future work, summarizing the findings, and providing
recommendations for further research. It emphasizes the need for standardizing CTI protocols
and improving privacy solutions within the blockchain context. The proposed framework's
29
architecture and methodology are revisited, highlighting their potential to revolutionize IoT
security. The summary encapsulates the overall contribution of the research, reaffirming the
importance of blockchain technology in developing advanced security solutions for IoT and
home networks. In its entirety, the dissertation makes a significant contribution to the field of
IoT security by presenting a novel approach that combines blockchain technology with
traditional security measures. The proposed solutions address critical challenges such as device
decentralized nature, the research provides a scalable and robust security framework that can
adapt to the evolving landscape of IoT threats. The findings and recommendations pave the way
for future innovations in securing IoT environments, underscoring the potential of blockchain as
essence of Diego M. Mendez Mena's research, providing a clear understanding of the proposed
solutions and their significance in enhancing IoT security through blockchain technology.
The architecture of the smart-home system is built on two core principles: separation of concerns
and the use of feedback. Separation of concerns involves dividing the system into distinct layers,
each responsible for different tasks and decisions, which helps manage the complexity of the
system. Each layer collects and processes data to inform its decision-making processes
independently. The use of feedback refers to gathering performance data about the system’s state
and using it to make necessary adjustments and improvements, thereby maintaining and
enhancing the system's overall performance. These principles are integrated to form a three-
layered structure where each layer's feedback loop encloses the next. The primary outer loop is
responsible for determining what should happen within the smart home, using predefined rules to
30
decide the desired state of various elements. It functions at a high level, setting the goals and
objectives for the system. The middle secondary loop then takes these high-level decisions and
translates them into specific actions, determining which devices need to be activated or adjusted
to achieve the desired state defined by the outer loop. This layer ensures that the appropriate
actions are planned in detail. The tertiary innermost loop is responsible for the actual execution,
activating the relevant devices as directed by the secondary loop. This layer directly interacts
with the smart home devices, ensuring that the actions planned by the secondary loop are carried
out. This results in a robust three-layered architecture where there is a constant two-way traffic
between the layers: decisions flow from the outer layers to the inner layers, ultimately causing
actions to be taken at end-point devices, while data flows from sensors through the inner layers
to the outer layers, where it is aggregated and processed to create comprehensive views of the
home's state. The data flow provides the necessary information for decision-making at each layer,
while the control flow ensures that the decisions are implemented effectively. In this architecture,
the data flow and control flow channels are interdependent and flow in opposite directions. Data
from sensors is continuously collected and processed as it moves up through the layers,
providing increasingly detailed and aggregated views of the system's state. This information
feeds into the decision-making processes at each layer, ensuring that the system can adapt and
respond to changing conditions. Conversely, control flows from the higher-level decision-
making layers down to the execution layer, ensuring that the desired actions are carried out
efficiently. This layered and feedback-driven approach allows the smart-home system to operate
in a responsive and adaptive manner, capable of managing a complex array of devices and
31
feedback, the system can maintain high performance and reliability, adapting to new data and
Figure 14: The layered architecture of the smart-home system with three levels of feedback loops.
2.3.1 Merged the Data Flow and Control Flow channels [4]:
The smart home architecture operates through an integrated data and control flow system, where
data from sensors feeds into decision-making processes that manage the home environment. For
example, a rule set for Joe’s comfort specifies maintaining his room temperature between 21-23
degrees in the summer mornings. When sensors or Joe himself confirm his presence at home, the
Generic State Manager evaluates the rule and passes a command to the Concrete State Manager.
This secondary layer identifies Joe's room and the necessary devices, translating the command
into an action, such as setting the cooling system to the desired temperature. The specific
Actuator Control Manager then adjusts the cooling system, accordingly, using feedback from
room temperature sensors to maintain the set point. If additional actions are needed, like
adjusting window shutters, the system incorporates these into its response, ensuring an adaptive
32
Figure 15: The overall architecture of the smart home system shows both control flow and data flow channels.
2.3.2 Broad Applications and Implications of the Internet of Things (IoT) [5]:
The broad applications and implications of the Internet of Things (IoT), highlighting its
integration into various sectors and the associated safety concerns. It mentions that IoT consists
of web-enabled devices that use processors, sensors, and communication hardware to collect and
process data in real-time. Additionally, technologies like Raspberry Pi, machine learning
algorithms, blockchain for device authentication, and various wireless communication modules
are mentioned as integral components of these IoT systems. The research emphasizes the
extensive application of IoT in real-world scenarios to solve practical problems. They highlight
the importance of IoT in enhancing safety, improving environmental monitoring, and automating
routine tasks. The paper underlines the role of IoT in creating intelligent systems that operate
with minimal human intervention, thus improving efficiency and safety in various domains.
Applications of IoT span across diverse areas including transportation, home automation,
industry, and environmental monitoring. Several IoT-based projects are cited, such as:
33
1. Air Pollution Monitoring: Utilizing sensors for real-time data collection on air quality.
2. Water Quality Monitoring: Employing sensors and Arduino microcontrollers to ensure safe
drinking water.
3. Home Automation: Using ESP8266 Wi-Fi modules, relays, and smartphones to control home
4. Gas Leakage Detection: Implementing systems with sensors like MQ2 and communication
technologies to detect, alert, and control gas leaks, enhancing home and industrial safety.
5. Environmental Monitoring: Using sensors like DHT22 and GSM modules to monitor and
6. Flood and Dam Monitoring: Developing systems to control dam operations and monitor river
7. Smart Gardening: Utilizing sensors and Wi-Fi technology to automate garden watering based
control. Instead of directly accessing specific devices, users request changes to the state of
controlled variables, which the Concrete Control Manager then translates into device actions.
This method simplifies access control by focusing on state requests rather than device access
permissions. For example, if a user tries to change the temperature in a room that doesn't belong
to them, the system will deny the request based on the state permissions, ensuring that
strategy that includes several established methods from related works. It uses a combination of
traffic monitoring, intrusion detection, and agent-based modeling to secure the smart home
34
environment. These methods help to identify and block malicious activities and unauthorized
access by monitoring network traffic, analyzing behaviors, and implementing specific rules for
IoT devices. The security framework incorporates techniques like whitelist-based intrusion
detection and rule-based approaches to enforce specific device behaviors and filter out anomalies.
Our security approach follows the principle of minimal trust, where all communication is
encrypted, users are authenticated, and actions are authorized based on a stringent policy. The
authentication process involves verifying users through schemes like passwords or multi-factor
authentication and issuing signed tickets for further actions. Authorization then uses these tickets
to verify user identities and grant access based on Access Control Lists (ACLs), which detail the
permissions for each user regarding the states they can control. To manage conflicts between
rules set by different users, the system assigns priorities to rule owners, creating a hierarchy
where higher-priority rules override those of lower-priority users. This hierarchical approach
allows for automated conflict resolution, with the Rule Administrator at the top. For instance, the
homeowner can set temperature limits to prevent freezing pipes, overriding any conflicting rules
set by residents. Similarly, entities like electricity providers can be given recommendation-only
permissions, ensuring their suggestions do not interfere with the homeowner’s control unless
35
Figure 16: Block diagram of a generic development board using sensors and actuators for IoT applications.
In a smart home, multiple devices communicate through a gateway, which can pose risks like
data exposure, privacy breaches, device malfunctions, and harm to users. Without security
standards, integrating diverse devices becomes challenging, hindering smooth service provision.
Therefore, ensuring gateway security is crucial. Here are the security requirements for smart
home gateways:
• Confidentiality: Smart home networks collect sensitive resident data, requiring strict
access control. Blockchain, coupled with encryption algorithms and keys, ensures data
confidentiality.
minimize data tampering risks, allowing precise tracking and verification of recorded
data.
36
• Authentication: Authentication prevents external attackers from maliciously accessing the
network. Blockchain verifies network legitimacy, enabling timely checks for proper
compromise IoT systems through various entry points such as hardware, firmware, data,
networks, and software. With physical access, attackers can exploit side-channel attacks or use
I/O ports to read sensitive firmware data, overwrite applications, disable device functions, or
perform other malicious activities. Even if these interfaces are disabled, attackers can still read
firmware directly from flash memory if it's stored in plaintext or if the encryption key is
accessible. Unsigned or poorly signed firmware can also be manipulated, allowing adversaries to
upload their own malicious firmware, undermining system integrity. Network security
vulnerabilities, like the lack of secure mutual authentication, confidentiality, and integrity at the
transport layer, can enable attackers to impersonate clients or servers and collect sensitive data.
Software vulnerabilities, such as buffer overflows and code injections, can be exploited remotely
updates, vendors cannot reliably patch IoT devices, leaving them vulnerable to attacks. Contrary
to common belief, securing IoT systems is feasible and affordable even with hardware
constraints. Modern IoT devices, like the ESP32 and CC3220, incorporate security features such
as firmware encryption, secure booting, and secure key storage. ARMv8-M processors with
cryptographic functions like RSA and AES enhance network security. Legacy devices can be
paired with external security modules to improve protection. However, software security remains
37
challenging due to the difficulty of writing bug-free software and the wide variety of software
attacks, including buffer overflows, format string attacks, and return-oriented programming. The
same software may exhibit different vulnerabilities on different hardware due to architectural
differences, and even systems protected by advanced features like Trust Zone can be
compromised by sophisticated software attacks. Securing IoT systems requires protecting not
only the end devices but also the entire network, including cloud servers and users. Cloud servers
are critical as they handle authentication, data processing, and traffic relay, but they also present
single points of failure if compromised. Users interact with devices via cloud servers, making
both vulnerable to attacks. MQTT is a widely used protocol for IoT communication due to its
low resource overhead and popularity, but its software security has been underexplored despite
the potential impact of vulnerabilities on millions of devices. Furthermore, the paper emphasizes
the broad application and inherent security challenges of IoT systems. They highlight the
importance of robust security measures across all components of IoT ecosystems, including
devices, networks, and cloud services. The reports underscore the potential risks of inadequate
security and the necessity for secure firmware, reliable authentication, and comprehensive
protection against software vulnerabilities. Research advocates for advanced technologies and
methodologies to enhance IoT security, ensuring the reliability and safety of IoT applications in
various domains such as home automation, environmental monitoring, and industrial safety. To
secure an IoT system, we must address hardware, system, and firmware security, as well as data
1. Hardware Security:
38
o Solution: Prevent attackers from reading/changing device data by disabling vulnerable
o Disabling JTAG: Set the eFuse bit "JTAG_DISABLE" to permanently disable JTAG.
o Disabling UART: Set eFuse values to disable transparent flash encryption, decryption,
o Secure Key Storage: Use eFuse to store encryption keys securely, preventing
unauthorized access.
o Secure Boot: Ensure all software running on the device is signed and verified.
o Bootloader Security: Use AES and ECDSA keys to validate bootloaders and firmware,
3. Data Security:
o Flash Encryption: Encrypt firmware and application data using AES-256 keys stored in
eFuse.
o Encrypting Flash Partitions: Default encryption for factory and OTA partitions, with
o Encrypting NVS: Store a separate AES-256 key for NVS encryption to secure sensitive
data.
4. Network Security:
o TLS Implementation: Use SSL/TLS for mutual authentication, message encryption, and
integrity.
39
o Hardware Acceleration: Utilize ESP32’s hardware acceleration for cryptographic
o OTA Process: Fetch, store, and load new firmware images securely.
o Partition Management: Use multiple OTA partitions and a pointer system to manage
Figure 17: Result of the bibliometric analysis in VOS viewer for ESP32 board considering SCOPUS database.
The ESP32 microcontroller, along with components like the solenoid lock and flame sensor,
interfaces with the ESP32 CAM via Wi-Fi and FTDI, enabling connectivity to the Blynk app.
Through this setup, users can remotely regulate devices like the solenoid lock and receive alerts
for fire incidents, while also viewing guest images through the app. The project's workflow
40
involves the passive infrared (PIR) sensor detecting nearby infrared light, with passive IR
sensors utilizing pyroelectric sensors to discern heat energy, triggering appropriate alerts or
actions. Additionally, the ESP32-CAM, featuring a built-in camera and microSD card slot,
serves IoT applications requiring advanced camera functionalities. A flame detector sensor
identifies and responds to flames, potentially initiating alarms or safety protocols. FTDI plays a
to USB signals. Furthermore, the ESP32 microcontroller family, known for its affordability, low
power consumption, and integrated Wi-Fi and Bluetooth capabilities, finds utility in various IoT
applications. Blynk simplifies mobile app development by providing an intuitive platform for
creating apps that communicate with microcontrollers or computers, such as Raspberry Pi,
through user-friendly drag-and-drop widgets. Upon detection of a visitor by the PIR sensor, the
Blynk app sends notifications to the user, who can then utilize the ESP32 CAM to gather more
information about the visitor. Similarly, the flame sensor triggers alerts in the Blynk app upon
detecting flames, with the successful execution of code resulting in the illumination of the flame
sensor's red light to signal proper connections. Through this integrated system, users can swiftly
respond to potential security threats or emergencies, ensuring efficient and reliable operation of
41
Figure 18: Architecture Diagram.
The decision to utilize Arduino for this project primarily stems from the vibrant community
support and extensive library availability. Although the ESP32 boasts its own official
development processes. With Arduino, it's likely that most sensors and devices encountered
already have compatible libraries, greatly reducing development time. Fortunately, Espressif
Systems also offers tools for ESP32 software development within the Arduino platform, bridging
the gap between ease of use and functionality. Espressif Systems, headquartered in Shanghai,
specializes in IoT solutions and is renowned for their ESP8266 and ESP32 chips and modules.
Despite the ESP8266's affordability and powerful processing capabilities, it lacks crucial security
features like flash encryption and secure boot. These omissions make it susceptible to
modifications, which could be exploited for server attacks. This limitation makes it less suitable
for projects that require robust security measures. The ESP8266's successor, the ESP32,
overcomes these security shortcomings by incorporating flash encryption and secure boot
42
capabilities, ensuring a higher level of protection against unauthorized access and tampering. The
ESP32 also features a more powerful dual-core processor, allowing one core to manage an
encrypted Wi-Fi connection independently. This setup prevents the Wi-Fi connection from
slowing down other functionalities, enhancing overall performance and security. Additionally,
the ESP32's processing power supports more complex cryptographic algorithms, further
strengthening its security features. Despite being slightly more expensive than the ESP8266, the
ESP32's advanced features justify the cost, making it the preferred choice for futureproofing the
project. The ESP32's versatility is reflected in its availability in various modules and
development boards, with options for single-core or dual-core processors, different flash memory
capacities, and diverse antenna configurations. For this project, the ESP32-WROOM-32 module
was selected. It includes 4 megabytes of flash storage and an integrated PCB antenna, providing
ample memory and reliable connectivity. The prototype system will use a development board
based on this module, which includes necessary circuitry for programming and a USB power
supply for convenient power delivery. The development board also features a power LED and
an activity LED connected to one of the digital pins, facilitating easy monitoring and debugging.
The project will utilize the Espressif IoT Development Framework (ESP-IDF), the official
development framework for the ESP32. Specifically, the project will use the "Arduino core for
the ESP32," allowing seamless integration of ESP32 libraries within the Arduino IDE, along
with other Arduino libraries. This approach combines the ease of Arduino development with the
advanced capabilities of the ESP32. The ESP-IDF documentation will be frequently referenced
during development due to the extensive features it supports, including over-the-air (OTA)
updates, running a file system, Wi-Fi connectivity, making HTTP requests, and running an
HTTP server. These features are crucial for the project's requirements. The system will operate at
43
a logic level voltage of 3.3 volts, as dictated by the ESP32 specifications. However, the
development board requires a 5-volt power supply, which is easily provided by common USB
power supplies. The development board includes an integrated 3.3-volt voltage regulator to step
down the voltage, though this regulator has limited current delivery capabilities. In a production
PCB, a similar power solution will be used, eliminating the need for the development board
44
With increasing concerns about home security, protecting our homes has become more
challenging. Whether the homeowner is present or not, ensuring the safety of the family and the
home is a major issue. The current module leverages modern IoT technologies, specifically an
ESP32 camera and an automated solenoid lock, to enhance home security. This system allows
users to recognize guests at the door and provides flame detection capabilities, ensuring
convenient access control, and immediate alert systems to significantly enhance home security,
1. Guest Recognition:
Smartphone Integration: The captured data is sent to the homeowner’s smartphone using
One-Click Operation: Homeowners can operate the solenoid lock remotely with a single
Enhanced Access Control: Provides a convenient and secure way to manage entry to the
home.
3. Flame Detection:
Indoor and Outdoor Monitoring: The module detects flames both inside and outside the
door.
Real-Time Alerts: Upon detecting flames, the system sends a notification to the
registered phone number via the Blynk application, ensuring the homeowner is promptly
45
2.6 System’s OSI Model Application Layer Protocol HTTP [8]:
HTTP is commonly utilized in the application layer (layer 7) of the OSI model. When securing
HTTP with HTTPS, it doesn't directly alter layer 7 but instead introduces encryption at layer 6
(the presentation layer). This encryption is provided by the Transport Layer Security (TLS)
protocol, which sits below HTTP. Hence, HTTPS is often referred to as HTTP over TLS,
denoting the use of the HTTP protocol atop the TLS protocol, which ensures secure
A URL (Uniform Resource Locator) serves as the address of an online resource and falls under
the subset of Uniform Resource Identifiers (URIs). Typically, URLs commence with a scheme,
often denoting a protocol such as HTTP, followed by a colon and the scheme-specific part,
its secure counterpart HTTPS (HTTP over a secure connection) stand as the most prevalent
protocols. A grasp of HTTP's functionality proves vital, especially for embedded IoT devices,
aiding in the diagnosis of client-server communication issues. HTTP transactions entail a request
from the client and a subsequent response from the server, each composed of a start line, headers,
and a body. While the start line and headers are encoded in ASCII text, the body may consist of
46
text or binary data and can be omitted. Request messages adhere to the syntax: <method>
<request-URL> <version>, followed by headers and an optional body. Methods like GET,
HEAD, or POST indicate the action desired. Response messages follow the format: <version>
<status> <reason-phrase>, supplemented by headers and an optional body. The status code, a
three-digit number, denotes the outcome of the request, with the reason phrase providing human-
readable context. In-depth resources such as MDN (Mozilla Developer Network) or "HTTP -
The Definitive Guide" by David Gourley and Brian Totty offer comprehensive insights into
HTTP methods, headers, and status codes. HTTP's extensibility allows developers to define
clients and servers. Additionally, rare extension methods can also be employed. HTTP status
47
1. Devices/Sensors: At the outset, sensors or devices gather data from their surroundings, which
can vary from simple temperature readings to comprehensive video streams. Whether standalone
sensors or part of a multifunctional system, these devices collect data from the environment in
the initial stage. For instance, a smartphone encompasses various sensors like a camera,
accelerometer, and GPS, capable of performing diverse actions beyond sensing alone.
a means of connectivity. This could entail cellular networks, radio, WiFi, Bluetooth, or low-
power wide-area networks (LPWAN), either through a gateway/router or directly via ethernet.
Each communication option presents tradeoffs in terms of power consumption, range, and
bandwidth, with the optimal solution contingent on the IoT application's requirements.
Regardless, the overarching objective remains the same: transferring data to the cloud.
3. Information Processing: Once data reaches the cloud, it undergoes processing by machines,
ranging from basic validation of temperature readings to complex tasks like object identification
4. User Interface: Subsequently, processed data is rendered useful to end-users through various
means. This could involve sending notifications via email or text messages, such as alerting
about high temperatures in a company's cold storage. Alternatively, consumers may access apps
enabling them to monitor devices remotely or view video feeds. Moreover, bidirectional
communication allows users to interact with and influence devices based on the IoT program's
specifications.
However, a lack of technical standardization poses challenges, with IoT companies often
adopting disparate architectures for simplicity and ease of implementation. This diversity
48
hampers interoperability when integrating diverse hardware and platforms. Addressing these
issues necessitates robust software infrastructure across networks and background servers to
handle smart objects and support services. Additionally, given the dynamic and mobile nature of
IoT devices, ensuring fault tolerance is paramount, requiring adaptive structuring of the Internet
2.8 Conclusion:
The concept of IoT in home automation is increasingly appealing, but numerous challenges need
to be addressed, particularly regarding security. Smart devices and homes face various attacks,
usage information, and data tampering to manipulate energy pricing. Attackers can also modify
smart meter readings to control access and track energy usage, potentially revealing personal
details. This project explores the implementation of IoT devices in home automation systems and
the associated challenges. IoT facilitates the interconnection of objects and sensors without
human intervention. The article reviews IoT security threats and vulnerabilities, presents an IoT
architecture with multiple controllers, describes the integration and operation of various sensors,
and discusses the use of Ubidots for industrial data cloud recording. A simplistic model using a
consortium blockchain (a blend of public and private blockchains) is proposed to secure smart
homes. In this model, IoT devices, specifically ESP32 devices, act as miners, eliminating the
need for user involvement in the blockchain process. These devices communicate through a
mesh network, with a Super Node (SN) functioning as a P2P server to broadcast blocks and
handle mining. The SN also manages user authorization via a RESTful API and stores the
blockchain. Security checks are applied to incoming requests to ensure confidentiality and
integrity before blockchain processing, enhancing data privacy and trust. An experimental
testbed using ESP32 devices showed that each device takes approximately one second to mine a
49
block at difficulty level 1. Due to the limited computational power of IoT devices, the difficulty
level was kept low, as higher difficulty levels significantly increased the time required to mine a
block. The study concludes that this blockchain-based scheme is cost-effective, secure, and
suitable for smart homes without relying on cloud storage. Future research will address
computational challenges related to hashing, block queuing, and the energy relationship for each
node, with plans to implement Protocols as a Super Node for its superior performance.
Chapter 3: Design/Simulation/Hardware
3.1 Overview
50
This chapter provides a comprehensive overview of the design, simulation, and hardware
implementation of a blockchain-driven smart home automation system using the ESP32 Wi-Fi
module. The system is designed to integrate various sensors and actuators for home automation,
ensuring enhanced security and data integrity through blockchain technology. This section will
elaborate on each component, communication protocols, software architecture, and the overall
implementation process.
The hardware setup for the smart home automation system includes a variety of sensors,
actuators, and modules that work together to create an interconnected, intelligent environment.
The ESP32 is a powerful, low-cost microcontroller with integrated Wi-Fi and Bluetooth
capabilities. It serves as the main controller in this project, processing data from sensors,
controlling actuators, and managing communication with the local server and blockchain
network.
❖ Specifications:
• GPIO Pins: 34
51
Figure 11:ESP32 Wi-Fi module
3.2.2 Sensors
Sensors are critical for detecting environmental changes and user interactions. The system
utilizes multiple sensors to gather data and control various home appliances.
The LDR sensor detects the intensity of ambient light and adjusts lighting accordingly. It is
• Working Principle: The resistance of the LDR decreases with increasing light
intensity, allowing the ESP32 to measure the voltage change and determine the light
level.
availability.
52
Figure 12: LDR Sensor
The PIR sensor detects motion within its range, providing an efficient method for security and
• Working Principle: It senses infrared radiation emitted by warm objects (e.g., humans)
• Applications: Triggering lights and alarms upon detecting movement in designated areas.
Temperature sensors monitor the room temperature, enabling the system to control fan speed and
53
• Working Principle: These sensors measure temperature using semiconductor materials
temperatures.
The IR sensor controls the garage door mechanism, adding convenience and security to the
system.
• Working Principle: It emits infrared light and detects reflections from nearby objects to
commands.
54
Figure 15:IR Sensor
3.2.3 Actuators
Actuators perform actions based on commands from the ESP32, such as turning on lights,
3.2.3.1 Fans
The system includes two fans with distinct operational modes to maintain comfortable indoor
temperatures.
• Fan 2: Features speed control between 25°C and 50°C, offering variable cooling based
on temperature.
• Control Mechanism: Controlled via PWM (Pulse Width Modulation) signals from the
ESP32.
55
Figure 16: 5V fans
3.2.3.2 Lights
Lights are controlled based on inputs from the LDR and PIR sensors, ensuring efficient use of
• Automatic Control: Lights turn on/off based on ambient light levels and detected
motion.
• Manual Override: Users can manually control lights via the web interface.
The door lock mechanism provides enhanced security, allowing users to lock/unlock doors
remotely.
56
Manual Control: Users can operate the lock through the web interface, providing convenience
and security.
Integration: Connected to the ESP32 for real-time control and status monitoring.
The ESP32 camera module captures images for security purposes, with data stored on the IOTA
❖ Specifications:
• Resolution: Up to 2 Megapixels
A 16*2 LCD display shows real-time temperature and fan speed, providing users with immediate
❖ Specifications:
57
• Interface: Interfaced with the ESP32 using I2C or parallel communication
The software architecture integrates various modules for data collection, processing, control, and
communication. It encompasses the local HTTP server, web interface, and blockchain integration.
The local HTTP server hosted on the ESP32 allows real-time data access and device control
❖ Functionality:
The web interface provides a user-friendly platform for monitoring and controlling the home
automation system.
❖ Features:
58
• Real-time data visualization (temperature, light levels, etc.)
The ESP32 camera module connects to the IOTA blockchain, storing image data securely and
59
• Blockchain Platform: IOTA Tangle, known for its scalability and feeless transactions.
The system uses HTTP for communication between the web interface and the ESP32 module.
Sensor data is transmitted via GPIO pins, and blockchain transactions are managed through the
IOTA Tangle.
The HTTP protocol is utilized for communication between the ESP32's local server and the web
• Requests: GET requests for retrieving data, POST requests for sending commands.
The ESP32 communicates with sensors and actuators through its GPIO pins, reading sensor data
60
• PWM Outputs: Controlling fan speed and light intensity.
The IOTA blockchain ensures secure and immutable storage of image data captured by the
• Transaction Management: Using the IOTA protocol for secure, feeless transactions.
Sensors are connected to the ESP32, which reads data periodically. The LDR and PIR sensors
control lighting, while temperature sensors regulate fan operation. The IR sensor manages the
garage door mechanism. The ESP32 processes sensor data and sends it to the local HTTP server
61
3.5.1 LDR Sensor Integration
The LDR sensor is connected to an analog input pin on the ESP32, allowing it to measure
• Data Processing: The ESP32 converts the analog signal to a digital value representing
light levels.
• Control Logic: Lights are turned on/off based on predefined light level thresholds.
The PIR sensor is connected to a digital input pin on the ESP32, providing a binary signal
• Data Processing: The ESP32 monitors the digital signal for changes indicating motion.
• Control Logic: Lights and alarms are triggered based on motion detection.
Temperature sensors can be either digital or analog, interfaced with the ESP32 for temperature
readings.
The IR sensor is connected to a digital input pin on the ESP32, detecting the presence of objects.
• Data Processing: The ESP32 interprets the digital signal to determine object proximity.
62
3.6 Device Control Mechanisms
The system offers two modes of operation: automatic and manual, providing flexibility and
In automatic mode, sensors control devices based on predefined thresholds and conditions.
Manual mode allows users to control devices via the web interface, overriding automatic settings.
To ensure the security and integrity of the system, the following measures are implemented:
Images captured by the ESP32 camera are hashed and stored on the IOTA blockchain, ensuring
• Data Hashing: Before storing, images are hashed to create a unique identifier.
• Blockchain Storage: Hashes are stored on the IOTA Tangle, securing the data.
Encryption and authentication mechanisms are employed on the local HTTP server to prevent
unauthorized access.
63
• Encryption: HTTPS ensures secure data transmission.
Each component was tested individually and as part of the integrated system. The sensors were
evaluated for accuracy, actuators for responsiveness, the web interface for usability, and
Sensors were tested under various conditions to ensure accurate readings and reliable
performance.
Actuators were tested for responsiveness and reliability in different operational scenarios.
• Door Lock: Tested for remote operation via the web interface.
The web interface was tested for usability, responsiveness, and real-time data updates.
64
• Data Updates: Confirmed real-time data display and status updates.
Appendix
3.13 Code
The code for the ESP32 and its integration with sensors, actuators, and the web interface is
provided in the appendix. The code includes functions for reading sensor data, controlling
#include <WiFi.h>
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP32Servo.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define DHTPIN 27
int pir = 14;
int ldr = 36;
int fan_pin = 15;
int fan_speed = 0;
int ir_sens = 32;
float h,t = 0;
Servo myservo;
int pos = 0;
int servoPin = 23;
int doorLockState = 0; // 0 for unlocked, 1 for locked
WiFiServer server(80);
String header;
String relay1State = "off";
String relay2State = "off";
String light_status = "OFF";
String motion_status = "No";
String modeState = "auto";
65
unsigned long currentTime = millis();
unsigned long previousTime = 0;
const long timeoutTime = 2000;
int m1 = 17;
int m2 = 16;
void setup()
{
Serial.begin(115200);
lcd.init();
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("SMART HOME");
pinMode(m2,OUTPUT);
pinMode(m1,OUTPUT);
pinMode(ir_sens,INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
pinMode(AUTO_PIN, INPUT_PULLUP);
pinMode(fan_pin, OUTPUT);
pinMode(ldr, INPUT);
pinMode(pir, INPUT);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
lcd.clear();
lcd.print(WiFi.localIP());
server.begin();
dht.begin();
66
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
myservo.setPeriodHertz(50);
myservo.attach(servoPin, 500, 2400);
myservo.write(0);
delay(3000);
lcd.clear();
}
void loop() {
WiFiClient client = server.available();
if (client)
{
currentTime = millis();
previousTime = currentTime;
Serial.println("New Client.");
String currentLine = "";
if (c == '\n') {
if (currentLine.length() == 0) {
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
client.println("<link rel=\"icon\" href=\"data:,\">");
client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
client.println(".button { background-color: #4CAF50; border: none; color: white; padding: 16px 40px;");
client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
client.println(".button2 {background-color: #555555;}");
client.println(".switch {position: relative; display: inline-block; width: 60px; height: 34px;}");
client.println(".switch input {display:none;}");
67
client.println(".slider {position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc;
-webkit-transition: .4s; transition: .4s;}");
client.println(".slider:before {position: absolute; content: \"\"; height: 26px; width: 26px; left: 4px; bottom: 4px;
background-color: white; -webkit-transition: .4s; transition: .4s;}");
client.println("input:checked + .slider {background-color: #2196F3;}");
client.println("input:focus + .slider {box-shadow: 0 0 1px #2196F3;}");
client.println("input:checked + .slider:before {-webkit-transform: translateX(26px); -ms-transform:
translateX(26px); transform: translateX(26px);}");
client.println("</style></head>");
client.println("<h2>Controls</h2>");
client.println("<p>BULB ROOM1 - State " + relay1State + "</p>");
if (relay1State == "off") {
client.println("<p><a href=\"/26/on\"><button class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/26/off\"><button class=\"button button2\">OFF</button></a></p>");
}
client.println("</body></html>");
client.println();
break;
} else {
currentLine = "";
}
} else if (c != '\r') {
currentLine += c;
}}}
header = "";
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
68
}
float h = dht.readHumidity();
float t = dht.readTemperature();
lcd.setCursor(0,0);
lcd.print("T:");
lcd.setCursor(0,1);
lcd.print(t);
lcd.setCursor(6,0);
lcd.print("H:");
lcd.setCursor(6,1);
lcd.print(h);
if(digitalRead(ir_sens) == HIGH)
{
digitalWrite(m1,HIGH);
digitalWrite(m2,LOW);
delay(2000);
digitalWrite(m1,LOW);
digitalWrite(m2,LOW);
digitalWrite(m2,HIGH);
digitalWrite(m1,LOW);
delay(2000);
digitalWrite(m1,LOW);
digitalWrite(m2,LOW);
}
lcd.setCursor(12,1);
lcd.print(motion_read);
if (ldr_read == HIGH)
{
light_status = "ON";
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
} else
{
light_status = "OFF";
// digitalWrite(relay1,LOW);
// digitalWrite(relay2,LOW);
}
delay(1000);
}
69
Chapter 4: Results/Case Studies
4.1 Overview
This chapter presents the results and case studies from the implementation and testing of the
blockchain-driven smart home automation system using the ESP32 Wi-Fi module. The primary
scenarios. Various tests were conducted to evaluate sensor accuracy, actuator responsiveness,
user interaction through the web interface, and the integrity of data stored on the blockchain.
Testing the smart home automation system involved several steps to ensure each component
functioned as intended. These steps included sensor accuracy tests, actuator performance
The sensors used in the system were tested to confirm they provide accurate readings under
different conditions.
• LDR Sensor: The LDR sensor was placed in environments with varying light levels. It
accurately detected changes in ambient light and adjusted the lighting accordingly. The
sensor showed high sensitivity to even minor changes in light intensity, which was
70
Figure 33: LDR Sensor Setup
• PIR Sensor: The PIR sensor's motion detection capabilities were tested by moving
within its range. The sensor reliably detected motion and triggered the lighting and
security alerts as expected. It was responsive to human presence while filtering out false
• Temperature Sensor: Both digital and analog temperature sensors were tested over a
wide range of temperatures. The sensors provided consistent and accurate temperature
readings, allowing the system to maintain comfortable indoor conditions by adjusting fan
71
4.2.2 Actuator Performance
Actuators, including fans, lights, and door locks, were evaluated to ensure they responded
• Fans: The fans were tested for their ability to adjust speed based on temperature readings.
Fan 1 activated when the temperature exceeded 25°C, while Fan 2 provided variable
speed control between 25°C and 50°C. The fans responded quickly to temperature
• Lights: The lighting system was tested in both automatic and manual modes. In
automatic mode, lights adjusted based on LDR and PIR sensor inputs. In manual mode,
users could control lights through the web interface. The lights responded promptly to
72
Figure 36: Lighting Control in Automatic and Manual Modes
• Door Lock: The door lock mechanism was tested for remote operation via the web
interface. Users could lock and unlock doors securely and without delay. The lock
73
Figure 37: Door Lock Remote Operation Test
The web interface was assessed for ease of use, responsiveness, and real-time data updates.
• Ease of Use: The interface was designed to be intuitive, with clear navigation and user-
friendly controls. Users could easily monitor sensor data and control actuators from their
devices.
seamless experience. Real-time updates of sensor readings and actuator status were
• Real-Time Data: The web interface successfully displayed real-time data from all
connected sensors, allowing users to make informed decisions about home automation
settings. The system reliably updated data and reflected changes instantly.
74
Figure 38: Web interface
The integration of the IOTA blockchain with the ESP32 camera module was tested to ensure
• Image Hashing: Images captured by the camera were hashed before being stored on the
IOTA blockchain. This process ensured that each image had a unique identifier,
• Blockchain Storage: The hashed images were stored on the IOTA Tangle, a distributed
ledger that provides scalability and feeless transactions. The stored hashes were
successfully retrieved and verified, confirming the integrity and security of the data.
To further demonstrate the effectiveness of the smart home automation system, two case studies
75
4.3.1 Case Study: Residential Home
Background: The system was installed in a single-family home to automate lighting, climate
Implementation: Sensors and actuators were strategically placed throughout the house. LDR
sensors were installed near windows, PIR sensors in hallways and common areas, temperature
sensors in each room, and IR sensors at the garage entrance. Fans, lights, and door locks were
Results:
76
• Energy Efficiency: The automatic lighting control significantly reduced electricity
consumption by turning off lights when natural light was sufficient or when rooms were
unoccupied.
• Security: The integration of PIR sensors and the ESP32 camera module enhanced home
security. Motion detection triggered alerts and recorded images were securely stored on
• User Feedback: Residents appreciated the convenience and efficiency of the system.
They found the web interface easy to use and valued the ability to monitor and control
4.4 Analysis
The smart home automation system demonstrated high reliability, responsiveness, and security in
both residential and office settings. Sensor data was accurate and effectively used to control
various actuators, ensuring energy efficiency and comfort. The web interface provided an
intuitive user experience, and blockchain integration ensured data integrity and security.
Key Findings:
and manually.
• Usability: The web interface was user-friendly, offering seamless interaction with the
system.
77
• Security: Blockchain integration successfully secured data, preventing tampering and
unauthorized access.
4.5 Conclusion
The blockchain-driven smart home automation system using the ESP32 Wi-Fi module proved to
be an effective solution for modern home and office environments. It enhanced energy efficiency,
comfort, and security while providing a user-friendly interface for monitoring and control. The
use of blockchain technology ensured data integrity, making the system reliable and secure.
78
Chapter 5: Conclusion
This thesis detailed the creation of a blockchain-driven smart home automation system using the
ESP32 Wi-Fi module. The goal was to develop an efficient, secure, and user-friendly solution for
managing home automation tasks while ensuring data integrity through blockchain technology.
The system effectively integrated sensors (LDR, PIR, temperature, and IR) to monitor
environmental conditions and detect human presence. Actuators, including fans, lights, and door
locks, responded accurately to sensor inputs and user commands from a web interface. The
interface was designed to be intuitive, providing real-time updates and seamless control. The
IOTA blockchain was utilized to secure data, particularly images from the ESP32 camera,
Testing confirmed the system's effectiveness in real-world scenarios. Sensors provided accurate
readings, actuators responded promptly, and the web interface was user-friendly. Blockchain
Case studies in residential and office settings demonstrated practical benefits. In homes, the
system improved energy efficiency, comfort, and security, receiving positive feedback from
users. In offices, it enhanced productivity and energy savings, with staff appreciating the
In summary, this project demonstrated that combining IoT devices with blockchain can create a
reliable and secure smart home automation system. The successful implementation shows
promise for future enhancements, such as increased scalability, improved user interface, and
integration of machine learning. The system's ability to enhance energy efficiency, comfort, and
79
Chapter 6: Suggestions for Future Work
While this thesis successfully developed a blockchain-driven smart home automation system
using the ESP32 Wi-Fi module, several areas for future enhancement have been identified:
Future work should focus on expanding the system's scalability to support larger environments
and more devices. Optimizing network architecture will be essential to manage increased data
traffic effectively.
Developing a more sophisticated web interface with features such as voice control, detailed
analytics, and customizable dashboards could significantly improve user experience. Integrating
voice assistants like Alexa or Google Assistant would offer seamless voice command capabilities.
Incorporating machine learning algorithms can enhance the system's ability to predict user
behavior and optimize settings. This would make the smart home more intuitive and efficient,
While IOTA was used for this project, exploring other blockchain technologies like Ethereum or
Hyperledger could provide additional benefits. Evaluating these platforms for security,
transaction speed, and ease of integration will help determine their suitability for smart home
applications.
80
Improving security is crucial. Future research should implement advanced encryption techniques,
multi-factor authentication, and intrusion detection systems to protect against cyber threats and
Incorporating energy harvesting methods, such as solar-powered sensors and actuators, could
make the system more sustainable. This would reduce reliance on external power sources and
Ensuring compatibility with a broader range of smart home devices and platforms will increase
the system's versatility. Developing protocols and APIs for seamless integration with existing
ecosystems is essential.
81
References:
1. https://www.google.com/search?q=investigating_smart_home_security_is_blockchain_the_a
nswer&rlz=1C1ONGR_enPK1025PK1025&oq=&gs_lcrp=EgZjaHJvbWUqCQgAEEUYOxj
CAzIJCAAQRRg7GMIDMgkIARBFGDsYwgMyCQgCEEUYOxjCAzIJCAMQRRg7GMI
DMgkIBBBFGDsYwgMyCQgFEEUYOxjCAzIJCAYQRRg7GMIDMgkIBxBFGDsYwgPS
AQkxMDgwajBqMTWoAgiwAgE&sourceid=chrome&ie=UTF-8
2. https://hammer.purdue.edu/articles/thesis/Blockchain
Based_Security_Framework_for_the_Internet_of_Things_and_Home_Networks/14497731
3. https://www.researchgate.net/publication/380570563_Smart_Lab_An_IoT-
centric_Approach_for_Indoor_Environment_Automation
4. https://arxiv.org/pdf/2401.02451
5. https://scholar.google.com.pk/scholar?hl=en&as_sdt=0%2C5&q=An+IOT+Based+Home+A
utomation+and+Chemical+Detector+with+Real+Time+Data+Analysis+by+Amina+Kumku
m+16366010&btnG=
6. https://scholar.google.com.pk/scholar?hl=en&as_sdt=0%2C5&q=Secure+Home+Calling+Be
ll+Sanjeeva+Polepaka1*%2C+R.+P.+Ram+Kumar1%2C+P.+Likith+Kumar2%2C+Karthik
+Vajja2&btnG=
7. https://scholar.google.com.pk/scholar?hl=en&as_sdt=0%2C5&q=IOT+BASED+MONITOR
ING+AND+AUTOMATION+SYSTEM+FOR+A+SMART+HOME+By+Md.+Riffat+Haide
r+19271002&btnG=
8. https://scholar.google.com.pk/scholar?hl=en&as_sdt=0%2C5&q=DEVELOPMENT+OF+A
+SECURE+SENSOR+SYSTEM+FOR+THE+INTERNET+OF+THINGS+%E2%80%93+G
athering+and+visualizing+data+from+IoT+sensors&btnG=
82
9. https://www.cs.ucf.edu/~czou/research/Bryan-Pearson-Dissertation-2023.pdf
83