Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.35 MB, 85 trang )
<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">
MINISTRY OF EDUCATION AND TRAINING
<b>HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY AND EDUCATION FACULTY FOR HIGH QUALITY TRAINING </b>
<b> </b>
<b>GRADUATION PROJECT </b>
<b>COMPUTER ENGINEERING TECHNOLOGY</b>
<b>LECTURER: PHAN VAN CA</b>
<b>STUDENT: LE BA MINH DAT NGUYEN VAN QUANG HUY</b>
<small>S K L 0 1 2 5 3 8</small>
<small>THE SOCIALIST REPUBLIC OF VIETNAM </small>
<b><small>Independence – Freedom– Happiness </small></b>
---
<i><small>Ho Chi Minh City, January 9, 2024 </small></i>
Advisor: Assoc. Prof. Ph.D Phan Văn Ca Phone number: 0902994358
Date of assignment: September 3<small>rd</small>, 2023 Date of submission: January 8<small>th</small>, 2024
1. Project title: Design and implementation of smart home system.
2. Initial materials provided by the advisor: Documents such as paper about application of smart home IoT.
3. Content of the project:
▪ Analyze the challenges of the project. Learn about the technical specifications, guiding thought and theoretical basis of the components of the hardware.
▪ Propose the model and summarize the overall system. Design block diagram, principle diagram. System configuration and design hardware.
▪ Test run, check, evaluate and adjust. ▪ Conduct report writing.
4. Final product: Smart home model, device control and monitoring box, system control software, final report, demo video.
<b>CHAIR OF THE PROGRAM </b>
<i><small>(Sign with full name)</small></i>
<b>ADVISOR </b>
<i><small>(Sign with full name) </small></i>
<b>Phan Văn Ca </b>
</div><span class="text_page_counter">Trang 4</span><div class="page_container" data-page="4"><small>THE SOCIALIST REPUBLIC OF VIETNAM </small>
<b><small>Independence – Freedom– Happiness </small></b>
<small>--- </small>
<i><small>Ho Chi Minh City, January 9, 2024 </small></i>
Student name: Lê Bá Minh Đạt Student ID: 19119040 Student name: Nguyễn Văn Quang Huy Student ID: 19119030 Major: Computer Engineering Technology
Project title: Design and implementation of smart home system Advisor: Assoc. Prof. Ph.D Phan Văn Ca
<b>EVALUATION </b>
1. Content of the project:
▪ Analyze the challenges of the project. Learn about the technical specifications, guiding thought and theoretical basis of the components of the hardware.
▪ Propose the model and summarize the overall system. Design block diagram, principle diagram. System configuration and design hardware.
▪ Test run, check, evaluate and adjust. ▪ Conduct report writing
2. Strengths:
The system model proposed in the thesis makes sense. Although the prototype implemented is rather basic, it still illustrates the characteristics of the platform framework: connectivity and communication between entities in a smart home.
6. Mark: 8.0 .(in words:. Eight dot Zero)
<i>Ho Chi Minh City, January 09, 2024 </i>
<b>ADVISOR </b>
<i>(Sign with full name) </i>
<i><b>Phan Văn Ca </b></i>
</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5"><small>THE SOCIALIST REPUBLIC OF VIETNAM </small>
<b><small>Independence – Freedom– Happiness </small></b>
<small>--- </small>
<i><small>Ho Chi Minh City, January 9, 2023 </small></i>
Student name: Nguyễn Văn Quang Huy Student ID: 19119030 Major: Computer Engineering Technology
Project title: Design and implementation of smart home system Name of Reviewer: Assoc. Prof. Ph.D Phan Văn Ca
<b>EVALUATION </b>
1. Content and workload of the project
▪ Analyze the challenges of the project. Learn about the technical specifications, guiding thought and theoretical basis of the components of the hardware.
▪ Propose the model and summarize the overall system. Design block diagram, principle diagram. System configuration and design hardware.
▪ Test run, check, evaluate and adjust. ▪ Conduct report writing.
2. Strengths:
... ... ... 3. Weaknesses:
... ... ...
<i>4. Approval for oral defense? (Approved or denied) </i>
...
<i>5. Overall evaluation: (Excellent, Good, Fair, Poor) </i>
...
<i>6. Mark:……….(in words: ...) Ho Chi Minh City, January…, 2024 </i>
<b>REVIEWER </b>
<i>(Sign with full name) </i>
</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6"><small>THE SOCIALIST REPUBLIC OF VIETNAM </small>
<b><small>Independence – Freedom– Happiness </small></b>
<small>--- </small>
<i><small>Ho Chi Minh City, January 9, 2023 </small></i>
<small>Student name: Nguyễn Văn Quang Huy Student ID: 19119030 Major:Computer Engineering Technology </small>
<small>Project title: Design and implementation of smart home system Advisor: </small>Assoc. Prof. Ph.D Phan Văn Ca
<b>EVALUATION </b>
1. Content and workload of the project
▪ Analyze the challenges of the project. Learn about the technical specifications, guiding thought and theoretical basis of the components of the hardware.
▪ Propose the model and summarize the overall system. Design block diagram, principle diagram. System configuration and design hardware.
▪ Test run, check, evaluate and adjust. ▪ Conduct report writing.
2. Strengths:
... ... ... 3. Weaknesses:
... ... ...
<i>4. Overall evaluation: (Excellent, Good, Fair, Poor) </i>
...
<i>5. Mark:……….(in words: ...) Ho Chi Minh City, January…, 2024 </i>
<b>COMMITTEE MEMBER </b>
<i>(Sign with full name) </i>
</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">This is the final report, "Design and implementation of a smart home system," we proclaim. The study findings are accurate, and they were completed totally under the supervision of the teacher, Assoc. Prof. Ph.D PHAN VAN CA. The report also does not replicate any other sources. In addition, the document provides a number of referenced and labeled reference resources. I would want to completely assume responsibility for this pledge in front of the department, teachers, and school.
<b>Student LE BA MINH DAT </b>
<b>NGUYEN VAN QUANG HUY </b>
</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">First, we would like to express our heartfelt appreciation to the School Board of the Ho Chi Minh City University of Technology and Education, as well as the Faculty for High Quality Training, for creating ideal circumstances for me to pursue our project.
Furthermore, we would like to express our heartfelt gratitude to the Assoc. Prof. Phan Van Ca, who constantly monitors the learning environment and supports and develops growth chances for each generation of students.
However, while having limited time and skills to accomplish this graduation project, the group still had several flaws when learning and presenting the project. Students want professors to provide comments so that the group's project may be finished and enhanced in the future. The contributions of the professors will assist the group obtain more information in their future studies and research.
Finally, the project implementation team wishes the instructors good health, as well as continued success in their noble vocations.
Many thanks for all your help and regards.
<b>Student LE BA MINH DAT </b>
<b>NGUYEN VAN QUANG HUY </b>
</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">GRADUATION PROJECT ASSIGNMENT ... i
ADVISOR’S EVALUATION SHEET ...ii
PRE-DEFENSE EVALUATION SHEET ... iii
EVALUATION SHEET OF DEFENSE COMMITTEE MEMBER ... iv
1.5. Object and Scope of the study ... 2
1.5.1. Object of the study ... 2
1.5.2. Scope of the study ... 3
1.6. Research contents ... 3
1.7. Outline ... 3
CHAPTER 2: LITERATURE REVIEW ... 5
2.1. Internet of Thing ... 5
</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">2.1.2. IoT systems structure ... 6
2.7. DHT11 temperature and humidity sensor ... 16
2.8. MQ3 alcohol gas sensor module ... 16
2.9. Module SIM 800L V2 5V ... 17
2.9.1. Global System for Mobile communication ... 17
2.9.2. Short messaging Service ... 19
2.9.3. Introduces the SIM800L V2 module ... 20
2.10. RC522 Module RFID Reader ... 20
2.11. Energy Meter Module PZEM-004T... 21
</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">3.1. System designing ... 26
3.1.1. Customer’s needs ... 26
3.1.2. Engineering requirements ... 26
3.1.3. System model of a smart home ... 29
3.1.4. Block diagram and functions of each block ... 29
3.2.4. Smart Home control interface on Blynk App and Blynk Dashboard ... 53
CHAPTER 4: RESULTS, OBSERVATIONS, AND EVALUATIONS ... 54
</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">Figure 2.1. Internet of Things ... 6
Figure 2.2. IoT System Structure ... 7
Figure 2.3. The SPI communication model ... 9
Figure 2.4. The clock diagrams for SPI with CPHA=0 and CPHA=1 ... 10
Figure 2.5. UART communication standard ... 10
Figure 2.6. UART packet ... 11
Figure 2.7. I2C Protocol ... 12
Figure 2.8. Transmitted in the form of packets of I2C ... 13
Figure 2.9. ESP-WROOM-32 microchip ... 15
Figure 2.10. Arduino Uno R3 ... 16
Figure 2.11. DHT11 temperature and humidity sensor module ... 16
Figure 2.12. MQ3 alcohol gas sensor module ... 17
Figure 2.13. Global System for mobile (GSM) network ... 18
Figure 2.14. SIM800L V2 5V Wireless GSM GPRS module ... 20
Figure 2.15. RC522 RFID Reader with Cards Kit ... 21
Figure 2.16. Energy Meter Module PZEM-004T ... 22
Figure 2.17. 5V Relay Module ... 22
Figure 2.18. 20x4 Character LCD Display ... 23
Figure 2.19. Servo Motor Pinout (Wires) ... 24
Figure 2.20. XL4015 DC-DC Voltage Regulator ... 24
Figure 2.21. LDR Sensor Module (Light Dependent Resistor) ... 25
Figure 3.1. The overall scheme of the Smart Home system ... 29
Figure 3.2. Block diagram of Smart Home system ... 30
Figure 3.3. Principle diagram of the system model ... 37
Figure 3.4. Printed circuit board of hardware... 41
</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">Figure 3.6. Arduino IDE Interface ... 43
Figure 3.7. Operating model of Blynk IOT ... 44
Figure 3.8. Secondary microcontroller algorithm flow chart ... 47
Figure 3.9. Algorithm flow chart of subroutine "read RFID tag" ... 48
Figure 3.10. Algorithm flow chart of transmit and receive SIM ... 49
Figure 3.11. Algorithm flow chart of Primary microcontroller ... 50
Figure 3.12. Algorithm flow chart of subroutine “read input sensors” ... 51
Figure 3.13. Algorithm flow chart of subroutine “monitor air conditioner operation” ... 52
Figure 3.14. Blynk App & Blynk Dashboard ... 53
Figure 4.1. System model ... 55
Figure 4.2. The device control box ... 56
Figure 4.3. Outside lights operate in auto mode ... 56
Figure 4.4. Scan RFID card ... 57
Figure 4.5. Displays parameters on LCD ... 57
Figure 4.6. Control the device via SIM module ... 58
Figure 4.7. Graph of electricity consumption over time ... 59
</div><span class="text_page_counter">Trang 14</span><div class="page_container" data-page="14">Table 3.1. Environmental Parameters Measured: Humidity, Temperature, Gas Levels ... 28
Table 3.2. Evaluating and choosing devices for primary microcontroller ... 31
Table 3.3. Evaluating and choosing devices for display unit ... 32
Table 3.4. Evaluating and choosing devices for relay ... 32
Table 3.5. Evaluating and choosing devices for power supply ... 33
Table 3.6. Evaluating and choosing devices for module sim ... 33
Table 3.7. Evaluating and choosing devices for temperature & humidity sensor ... 34
Table 3.8. Evaluating and choosing devices for gas sensor ... 34
Table 3.9. Evaluating and choosing devices for secondary microcontroller ... 35
Table 3.10. Evaluating and choosing devices for security ... 35
Table 3.11. Evaluating and choosing devices for servo motor ... 36
Table 3.12. Evaluating and choosing devices for device activity monitoring ... 36
Table 3.13. Total current used in the circuit (ESP32) ... 39
Table 3.14. Total current used in the circuit (Arduino Uno R3) ... 40
Table 3.15. List the components used ... 45
Table 4.1. Experimental data ... 59
</div><span class="text_page_counter">Trang 15</span><div class="page_container" data-page="15"><b>ABBREVIATIONS MEANING </b>
<b>2 </b> GPIO General Purpose Input/Output
<b>3 </b> HTTP Hypertext Transfer Protocol
<b>4 </b> I2C Inter-Integrated Circuit
<b>25 </b> SPI Serial Peripheral Interface
<b>27 </b> UART Universal Asynchronous Receiver/Transmitter
<b>28 </b> IDE Integrated Development Environment
</div><span class="text_page_counter">Trang 16</span><div class="page_container" data-page="16">The incorporation of intelligent systems into homes has emerged as a clear trend in the contemporary era, as technology progressively becomes a fundamental aspect of our lives. Research on Smart Home IoT not only explores the potential for offering clever and convenient solutions for daily life but also prompts thought-provoking inquiries about human-machine interaction, safety, and the trajectory of smart living in the future.
Our project aims to create and implement a smart home system. This not only unlocks possibilities for intelligent and pragmatic solutions in daily living but also prompts engaging considerations about human-machine interaction, security, and the future of smart living.
Moreover, the project serves as an opportunity to cultivate and enhance diverse skills, ranging from programming to data management and IoT devices. Therefore, it is a journey that not only supports personal growth but also makes a positive contribution to the increasingly innovative and diverse field of information technology.
</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17"><b>CHAPTER 1: INTRODUCTION </b>
The first chapter explains the project overview, the project's research object, the project methodology, and the project goals in addition to the basic goal behind smart home system. In addition, the layout of the entire report is presented below.
<b>1.1. Introduction </b>
Applying information and communication technology to the house is becoming more and more of a trend in today's environment of ever-more-modern living, as well as a full answer to the demands of comfortable and secure living [1]. However, a lot of problems need to be fixed in order to maximize this smart living area.
Integrating security and performance in an Internet of Things (IoT)-based smart home system is one of the main problems. When it comes to linking lighting, cameras, and house gates, security is always the first concern. Effective solutions are required to solve the issues of safeguarding personal information and maintaining system security
Another difficulty is ensuring that gadgets are interoperable. Variations in standards and protocols might lead to a decrease in user experience and performance. Simultaneously, it was shown in [2] that the process of installation and management might become complex due to device integration from multiple manufacturers .
To further enhance Smart house operations and reduce adverse environmental effects, attention must also be paid to energy-saving and connection stability concerns.
The Internet of Things-based Smart Home project is not only a chance to address these issues, but it also serves as inspiration for building user-friendly, safe, and intelligent living spaces. This graduation thesis subject will undoubtedly match the rising needs of contemporary living and significantly impact the industry's development.
</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">Visually displayed on the LCD screen and on the Blynk App are display characteristics including door status, device status, temperature, humidity, gas and energy usage.
<b>1.3. Scope </b>
Control on and off low-power household appliances such as light bulbs, fans, etc.
Connecting and interacting between devices can be difficult due to latency in communication standards.
If the Internet connection is interrupted, remote monitoring and interaction capabilities will be affected.
There may be thresholds of difficulty when it comes to changing user habits.
ESP32, Arduino Uno R3 microcontroller: These are compact and popular microcontroller boards in electronic applications. These microcontrollers will be used to control other modules and components in the system.
Necessary modules and components: Includes PZEM004T used to measure power consumption, sim module 800L V2 used to transmit - receive signals to phone numbers via SMS, in addition, there are also sensors such as DHT11, MQ3 , LDR is used to measure parameters such as temperature, humidity, gas, light intensity.
</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">Programming software: The team will use the Blynk App to monitor and control home devices, and Arduino IDE to program the Arduino Uno R3 and ESP32 microcontrollers.
<b>1.5.2. Scope of the study</b>
The topic focuses on researching hardware (microcontrollers, modules and components) and software (Blynk App), to build an effective smart home system.
Learn about the ESP32 and Arduino Uno r3 circuit boards, necessary modules and components: The group will research the features, how to use and connect these modules and components to the microcontroller.
Programming microcontrollers and modules and components: The team will perform programming to control and interact between the Arduino Uno R3 and ESP32 microcontrollers with other modules and components in the system.
<b>1.6. Research contents </b>
During the implementation of graduation project with the topic "Design and implementation of smart home system ", we worked on overcoming and accomplishing the following contents:
Content 1: Analyze the challenges of the project.
Content 2: Learn about the technical specifications, guiding thought and theoretical basis of the components of the hardware.
Content 3: Propose the model and summarize the overall system. Design block diagram, principle diagram.
Content 4: System configuration and design hardware. Content 5: Test run, check, evaluate and adjust.
Content 6: Conduct report writing. Content 7: Thesis defense.
<b>1.7. Outline </b>
The research team worked hard to organize the material in the report so that readers could immediately grasp the subject's knowledge, technique, and operation. The report is divided into five chapters, which are as follows:
<i>Chapter 1: Introduction. An overview of the report and presents the reasons for selecting the </i>
topic, as well as the research objectives, scope, and limitations.
</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20"><i>Chapter 2: Liturature review. Give a clear explanation of the theoretical underpinnings of </i>
<i>this issue and list all the information that will be needed. </i>
and block functions, hardware design for the system, building algorithmic flowcharts.
hardware and software development.
<i>Chapter 5: Conclusion and Future Developments. Presenting conclusions for final project, </i>
emphasizing the benefits and drawbacks of the topic, identifying faults made by the team during implementation, and providing recommendations for future improvement.
</div><span class="text_page_counter">Trang 21</span><div class="page_container" data-page="21"><b>CHAPTER 2: LITERATURE REVIEW 2.1. Internet of Thing </b>
<b>2.1.1. Introduction </b>
As in [3], the internet of things, or IoT, is a network of interrelated devices that connect and exchange data with other IoT devices and the cloud. IOT devices are typically embedded with technology such as sensors and software and can include mechanical and digital machines and consumer objects.
Increasingly, organizations in a variety of industries are using IoT to operate more efficiently, deliver enhanced customer service, improve decision-making and increase the value of the business.
With IoT, data is transferable over a network without requiring to-human or to-computer interactions.
human-A thing in the internet of things can be a person with a heart monitor implant, a farm animal with a biochip transponder, an automobile that has built-in sensors to alert the driver when tire pressure is low, or any other natural or man-made object that can be assigned an Internet Protocol address and is able to transfer data over a network.
The potential applications of IoT are vast and diverse. In agriculture, IoT systems can monitor soil conditions, optimize irrigation, and automate crop management. Healthcare benefits from wearable devices that track vital signs, monitor patients remotely, and offer personalized treatment plans. Smart homes leverage IoT technology to control lighting, heating, and security systems, enhancing comfort and energy efficiency. In the industrial sector, Industrial IoT enables predictive maintenance, real-time asset tracking, and intelligent supply chain management, optimizing productivity and reducing costs. The widespread adoption of IoT is reshaping various industries, offering innovative solutions and improving efficiency in numerous aspects of our lives.
</div><span class="text_page_counter">Trang 22</span><div class="page_container" data-page="22">Figure 2.1. Internet of Things [3]
<b>2.1.2. IoT systems structure </b>
It was shown in [4] that the IoT technology has risen in popularity in recent years, and it has a wide range of uses. IoT apps function in accordance with how they were designed/developed depending on the many application domains. However, there is no standard specified work architecture that is rigidly followed across the board. The complexity and quantity of architectural
</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">layers differ depending on the business goal at hand. The typical and most frequently acknowledged format is a four-layer design.
Figure 2.2. IoT System Structure [4]
As depicted in the preceding diagram, there are four levels in existence: the Perception Layer, Network Layer, Processing Layer, and Application Layer.
Perception/Sensing Layer: This is the initial tier of any IoT system, comprising "things" or endpoint devices acting as a bridge between the physical and digital realms. This physical layer, housing sensors and actuators capable of receiving, accepting, and processing data across the network, is referred to as perception. Sensors and actuators can be connected wirelessly or
</div><span class="text_page_counter">Trang 24</span><div class="page_container" data-page="24">through wired connections, and the design imposes no limitations on the scope or placement of its components.
Network Layers: These layers detail how data is transmitted within an application, incorporating Data Acquiring Systems (DAS) and Internet/Network gateways.
Processing Layer: Serving as the brain of the IoT ecosystem, the processing layer is where data is typically assessed, pre-processed, and stored before being transmitted to the data center. There, it becomes accessible to software programs that monitor and manage the data while preparing subsequent actions. This is where edge IT or edge analytics comes into play.
Application Layer: User interaction takes place at the application layer, offering the user application-specific services. The Internet of Things can be deployed in various ways, such as in smart cities, smart homes, and smart health.
<b>2.2. SPI Interface </b>
<b>2.2.1. General introduction </b>
The Serial Peripheral Interface (SPI) is a widely utilized synchronous serial communication protocol employed for linking microcontrollers, sensors, memory devices, and various peripheral devices. Its purpose is to facilitate data exchange among multiple devices through a master-slave architecture. SPI is recognized for its simplicity, high speed, and versatility, contributing to its popularity in embedded systems and electronic applications.
The fundamental communication principle of SPI revolves around the master-slave mode, wherein there is typically one master device and one or more slave devices. The SPI interface is commonly denoted as a 4-wire serial bus, comprising SDI (data input), SDO (data output), SCLK (clock), and CS (chip select).
• SDO/MOSI - master device data output, slave device data input. • SDI/MISO - master device data input, slave device data output. • SCLK - clock signal generated by the master device.
• CS/SS - Slave device enable signal controlled by the master device.
On the SPI bus, multiple slave devices can appear at a time, but there can only be one master device. The master device determines the slave devices to be communicated through the chip select lines. This requires the slave device's MISO port to have three-state characteristics so that the port line will exhibit a high impedance when the device is not gated [5].
</div><span class="text_page_counter">Trang 25</span><div class="page_container" data-page="25">Figure 2.3. The SPI communication model [5]
<b>2.2.2. SPI operating principle </b>
Each Master and Slave device incorporates an 8-bit shift register along with a clock generator. During data transmission by the Master, it injects 8 bits of data into its shift register, subsequently dispatching these 8 bits through the MOSI signal line to the Slave device. Conversely, when the Slave transmits data, the bits residing in its shift register traverse to the Master via the MISO signal line.
Consequently, a data exchange occurs between the two shift registers. Simultaneous reading and writing of data into the Slave transpire, enabling rapid data interchange. Hence, the SPI protocol stands out as a remarkably efficient communication protocol.
The SPI protocol entails a configuration that dictates the timing of data reception between the master and the slave by utilizing two bits: CPOL (Clock Polarity) and CPHA (Clock Phase):
• CPOL = 0: The SCK signal is low when no data is being transmitted. CPOL = 1: The SCK signal is high when idle.
• CPHA = 0: Data is sampled on the first edge transition of the SCK signal and is changed on the second edge when CPHA = 1.
</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">Figure 2.4. The clock diagrams for SPI with CPHA=0 and CPHA=1 [5]
<b>2.3. UART Interface 2.3.1. General introduction </b>
The Universal Asynchronous Receiver/Transmitter, abbreviated as UART, represents an integrated circuit within a computer or microcontroller designed for serial communication. A microcontroller may include one or two UART peripherals. The operation of a standard UART module depends on the logic level of the control signal, requiring a matching baud rate configuration at both the transmitter and receiver ends. Data transmission is initiated by converting individual data bits into logic high, low, and stop bits [6]. The fundamental characteristics of UART include:
• <b>Universal Accepted: The speed, data size, and velocity can be configured easily to ascertain </b>
the requirements of the clients and follows the same protocol around the world.
• <b>Short Distance Transmission: UART is frequently used in short-range transmission. In </b>
wired communication, the distance can be configured in terms of baud rate. The relationship between the transmission distance and speed in UART is proportional to each other. Shorter distance results in a faster data transfer rate. The transmission distance can vary from few inches to meters on the basis of desired speed, noise generated due to external source, and quality of the external device.
• Low-Cost Protocol: The non-requirement of a clock signal and single wire utilization to transmit data keeps the hardware simple, which in turn makes it cost-efficient compared to other data transfer modules.
Figure 2.5. UART communication standard [6]
<b>2.3.2. UART operating principle </b>
</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">In UART, data is transmitted in the form of packets. The segment that links the transmitter and receiver involves generating serial packets and managing those physical hardware lines. A packet comprises a start bit, data frame, a parity bit, and stop bits.
Figure 2.6. UART packet [6]
<b>Start Bit: </b>
The UART data transmission line typically maintains a high voltage level when not actively transmitting data. To initiate the data transfer, the transmitting UART lowers the transmission line from high to low for a single clock cycle. Upon detecting this high-to-low voltage transition, the receiving UART starts reading the bits within the data frame at the baud rate frequency.
<b>Data Frame: </b>
The data frame contains the actual data being transferred. It can be five (5) bits up to eight (8) bits long if a parity bit is used. If no parity bit is used, the data frame can be nine (9) bits long. In most cases, the data is sent with the least significant bit first.
<b>Parity: </b>
Parity describes the evenness or oddness of a number. The parity bit is a way for the receiving UART to tell if any data has changed during transmission. Bits can be changed by electromagnetic radiation, mismatched baud rates, or long-distance data transfers.
After the receiving UART reads the data frame, it counts the number of bits with a value of 1 and checks if the total is an even or odd number. If the parity bit is a 0 (even parity), the 1 or logic-high bit in the data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1 bit or logic highs in the data frame should total to an odd number.
When the parity bit matches the data, the UART knows that the transmission was free of errors. But if the parity bit is a 0, and the total is odd, or the parity bit is a 1, and the total is even, the UART knows that bits in the data frame have changed.
</div><span class="text_page_counter">Trang 28</span><div class="page_container" data-page="28">Data packets are used for data transmission.
Starting with a Start bit, the high-voltage line is pulled to the ground.
After the Start bit, 5 to 9 data bits of the packet's data frame are transferred, followed by an optional parity bit to verify proper data transmission.
Finally, one or more stop bits are transmitted where the line is set high.
<b>2.4. I2C interface </b>
<b>2.4.1. General introduction </b>
I2C amalgamates the favorable attributes of both SPI and UARTs. According to sources [7], I2C permits the connection of multiple slaves to a single master (akin to SPI) and enables multiple masters to control a single or multiple slaves. This proves advantageous in scenarios where more than one microcontroller is either recording data to a shared memory card or displaying text on a single LCD.
Similar to UART communication, I2C utilizes only two wires to facilitate data transmission between devices:
Figure 2.7. I2C Protocol [7]
<b>SDA (Serial Data) – The line for the master and slave to send and receive data. SCL (Serial Clock) – The line that carries the clock signal. </b>
Because I2C is a serial protocol, data is sent bit by bit via a single wire (the SDA line). Like SPI, I2C is synchronous, so the output of bits is synchronized to the sampling of bits by a clock signal shared between the master and the slave. The clock signal is always controlled by the master.
<b>2.4.2. I2C operating principle </b>
</div><span class="text_page_counter">Trang 29</span><div class="page_container" data-page="29">In the I2C communication protocol, The data is transmitted in the form of packets which consists of 9 bits.
Figure 2.8. Transmitted in the form of packets of I2C [7]
● If the address matches, it sends a low-voltage ACK bit back to the master.
● If the addresses do not match, the slave does nothing and the SDA current between those 2 devices will remain high.
<b>Read/Write Bit: </b>
This bit indicates whether the process is sending or receiving data from the Master device. A high Read/Write bit means the master is sending data to the slave, whereas a low Read/Write bit means the master is receiving data from the slave.
<b>ACK/NACK Bit: </b>
Abbreviation for Acknowledged / Not Acknowledged. Used to compare the physical address bit of the device with the address to which it was transmitted. After each data frame, an ACK/NACK bit is followed. If it does, the Slave will be set to '0' and otherwise, the default will be '1'.
<b>Data Frame: </b>
</div><span class="text_page_counter">Trang 30</span><div class="page_container" data-page="30">The data frame is always 8 bits long and is sent with the most significant bit first (MSB). Each data frame is immediately followed by an ACK/NACK bit to verify that the frame was received successfully (bit 0 in the SDA line). The ACK bit must be received by the master or slave before the next data frame can be sent.
After all data frames have been sent, the master can send a Stop condition to the slave to pause the transmission.
<b>Stop condition: </b>
To STOP, the voltage changes from low to high on the SCL line before switching the voltage from low to high on the SDA line.
<b>Data transmission process: </b>
Master device will send a Start pulse by switching SDA and SCL from high voltage to low voltage, respectively.
Next, Master sends the 7 or 10 address bits to Slave that wants to communicate with the Read/Write bit.
Slave will compare the physical address with the address it was sent to. If there is a match, Slave will acknowledge it by turning SDA low voltage and setting ACK/NACK bit to '0'. If there is no match, SDA and ACK/NACK bits both default to '1'.
Master device sends or receives a data bit frame. If Master sends to Slave, Read/Write bit is set to '0'. Otherwise, this bit is set to '1'.
If Data frame has been successfully transmitted, ACK/NACK bit is set to '0' to signal Master to continue.
After all data has been successfully sent to Slave, Master will send a Stop signal to notify Slave that the transmission has ended by switching SCL and SDA from low voltage to high voltage, respectively.
<b>2.5. ESP32-WROOM-32 </b>
The ESP32-WROOM-32 stands out as a versatile and robust MCU module extensively applied in the development of WiFi-Bluetooth PCB circuits. Bluetooth Low Energy (BLE) is notably employed in a myriad of IoT applications today. Its usage ranges from low-power sensor networks to more intricate tasks like audio encoding, online music streaming, and MP3 decoding. At the core of the module lies the ESP32-D0WDQ6 chip, an embedded semiconductor designed for optimal scalability and customization. Featuring two distinct CPU cores and an adjustable CPU clock frequency from 80MHz to 240MHz, this chip provides flexibility to programmers.
</div><span class="text_page_counter">Trang 31</span><div class="page_container" data-page="31">They can disable one CPU to utilize the low-power coprocessor for tasks such as monitoring changes or surpassing peripheral thresholds. Additionally, the ESP32 boasts a wide array of peripherals, including capacitive touch sensors, Hall sensors, SD cards, Ethernet, high-speed SPI, UART, I2S, and I2C [8].
Figure 2.9. ESP-WROOM-32 microchip [8]
<b>2.6. Arduino Uno R3 </b>
The Arduino Uno R3 is an ATmega328P-based microcontroller board. It includes everything needed to support the microcontroller; simply connect it to a PC via a USB connection and provide power via an AC-DC converter or a battery to get started. The title "Uno" means "one" in "Italian" and was chosen to commemorate the debut of Arduino's IDE 1.0 software. The R3 Arduino Uno is the third and most recent version of the Arduino Uno. The Arduino board and IDE software are the reference versions of Arduino that are currently being updated. The Uno-board is the first of a series of USB-Arduino boards, and it is the standard model for the Arduino platform [9].
</div><span class="text_page_counter">Trang 32</span><div class="page_container" data-page="32">Figure 2.10. Arduino Uno R3 [9]
<b>2.7. DHT11 temperature and humidity sensor </b>
The DHT11 Temperature Humidity Sensor is a common sensor nowadays since it is inexpensive and simple to obtain data via 1-wire transmission (single 1-wire digital communication). The sensor's built-in signal preprocessing allows you to obtain precise data without performing any calculations. The DHT11 has a substantially lower measurement range and precision than the newer sensor DHT22.
Figure 2.11. DHT11 temperature and humidity sensor module [9]
<b>2.8. MQ3 alcohol gas sensor module </b>
</div><span class="text_page_counter">Trang 33</span><div class="page_container" data-page="33"><b>MQ3 Alcohol Gas Sensor detects the concentrations of alcohol gas in the air and ouputs its </b>
reading as an analog voltage. The sensor can detect concentrations ranging from 0.04mg/L to 4mg/L. Breathalyzers can use the concentration sensing range. The sensor operates at temperatures ranging from -10 to 50°C and draws less than 150 mA at 5 V.
By connecting five volts across the heating (H) pins, the sensor is kept hot enough to work properly. When five volts are applied to either the A or B pins, the sensor emits an analog voltage on the other pins. The detector's sensitivity is determined by a resistive load connected between the output pins and ground. The resistive load should be calibrated for your specific application using the datasheet formulae, although 200 k is an acceptable starting point.Technical specifications:
Figure 2.12. MQ3 alcohol gas sensor module [9]
<b>2.9. Module SIM 800L V2 5V </b>
<b>2.9.1. Global System for Mobile communication </b>
GSM (Global System for Mobile Communication) is a digital mobile network widely utilized by mobile phone users in Europe and various global regions. It employs a variant of time division multiple access (TDMA) and stands out as the most prevalent among the trio of digital wireless telephony technologies: TDMA, GSM, and code-division multiple access (CDMA). The process involves digitizing and compressing data, transmitting it down a channel alongside two additional streams of user data, each occupying its designated time slot. GSM operates within the frequency bands of either 900 megahertz (MHz) or 1,800 MHz.
Teaming up with other technologies, GSM plays a crucial role in advancing wireless mobile telecommunications. This encompasses features such as High-Speed Circuit-Switched Data
</div><span class="text_page_counter">Trang 34</span><div class="page_container" data-page="34">(HSCSD), General Packet Radio Service (GPRS), Enhanced Data GSM Environment (EDGE), and Universal Mobile Telecommunications Service (UMTS).
<b>Composition of the network </b>
It was shown in [10] that the GSM network is comprised of four distinct components that operate in tandem to function as a whole: the mobile device itself, the base station subsystem (BSS), the network switching subsystem (NSS), and the operation and support subsystem (OSS). The hardware links the mobile device to the network. The subscriber identity module (SIM) card sends identifying information about the mobile user to the network.
Figure 2.13. Global System for mobile (GSM) network [10]
The base station controller (BSC) and the base transceiver station (BTS) are the fundamental devices responsible for facilitating communication between the mobile phone and the NSS. The BTS comprises equipment that interacts with mobile phones, notably radio transmitter receivers and antennae, while the BSC acts as the intelligent component overseeing these operations. The BSC effectively interacts with and manages a network of base transceiver stations.
The NSS segment, often referred to as the core network in GSM network design, monitors caller locations to support the provision of cellular services. Owned by mobile carriers, the NSS
</div><span class="text_page_counter">Trang 35</span><div class="page_container" data-page="35">includes components such as the mobile switching center (MSC) and home location registry (HLR). These elements serve various functions, including call routing, SMS, and the authentication and storage of caller account information via SIM cards.
Due to roaming agreements between GSM network providers and their overseas counterparts, consumers can frequently use their phones when traveling to other countries. Users can significantly reduce roaming fees without experiencing service loss by transitioning from SIM cards that store home network access configurations to those enabling metered local access.
<b>2.9.2. Short messaging Service Introduce SMS: </b>
SMS (Short Messaging Service) is a synonymous term for text messaging, commonly involving the transmission of messages from one mobile device to another through the cellular network. SMS operates as a text-only communication format, with its origins dating back to its establishment in the Global System for Mobile Communications (GSM) guidelines in 1985.
While a single SMS message is confined to 160 GSM-7 characters, contemporary mobile phones can often break down and reassemble messages of up to 1,600 characters. To accommodate emojis and characters beyond the GSM-7 alphabet, text communications utilize UCS-2 character encoding. It's noteworthy that a single Unicode character converts the entire text message to UCS-2, imposing a limit of 70 characters on communications.
The initial limitation of SMS to 160 characters was designed to integrate seamlessly with existing phone protocols. This constraint was later incorporated into the SMPP Protocol when it gained prominence, facilitating the transfer of text messages between carriers.
<b>SMS structure: </b>
SMS message standards establish the details of information conveyed in a message, the way binary bits form letters, and how data is organized, transmitted, and received among devices. The data format of a message encompasses not just the message text but also additional details like the timestamp and the sender's phone number.
Protocol Description Units (PDUs) delineate message information in the form of a hexadecimal and semi-decimal string. Hexadecimal, a base-16 counting system, represents numbers from 10 to 15 using the characters 0 to 9 and A to F.
The PDU format consists of various information fields, with the initial bits containing details about the destination, including the message center and the sender's number. Subsequent bits constitute the message string.
</div><span class="text_page_counter">Trang 36</span><div class="page_container" data-page="36">Subsequently, details about the sender and recipient are transformed into a protocol format, accompanied by a tag identifying the encoding program utilized. The tag specifies the encoding method, aiding the message center in determining the decoding software applied to decode the message. Timestamp labels and information regarding the message length are also included.
<b>2.9.3. Introduces the SIM800L V2 module </b>
The SIM800L V2 5V Wireless GSM GPRS Module operates on a 5V power supply and features a PC debug USB to TTL serial interface. It has an output current of 800mA, and its TTL serial interface is compatible with both 3.3V and 5V microcontrollers. The module can be connected to a single-chip computer immediately after purchase.
It comes with an IPX antenna, an antenna interface, and suction cups that can be freely interchanged with PCB glue stick antennas. The SIM800L supports 4 frequency communications, ensuring global data availability. It is suitable for overseas trade and supports foreign trade initiatives.
The SIM800L V2.0 GSM/GPRS Module is Arduino compatible, offering QUAD-BAND GSM/GPRS capabilities. This module combines both GSM and GPRS features. Notably, its VCC and TTL serial levels operate at 5V voltage, allowing a direct connection to Arduino or other minimum systems with a 5V voltage level.
Additionally, the SIM800L V.2 GSM/GPRS module comes equipped with a built-in regulator circuit and TTL level converter on the board.
Figure 2.14. SIM800L V2 5V Wireless GSM GPRS module [10]
<b>2.10. RC522 Module RFID Reader </b>
</div><span class="text_page_counter">Trang 37</span><div class="page_container" data-page="37">RFID technology, also recognized as Radio-Frequency Identification, is a system designed to automatically identify information from a distance using radio waves. This process involves the interaction between the RFID tag and a dedicated reader. Each RFID tag comprises a chip and an antenna, enabling it to store and retrieve specific information [11].
The RC522 RFID module, utilizing the NXP MFRC522 IC, stands out as one of the most cost-effective RFID solutions available online, with a price tag of less than four dollars. It is bundled with an RFID card tag and a key fob tag featuring 1KB of memory. Notably, it possesses the unique capability to generate tags, empowering users to store various messages within it.
Figure 2.15. RC522 RFID Reader with Cards Kit [11]
<b>2.11. Energy Meter Module PZEM-004T </b>
The PZEM004T device gauges energy consumption by monitoring a live AC mains cable, employing an inductor as the measurement sensor. It's important to note that there are currently at least two versions (3/2020): V2.0, which utilizes the standard serial protocol, and V3.0, which employs Modbus. This project utilizes V2.0.
One of the wires, typically the AC power phase, passes through the inductor, enabling the measurement of the current flowing through it and subsequently monitoring other measurements [12], including power consumption.
The PZEM004T outputs the collected data through an opto-coupled isolated serial port. This feature facilitates the retrieval of values for voltage, current/intensity, current power consumption, and accumulated energy consumption.
</div><span class="text_page_counter">Trang 38</span><div class="page_container" data-page="38">Figure 2.16. Energy Meter Module PZEM-004T [12]
<b>2.12. 5V Relay Module </b>
A 5V relay module is a relay module with a single or multiple channels that functions on a 5V DC low-level trigger voltage. Any microcontroller or logic device capable of outputting a digital signal can supply the required input voltage.
Similar to many other relays, the 5V relay module is an electromagnetically controlled, electric switch utilized for circuit activation or deactivation. It consists of two components: the relay and the control module.
Figure 2.17. 5V Relay Module [13]
<b>2.13. 20x4 Character LCD Display </b>
This module is an Arduino compatible LCD display module with high speed I²C interface. It can display 20×4 characters (white characters on a blue background).
</div><span class="text_page_counter">Trang 39</span><div class="page_container" data-page="39">Figure 2.18. 20x4 Character LCD Display [14]
<b>Features: </b>
<b>• Sharp visibility: The clear presentation achieved by featuring white characters on a </b>
blue background ensures a sharp and easily legible display, which is essential for projects necessitating distinct visualizations.
<b>• Customizable contrast: The incorporation of a trimmer for contrast adjustment </b>
provides users with the flexibility to tailor the display according to their preferences, enhancing functionality for diverse lighting conditions and project requirements.
<b>• Rapid I2C interface: The swift I2C interface, recognized for its simplicity and speed, </b>
minimizes the setup time for connections, allowing users to focus more on their projects.
<b>2.14. Servo Motor SG90 </b>
The Servo Motor SG-90 (SG90) is a compact and cost-effective servo motor commonly used in various applications that demand precise control of angular motion. Despite its diminutive size, it delivers outstanding performance and versatility. It can be easily powered by standard power sources, given its operational voltage range of 4.8V to 6V. The SG90 servo motor is designed to rotate within a 180-degree span, providing a broad range of motion for control systems. Its built-in gear system ensures smooth and accurate movement, facilitating precise positioning of objects or components. This makes it well-suited for precision-control applications such as robots, RC vehicles, and pan-tilt camera systems.
</div><span class="text_page_counter">Trang 40</span><div class="page_container" data-page="40">Figure 2.19. Servo Motor Pinout (Wires) [15]
<b>2.15. DC-DC XL4015 5A power module </b>
To lower DC voltage, utilize the XL4015 (5A) DC voltage reduction circuit with current adjustment. In order to assist assure safety when utilized in applications, the circuit additionally includes a voltage limit variable resistor and an inbuilt comparator opamp IC at the output. When contact or overcurrent occurs, the circuit will immediately shut off and flash an LED to alert users.
Figure 2.20. XL4015 DC-DC Voltage Regulator [16]
<b>2.16. LDR Sensor Module </b>
The LDR sensor module is used to measure light intensity. It is connected to the board's AO and DO labels, which stand for analog and digital output pins, respectively. When there is light,
</div>