OVERVIEW
INTRODUCTION
Technology is continuously transforming our lives, driving improvements in living standards As individuals seek to enhance their home comfort, the challenge arises when managing multiple electronic appliances across spacious homes Homeowners often find it inconvenient to manually control devices in different rooms, highlighting the need for a more efficient solution.
A key benefit of a home automation system is the ability for homeowners to remotely control their electronic appliances with ease, ensuring convenience and peace of mind This technology enhances comfort and enjoyment, allowing users to manage their household devices effortlessly.
Tracking environmental conditions is crucial, as they can significantly impact health, particularly for vulnerable groups like infants and the elderly Therefore, having an adjustable appliance that adapts to these changing environmental factors is essential for maintaining a safe and healthy living space.
Managing power bills can be challenging, but a home automation system offers a solution by monitoring and controlling household appliances, ultimately helping to reduce electricity expenses.
To sum up, from the criteria mentioned above, we decided to “DESIGN AND
IMPLEMENT MONITORING AND CONTROL APPLIANCE SYSTEM USING WEBSITE” to serve the target customers.
OBJECTIVE
Create an IoT system utilizing the ESP32 to monitor environmental conditions and manage household electronic appliances This system features two operational modes: Manual and Remote Users can conveniently track and control their appliances via a dedicated website, and they have the option to add new nodes to the system directly through the site.
LIMITATION
The project has some limitations:
• Does not have a mobile app
• Uses 5V power supply for each node and gateway
• Does not have a backup battery in any emergency case
RESEARCH CONTENT
The thesis has implementation following the contents:
• Content 1: Refer to the document, research, and summarize
• Content 3: Design, calculate and simulate the system and implement the system on the test board
• Content 4: Design and construction of hardware
• Content 6: Programming to create websites
• Content 7: Complete the system and construct the PCB
• Content 8: System test on the PCB
• Content 10: Prepare slides for defense
This chapter shows the reason for choosing the topic, the scope, and the limitation of the project
This chapter presents the basic theory which is applied to the project
This chapter provides the calculation, design, and implementation components of the system
This chapter presents the method to construct the system and the test result on the PCB
• Chapter 5: CONCLUSION AND FUTURE WORKS
This chapter presents the result of the overall system and the reformative in the future
LITERATURE REVIEW
The Home Automation System
Advancements in technology have led to a growing desire for increased comfort in homes To adapt to contemporary lifestyles, individuals are utilizing control systems for various electronic devices These systems can operate automatically or be managed remotely by users Many modern devices have embraced this concept, enhancing convenience and efficiency in everyday living.
In today's world, remote-controlled devices are increasingly prevalent, enhancing user safety, particularly in hazardous situations The advent of the Internet has revolutionized our lives, giving rise to the Internet of Things (IoT) concept, which encompasses a variety of devices, ideas, and protocols designed to improve convenience and comfort As a result, smart homes are gaining popularity, reflecting society's desire for innovative solutions that simplify daily living.
A smart home, often referred to as a smart house, is defined as a residence that integrates advanced automation systems, enabling residents to monitor and control various functions within the home Key features of a smart home include the management of lighting, temperature, multimedia, security, and the operation of windows and doors, among other capabilities.
Smart wearable devices like watches, bracelets, and glasses are gaining popularity in countries worldwide, including Vietnam These devices serve multiple purposes, such as monitoring health, providing weather updates, and displaying time Their compact design also allows them to function as stylish jewelry, contributing to their appeal As a result, manufacturers are reaping significant profits from the growing demand for these innovative gadgets.
A fire alarm system is an essential component of any home automation setup, prioritizing safety above all else Thanks to advancements in technology, modern fire alarm systems are compact and seamlessly integrate with various systems, enhancing overall home security.
The project involves constructing a wireless sensor network using an Arduino microcontroller and sensors such as flame, gas, and DHT11 to gather environmental data This system enhances application possibilities in both residential homes and larger buildings with multiple rooms Additionally, it features a warning notification system that alerts users via their mobile devices.
Introduction of Monitor and Control System
The remote control system is gaining popularity worldwide, driven by the demand for convenience and comfort in modern living To enhance these aspects, a home monitoring and controlling system has become essential for every household.
The system can be operated on a website for remote control or manual operation The connection between each node is established by using the ESP-NOW protocol
To carry out the design of the hardware as well as the software the team researched some of the concepts described below
A MAC address is a unique identifier assigned to a network interface controller, facilitating communication at the data link layer It serves as a network address for various IEEE 802 networking technologies, such as Ethernet and Wi-Fi In the OSI reference model, MAC addresses operate within the media access control sublayer.
The MAC address is a hexadecimal number (number range 0-9, A-F), consisting of
6 octets, each equal to 8 bits, represented by 6 different pairs of digits or characters, separated by a comma, two dots, or a hyphen
Network nodes like routers and layered switches require a unique MAC address for each device within the same network In contrast, devices that are connected to separate networks can utilize the same MAC address without conflict.
Broadcast MAC addresses are essential for communication within a network, as they represent all devices connected to it The broadcast MAC address, identified by the destination address FF-FF-FF-FF-FF-FF, enables Ethernet frames to be sent to every computer within a local area network (LAN) segment When a source device needs to transmit data to all devices on the network, it can simply utilize this broadcast address as the destination MAC address.
The ESP-NOW protocol, developed by Espressif, enables wireless communication for sharing small data between ESP boards Its unique pairing process, which utilizes a device's Mac address, minimizes the risk of transmitting data to the wrong destination, ensuring more reliable connections.
The five layers from the traditional OSI model are becoming one layer in the ESP-
The NOW model optimizes ESP-NOW by minimizing packet loss during transmission and enhancing response times, as data bypasses the application, presentation, session, transport, and network layers.
For an example of Figure 3, the ESP-NOW protocol can establish the communication between 3 boards by using Mac address
There are some advantages and limitations to this protocol:
The ESP-NOW protocol enables low-power connections between two boards without relying on Wi-Fi, as it requires initial pairing for devices to exchange data efficiently.
+ The ESP-NOW protocol’s connection between two boards is called a Node
In the event that a Node experiences downtime due to power issues or a restart, the protocol ensures continuous operation by maintaining the connection until the affected Node is back online, while simultaneously connecting to the alternative Node.
+ Can establish the connection to up to 20 devices which is a huge amount of boards
+ Support long-range communication even if the devices are separated by walls
+ The data capacity that the ESP-NOW protocol can transfer is up to 250 bytes but also this is a limitation
+ Using only for the ESP board
Firebase is Google's free platform widely used in the IoT field Data management is straightforward, simple to use, and connects to the MCU Firebase gradually took its place
Firebase enables seamless data transmission and device control over long distances, making it an ideal choice for IoT applications Its NoSQL database facilitates efficient management of data streams from microcontroller-attached devices.
HTML, or Hypertext Markup Language, is essential for structuring and organizing content on websites and applications, allowing users to define elements such as paragraphs, headings, links, and block quotes It's important to note that HTML is not a programming language, which means it lacks the capability to create dynamic functions.
It's like Microsoft Word is used to lay out and format document pages HTML uses a simple code structure (tags and attributes) to mark up the web page
CSS, or Cascading Style Sheets, is a language that enhances the style and color of a website, allowing for customization based on user preferences When combined with HTML, CSS creates a more flexible and user-friendly interface for websites.
JavaScript is a versatile programming language that enhances website interactivity and user engagement It facilitates communication between the client and server, making it essential for dynamic web applications With a rich set of libraries, including Array, Date, and Math, JavaScript also offers core programming features such as operators, data structures, and statements, making it a fundamental tool for developers.
Representing the function depends on the programmer The trio is called a block building website The combination of three language above is dominated in the website development
DESIGN AND IMPLEMENTATION
SYSTEM REQUIREMENTS
This project focuses on developing a smart system that enables users to monitor their environment and control household electronic appliances via a website It offers two operational modes: manual, where users can activate appliances using a touch sensor, and remote, which allows for direct control through the website Additionally, the platform will showcase environmental parameters and includes a feature for users to add nodes, facilitating model expansion The system operates in real-time and is compatible with a variety of household electronic devices.
BLOCK DIAGRAM
The overall model consists of three key components: the gateway, the node that connects to the sensors and relays, and the system's power supply.
Figure 3-1: Block diagram of the system
The gateway serves as a vital node within a network, acting as an access point for data transmission and connecting to another network through the ESP-NOW communication protocol Essentially, it functions as the central hub of the system for this project.
The gateway assumption functions as both a receiver and transmitter, collecting data from connected nodes equipped with sensor blocks and relays, and then sending this information to the Firebase server.
The sensor from nodes is connected to many sensors like Flame, Rain, DHT11, Light, and MQ2 Each node is working independently and sends all the data collected to a gateway
The node manages the electronic device either via a website or through a touch sensor Upon receiving control commands from the gateway, the node effectively operates the device remotely The entire system is designed to function with a power supply of 5V DC and 220V AC, suitable for household electronics.
Last but not least is the website for users to interact with the system as well as receiving alerts and sensor data.
DETAIL HARDWARE DESIGNS
3.3.1 The microcontroller for node and gateway
The ESP32 chip serves as the foundation of this module, offering scalability and adaptability with individually controllable dual CPU cores Its adjustable clock frequency ranges from 80 MHz to 240 MHz, supporting Real-Time Operating Systems (RTOS) This versatile module, known as ESP-WROOM-32s, features general-purpose Wi-Fi, Bluetooth, and Bluetooth Low Energy (BLE) capabilities.
The module seamlessly integrates traditional Bluetooth, Bluetooth Low Energy, and Wi-Fi, offering versatile communication options With Wi-Fi enabling direct internet connections through routers and Bluetooth facilitating mobile phone connectivity and BLE Beacon broadcasting, this module supports data rates up to 150 Mbps and an antenna output power of 20 dBm Its industry-leading specifications ensure exceptional performance in high integration, extended wireless transmission distance, low power consumption, and robust network connectivity.
• WIFI Frequency Range 2.4GHz ~ 2.5GHz
• Clock frequency adjustment range from 80 MHz to 240 MHz, support for RTOS
• Built-in 2-channel 12-bit high-precision ADC with up to 18 channels
• Support UART/GPIO/ADC/DAC/SDIO/SD card/PWM/I2C/I2S interface
• Support multiple sleep modes, ESP32 chip sleep current is less than 5 μA
• Supports STA/AP/STA + AP operation mode
• Supports remote firmware upgrade (FOTA)
• General AT commands can be used quickly
When selecting a microcontroller for the ESP-NOW protocol, the ESP32 and ESP8266 are the primary options Our team opted for the ESP32 due to its superior features, including larger FLASH memory, faster processing speed, and more GPIOs, despite its slightly higher market price.
The node is essential in the system as it connects multiple sensors and relays, facilitating data transmission to the gateway The model comprises two nodes.
The system is equipped with various sensors, including flame, smoke, gas, temperature and humidity, and rain sensors, all connected to a central node Additionally, it features four relays that enable the control of household electronic appliances.
The relays are connected to Node through the following pinouts which were described in Table 1
The diagram illustrates the wiring linked to the microcontroller of the sensor Accordingly, our team has provided the sensor's pinout connected to the node, as detailed in Table 2.
Touch Sensor GPIO2, GPIO5, GPIO15, GPIO18
Depending on the feature and compatibility with the system, our group need to choose suitable components
The rain sensor is an affordable and efficient module for IoT applications, functioning as a switch that detects rain status.
The rain sensor consists of two main components: an operational amplifier and a copper plate The operational amplifier measures and amplifies resistance to produce either a digital or analog output signal Meanwhile, the copper plate collects data from raindrops, generating parallel resistance that triggers the operational amplifier to perform calculations based on the detected rainfall.
The rain sensor is an ideal choice for various IoT systems, offering a cost-effective solution with high accuracy and ease of use Its ability to support both analog and digital signals provides users with great flexibility Given these advantages, our team opted for a rain sensor that is compatible with our system.
● Pin1 (VCC): It is a 5V DC pin
● Pin2 (GND): it is a GND (ground) pin
● Pin3 (DO): It is a low/ high output pin
● Pin4 (AO): It is an analog output pin
DHT11 is the sensor used to evaluate the humidity and temperature of the environment The sensor is very popular and has high accuracy while getting the data
DHT11 uses a capacitive humidity sensor and thermistor which is integrated inside the sensor along with the built-in preprocessor to help get the data faster without calculation
Due to its cheap and popularity on the market and high accuracy, our group decided to choose this sensor to obtain the humidity and temperature environment surrounding
• Humidity measurement: 20% - 90% RH, error ± 5% RH
• Sampling frequency: 1Hz, which means 1 second DHT11 gets samples once
The MQ2 gas sensor is designed to detect flammable gases that could potentially cause fires It utilizes the semiconductor SnO2, which exhibits low sensitivity in clean air but shows a significant change in conductivity when exposed to combustible substances This unique property allows for the integration of a simple circuit that converts the sensor's sensitivity into a measurable voltage, enhancing its functionality in safety applications.
When the environment is clean, the output voltage of the sensor is low, and the output voltage value increases as the concentration of combustible gas around MQ2 is higher
MQ2 works very well in liquefied petroleum gas (LPG), H2, and other combustible gas It is widely used in industry and civil because of its simple circuit and low cost
The compact MQ2 gas sensor, measuring 32 x 20 x 20mm, is an ideal solution for our group system, as it is specifically designed to detect gas leaks in the surrounding environment, distinguishing it from other sensors in the MQ series.
There are 4 pins for the gas sensor:
• Digital output: This pin will give an output as a digital signal
• Analog output: This pin will give an output as an analog signal
• Output: analog and digital signal
A flame sensor is a specialized detector designed to identify and respond to fire or flame occurrences, significantly impacting the reaction time of flame detection Equipped with a fire suppression system, propane line, natural gas line, and alarm system, it is commonly used in commercial boilers to ensure proper operation verification Flame sensors offer quicker and more accurate responses compared to traditional heat or smoke detectors, enhancing safety measures in fire-prone environments.
Our team selected flame sensors that are cost-effective, highly accurate, and widely available in the market These sensors operate within a range of up to 1100 nm and are designed to minimize false alarms Additionally, they have a lifespan of up to five years, making them a reliable choice for our system.
There are 4 pinouts for the flame sensor:
• Pin1 (VCC pin): Voltage supply rages from 3.3V to 5.3V
• Pin2 (GND): This is a ground pin
• Pin3 (AOUT): This is an analog output pin
• Pin4 (DOUT): This is a digital output pin
A touch sensor is an electronic device designed to detect a single touch, functioning similarly to a switch These sensors effectively replace mechanical switches in various applications, including lamps, touch screens, and doors, by sensing the measured interface.
Our team opted for touch sensors over traditional buttons due to their cost-effectiveness and stylish design, making them ideal for automation systems without requiring additional power sources.
By sensing the radiant energy that exists in a relatively small range of frequencies often referred to as "light," which ranges in frequency from "Infra-red" to "Visible" up to
"Ultraviolet" light spectrum, a light sensor produces an output signal that indicates the intensity of light
The light sensor is a passive component that produces an electrical signal from this
SOFTWARE DESIGN
3.4.1 Flowchart of Node and Gateway
The programming of the project is divided into 2 parts: the gateway and the nodes
The gateway initiates the pairing process if there is an open request to add a new node; otherwise, it receives user commands via Firebase and relays them to the nodes Simultaneously, it collects sensor data, including fire and gas sensor values, and uploads this information to Firebase If any incidents are detected, an alarm is triggered from the website.
The node initiates the pairing process upon detecting an open pairing request and a signal from the gateway If no pairing signal is present, it gathers sensor data and transmits it to the gateway via ESP-NOW, while also receiving commands to manage the sockets During this operation, the fire and gas sensor readings are continuously monitored, and if any anomalies are detected, an alarm will sound to alert individuals nearby the node module.
3.4.2 Flowchart of node pairing process
Pairing nodes is a standout feature of the project, allowing users to easily connect new nodes via the website However, it's important to note that the ESP-NOW protocol limits the system to pairing a maximum of 20 devices.
To initiate the pairing process, the system must first receive a pairing signal from the gateway command for authentication Upon successful authentication, the system will verify the existence of the Gateway’s MAC address in memory, leading to two potential outcomes.
Case 1: If the Gateway’s Mac address exists in memory, it will pass and end the pairing process
Case 2: If the Gateway’s Mac address does not exist in memory, the pairing process begins by sending a template with the node’s MAC address
During the initial user pairing on the website, a command is dispatched to each node for pairing If the gateway detects a signal response from a node, two possible scenarios arise.
Case 1: If the gateway receives the response signal from the node, the gateway writes the new node’s MAC address into memory
Case 2: If the gateway does not receive any response signal from node, it will end the gate pairing process
SYSTEM CONSTRUCTION
INTRODUCTION
The group will describe how to build, assemble, and inspect hardware in this chapter as well as how to create algorithmic and software schematics for the system.
PCB Construction
Following the design in chapter 3, our group can construct the list of components show in Table 4 into a print circuit board.
Gas sensor 1 Detect gas leak
The Proteus software allows the user to create the print circuit board in a paper file The output of the print circuit board is present in figure 26
Network connection
The ESP-NOW protocol supports a broadcast mode configuration, allowing the gateway to communicate with multiple nodes without needing to identify the destination MAC address This enables seamless integration of new nodes into the network, leveraging the unique capabilities of the ESP-NOW protocol The accompanying figure illustrates the gateway's setup in broadcast mode.
In this figure 28 shows the parameters of 2 nodes including:
• Sensor parameters: the parameters of each sensor in node
• Socket: the status of outlet
• Newnode: the number of nodes paired in the network
The API to connect MCU and Firebase, Website and Firebase need to be set to communicate with each other The API of those two is provided by Firebase
Figure 4-4: The dataflow of Firebase
Firebase serves as a crucial link in this project, enabling the ESP32 to transmit sensor data and GPIO states to its database The connected website retrieves this sensor information from Firebase, allowing it to display the data and control the outputs of the ESP32 nodes effectively.
RESULT
Introduction
In this chapter, we present the outcomes of our system, detailing the hardware design, functionality, website design, and overall performance following rigorous calculations, implementation, and testing.
Finished Product
Following the calculations and design outlined in chapter 3, the team is set to create the PCB and integrate various components, including a light sensor, touch sensor, buzzer, flame sensor, ESP32 Node MCU, relay, rain sensor, and a power source to energize the node.
Instead of connecting directly, our group decided to make a jumper for each component By doing this, the broken component can be replaced easily
The system has demonstrated reliable performance over time, with a compact PCB board design that is ideal for IoT products However, a drawback is the occasional delay in sensor data transmission to the website.
The XH-M299 with a 5V DC out connects straight through to the power source to supply all the power for all components in the circuit
The ESP-Now protocol allows a single ESP32 board to function as a gateway, which is why our team chose to utilize one ESP32 for both gateway purposes and connectivity with Firebase.
Figure 5-2: The node and gateway
Our team opted not to create a printed circuit board for the ESP-NOW gateway, as it only requires a single independent board to function effectively Instead, we focused on supplying the necessary 5V power to streamline the process and save time.
Website
The website is constructed and finished based on the algorithm flow chart designed in chapter 3 Each board is separated for identification
The figure 32 shows that there are three main frames for the website:
• The main function of the green frame presents the number of Nodes The name of the node can be renamed depending on the user
• The blue frame shows the “New node” This is the adding node function button of the website
• The yellow frame has displayed the parameters of each node
The system's primary function is to monitor the surrounding environment, manage household appliances, and integrate new nodes Users have the ability to toggle the relay on and off via buttons located in the socket frame, with each button providing a status indicator.
In the event of a gas leak or flame detected in the vicinity, a popup notification appears to alert the user, while an alarm is simultaneously activated Additionally, the name of the node monitoring the situation is displayed for quick location identification.
The new node button represents the function pairing This process is shown in figure 35
When the user clicks the "New node" button, a pairing process is initiated, which is then displayed on the website to inform the user This process can occur in two different scenarios.
• The system is adding success before the timeout The new frame of the new node appears which is shown in figure 36
• The system is adding failure and the popup to notify the process fails to appear on the website which is shown in figure 37
Discussion and test execution
After completion, the function of the system our group has achieved is followed as:
• Controlling the household electronic devices manually or remotely on the website
• Tracking the parameters of the environment surrounding
• Warning of a gas leak or flame in a specific area
The system is tested with the power supply from the test board Our group has performed many tests for the system including:
• Start up the system in over 20 hours to test the communication
• Pairing different nodes to the system
• Test the stability of the relays when controlling from the website and manual with the touch sensor
Following the test, our team confirmed that the system is stable, exhibiting only a minor delay that does not impact overall performance The sensor is functioning effectively, providing accurate parameters to Firebase.
CONCLUSIONS AND FUTURE WORKS
CONCLUSIONS
The project “DESIGN AND IMPLEMENTATION MONITORING AND
The "Control Appliance System Using Website" project has been successfully completed, showcasing effective design and functionality It incorporates various hardware components, including light, rain, flame, gas, temperature and humidity sensors, as well as touch sensors, buzzers, relays, and the ESP32 microcontroller, all of which are assembled and operate reliably The software, structured according to a flowchart, aligns with the system's initial objectives of controlling household appliances, integrating new nodes, and enabling environmental monitoring through a user-friendly website.
From the outset, the project has successfully met its objectives, with all functions operating as intended The system has demonstrated long-term stability, ensuring that all components remain within safe temperature limits Users can conveniently monitor the parameters of each sensor from various nodes and check the status of all outlets via the website.
While the project offers several benefits, it also faces limitations, such as the lack of a backup battery to protect against sudden power loss, which could lead to potential damage Additionally, the data transfer capacity between nodes is limited to 250 bytes.
FUTURE WORKS
For the project to be capable of working effectively in the future, the need of improvement is very necessary
• Backup battery to avoid damage from sudden power cuts
• Expand the number of nodes instead of 20 devices
• Reduce the power anticipated in the system
[1] "What is a Smart Home?," 2013 [Online] Available: https://smarthomeenergy.co.uk/what-smart-home/
[2] E E S V Karwan Muheden, "Design and implementation of the mobile fire alarm system using wireless sensor networks," IEEE, Budapest, Hungary,
Địa chỉ MAC (Media Access Control) là một định danh duy nhất được gán cho thiết bị mạng để xác định nó trong một mạng cụ thể Trong khi đó, địa chỉ IP (Internet Protocol) là một địa chỉ logic được sử dụng để xác định vị trí của thiết bị trên internet hoặc mạng nội bộ Sự khác biệt chính giữa địa chỉ MAC và địa chỉ IP là địa chỉ MAC là cố định và không thay đổi, trong khi địa chỉ IP có thể thay đổi tùy thuộc vào mạng mà thiết bị kết nối Cả hai địa chỉ này đều đóng vai trò quan trọng trong việc định tuyến và quản lý lưu lượng dữ liệu trong các mạng máy tính Tìm hiểu thêm về sự khác biệt giữa địa chỉ MAC và địa chỉ IP tại [đây](https://wifi.fpt.net/dia-chi-mac-la-gi-phan-biet-dia-chi-mac-va-dia-chi-ip/).
[4] wujiangang, "ESP-NOW," 2022 [Online] Available: https://github.com/espressif/esp-now
[5] F Cloud, "Firebase là gì? Ưu nhược điểm & Các dịch vụ của Firebase,"
2022 [Online] Available: https://fptcloud.com/firebase-la-gi/
[6] N N Thiện, "HTML là gì? Bố cục trang web được tổ chức ra sao?,"
[Online] Available: https://lamvt.vn/html-la-gi-bo-cuc-trang-web-duoc-chuc- ra-sao/
[7] KienTT, "Kinh nghiệm tiếp cận CSS nhanh," 2020 [Online] Available: https://codelearn.io/sharing/kinh-nghiem-tiep-can-css-nhanh
[8] Geekboots, "Importance of JavaScript in web development," [Online]
Available: https://www.geekboots.com/story/importance-of-javascript-in- web-development
[9] D Bhalla, "ADD JAVASCRIPT AND CSS IN SHINY," [Online] Available: https://www.listendata.com/2018/12/javascript-shiny-r.html
[10] "Connect ESP32 and ESP8266 Send and receive data," 2020 [Online]
Available: https://wirandle.com/connect-esp32-and-esp8266-send-and- receive-data/