Long press the QR code below to enter the public account

Chapter 1 Overview
Fire is one of the most dangerous disasters to human life and survival, causing property loss and, in severe cases, loss of life. In recent years, with the popularity of high-power household appliances and the use of various combustible gases such as liquefied gas, natural gas, and biogas, household fires have been on the rise, threatening people’s safety. On the other hand, as people’s awareness of theft prevention increases, home security has become increasingly important. With the continuous advancement of hardware and software technology, smart home systems have entered many households. One of the most important aspects of smart homes is safety; a secure home is the premise of a smart home and the foundation for its realization. Fire and theft prevention capabilities are key to home security and are also a focus of current research.
Common fire alarms mainly rely on manual button presses to alert people to a fire. However, these alarms require manual activation and often fail to provide quick alerts, which diminishes their effectiveness in timely fire suppression. To address this issue, various sensors have been proposed to monitor areas prone to fire, enabling rapid and timely alerts when a fire occurs. Additionally, current theft prevention systems also face issues such as inaccurate identification and delayed alerts. Meanwhile, microcontrollers, with their compact size and multifunctionality, can meet various design requirements and are applied in multiple fields. Therefore, using microcontrollers for smart home design is a good choice. However, existing fire alarm and theft prevention systems based on microcontrollers still face issues such as delayed alerts, insufficient display accuracy, and the inability to perform sound and light alarms simultaneously, which need further resolution.
To solve the above problems, this paper combines practical needs with the characteristics of the 51 microcontroller, utilizing temperature and humidity sensors and smoke sensors to design a smart home control system based on the 51 microcontroller. Through hardware and software design, the system achieves miniaturization, multifunctionality, high precision, and basic functions such as fire sound and light alarms, enhancing the safety of smart homes.
Chapter 2 System Function Requirements and Design
2.1 System Design Requirements
To achieve real-time display of temperature, humidity, and smoke, and timely alerts to reduce fire hazards, this paper will implement the following design requirements:
(1) Accurate and real-time detection of temperature, humidity, and smoke levels in the villa;
(2) Direct and clear display of measured temperature, humidity, and smoke concentration values;
(4) Automatic fire alarm capability;
(5) Simple operation, complete functions, and high accuracy.
As shown in Figure 2-1.
Figure 2-1 System Design Block Diagram
2.2 Main Components
2.2.1 STC89C51 Microcontroller
The STC89C51 microcontroller, as shown in Figure 2-2, is one of the most commonly used microcontroller chips in microcontroller design, featuring comprehensive functionality and ease of design. It mainly has the following peripheral functions:
8k bytes of Flash;
512 bytes of RAM;
32-bit I/O ports;
4KB EEPROM;
MAX810 reset circuit;
3 16-bit timers/counters;
4 external interrupts;
Full-duplex serial interface.
Figure 2-2 STC89C51 Microcontroller Pin Diagram
2.2.2 DHT11 Temperature and Humidity Sensor
The DHT11 digital temperature and humidity sensor is primarily used for detecting temperature and humidity data in a small range. It provides stable, reliable, and digital output data without the need for post-processing. Although small in size, it can achieve the basic temperature and humidity values required and is easy to expand for further research, as shown in Figure 2-3.
Figure 2-3 DHT11 Temperature and Humidity Sensor
DHT11 Temperature and Humidity Sensor Pin Description
Pin 1: (VCC), power pin, supply voltage 5V;
Pin 2: (DATA), serial data, single bus;
Pin 3: (VDD), ground pin.
Pin 2 DATA port is used for communication and connection between the STC89C52 microcontroller and the DHT11 temperature and humidity sensor, facilitating data transmission and control and configuration of the DHT11 temperature and humidity sensor by the microcontroller. It uses single-bus data transmission, with a single communication time of 4ms, and the data is divided into integer and decimal parts.
2.2.3 Smoke Sensor
When the concentration of combustible gases in the air is abnormal, the MQ-2 sensor, as shown in Figure 2-4, converts the concentration value of combustible gases into an electrical signal. This electrical signal is sent to the microcontroller after passing through the AD module for further processing and display.
MQ-2 Smoke Sensor Pin Description:
Pin 1: VCC 5V working voltage;
Pin 2: GND external GND;
Pin 3: DO digital switch output interface;
Pin 4: AO analog output interface.
When the DO pin outputs a high level and the AO pin outputs a low level, it indicates no detection output, meaning the MQ-2 is not working. When combustible gas starts to flow, the DO pin begins to output a low level, and the analog voltage output from the AO pin gradually increases and is sent to the ADC0832 module.
Figure 2-4 Smoke Sensor Structure Diagram
2.2.4 ADC0832 Analog-to-Digital Converter Chip
ADC0832 is one of the most commonly used analog-to-digital conversion modules in microcontroller design, featuring stable performance, relatively fast conversion speed, and good conversion accuracy. The specific pin diagram is shown in Figure 2-5.
Pin Interface Description:
Chip Interface Description:
(1) (CS)̅ is the enable pin, low level enables;
(2) CH0 analog input channel 0;
(3) CH1 analog input channel 1;
(4) GND ground; Vcc is the voltage input pin;
(5) DI data signal input, channel selection control;
(6) DO data signal output, conversion data output;
(7) CLK chip clock input.
Figure 2-5 ADC0832 Pin Diagram
2.2.5 LCD1602 Liquid Crystal Display Module
This system uses the LCD1602 liquid crystal display to show the measured values. It is well known that microcontroller designs typically use digital tubes or LCD screens to display data, and the LCD screen has prominent features, providing clearer and more distinct data while consuming less power, making it suitable for this design. The pin diagram is shown in Figure 2-6.
Figure 2-6 LCD1602 Pin Diagram
Chapter 3 Hardware Design
As shown in Figure 3-1, the hardware design scheme of this system consists of the following modules:
(1) Minimum system of the microcontroller. It is used to drive and control other modules to achieve overall functionality, centered around the STC89C51 microcontroller, supplemented by a reset circuit and an oscillator circuit.
(2) Signal acquisition circuit. Responsible for collecting the data to be monitored, this design’s signal acquisition circuit consists of temperature acquisition circuits, smoke acquisition circuits, and infrared acquisition circuits.
(3) AD conversion circuit. Composed of the ADC0832 module, it connects with the sensors and the microcontroller chip, responsible for converting analog values into digital quantities and sending them to the microcontroller.
(4) Key and display circuit. The display circuit is used to show relevant data, while the key circuit is used to control the chip to achieve related functions, directly connected to the microcontroller.
Figure 3-1 Hardware Design Block Diagram
3.1 Main Controller Circuit Design
The minimum system of the microcontroller is the most basic and essential part of microcontroller expansion and application, generally composed of the following circuits, serving as the core of the entire design, ensuring the expansion and realization of other functions based on the microcontroller. As shown in Figure 3-2.
Figure 3-2 Minimum System of the Microcontroller
Reset Circuit: The reset circuit is the most basic and important circuit in microcontroller applications, used to handle emergencies such as microcontroller malfunction. The reset circuit is divided into power-off reset and button reset; this paper uses button reset, which works as follows: when the reset port of the microcontroller is at a high level, the code in the microcontroller will not be executed. Initially, when powered on, the capacitor is not fully charged, and the reset port is at a high level, preventing program errors caused by running the program immediately upon power-up. Once the capacitor is fully charged, the reset port becomes low, and the program begins to run. Additionally, when the button is pressed, the microcontroller is in a reset state.
Oscillator Circuit: The oscillator circuit provides the essential clock frequency for the microcontroller, necessary for data transmission and the working timing of the microcontroller. This design provides an 11.0592MHz clock frequency. The microcontroller chip’s XTAL1 (pin 19) and XTAL2 (pin 18) form the clock pins of the microcontroller, creating a stable oscillation circuit to ensure the normal operation of the microcontroller; the oscillator circuit uses two 20pf capacitors.
3.2 LCD1602 Display Module Design
This system uses the LCD1602 liquid crystal display to show temperature, humidity, and smoke values. It is well known that microcontroller designs typically use LED digital tubes or LCD screens to display data, and the LCD screen has prominent features, providing clearer and more distinct data while consuming less power, making it suitable for this design. The pin descriptions are as follows:
Pin 1: VSS is the ground power supply.
Pin 2: VDD connects to the 5V positive power supply.
Pin 3: V0 connects to the positive power supply through a 10K resistor.
Pin 4: RS is the register select pin; in high level, it is the data register, and in low level, it is the instruction register.
Pin 5: R/W is the read/write signal line; it performs read operations at high level and write operations at low level.
Pin 6: E is the enable pin; when it transitions from high to low, the LCD module begins executing code.
Pin 7-14: D0-D7 are data input pins. Pin 15: backlight positive terminal.
Figure 3-3 LCD1602 Display Module
3.3 Temperature and Humidity Sensor Module Design
The temperature sensor’s port 1 is grounded, and ports 2 and 3 connect to the power supply and microcontroller through a 10K pull-up resistor, with the collected digital signal sent directly to the microcontroller for processing and display. The liquid level sensor and flow sensor need to be externally connected through pin headers, as shown in Figure 3-4.
Figure 3-4 Temperature and Humidity Sensor Module Circuit Diagram
3.4 Smoke Sensor Module Design
The smoke concentration acquisition requires the smoke sensor and AD module to complete. The specific smoke acquisition circuit and AD conversion circuit are shown in Figure 3-5. The MQ-2 smoke sensor module connects to an operational amplifier circuit, sending data to the CH1 port of the dual-channel ADC0832 module to transmit the analog signal to the AD module. The AD module’s pin 1 connects to the microcontroller’s P1.1 port, and the CLK clock pin connects to the microcontroller’s P1.3 port, while the DO and DI pins are connected in series to the microcontroller’s P1.2 port.
Figure 3-5 Smoke Concentration Acquisition and AD Conversion Circuit
3.5 Relay Control Circuit
The relay circuit can control the on/off of the motor. The specific circuit is shown in Figure 3-6. The circuit consists of a relay, LED, 1K resistor, and switch, with the input connected to the microcontroller chip’s IO port and the output connected to the motor drive circuit using a two-pin header, controlling the on/off of household appliances. Specifically, when the microcontroller’s IO port outputs a high level, the PNP transistor does not conduct, the relay does not engage, and the motor remains off. When the microcontroller’s IO port outputs a low level, the PNP transistor conducts, the relay engages, and the motor starts working.
Figure 3-6 Smoke Concentration Acquisition and AD Conversion Circuit
3.6 Simulation Schematic
Proteus is also one of the commonly used design software in microcontroller simulation design. By designing the hardware circuit diagram and writing the driver program, circuit debugging can be performed without implementing hardware. Additionally, Proteus can also realize PCB design and can be coordinated with KEIL in simulation, facilitating program debugging and supporting multiple platforms, making it simple and convenient to use. Therefore, based on the design of the hardware schematic, we used Proteus 8.7 software to design the simulation schematic, as shown in Figure 3-7. Since the simulation does not include the liquid level sensor module and flow sensor module, this design uses two sliding potentiometers to output analog values instead of the outputs of the two sensors.
On another note, since the Proteus simulation software component library does not include the STC series microcontrollers, the AT89C51 microcontroller is used to replace the STC89C51 microcontroller used in the hardware circuit diagram for simulation design. Meanwhile, the reset circuit of the minimum system in the simulation differs from that in the hardware schematic, with the capacitor value being 0.1uf and the resistor value being 100Ω. If the resistor and capacitor values from the hardware are used, the reset function cannot be achieved. The capacitor values in the oscillator circuit are consistent with those in the hardware schematic.
Figure 3-7 Simulation Schematic
Chapter 4 Software Design
Based on the design requirements of this paper, the specific functions to be implemented through software programming on the basis of the hardware circuit design in Chapter 3 are:
(1) Drive each module to work, achieving temperature acquisition and display, and smoke concentration acquisition and AD conversion display;
(2) Key setting function. Set temperature and humidity alarm thresholds, smoke alarm thresholds, motor drive, etc.;
(3) Alarm function implementation. Implement sound and light alarms for high temperature, low temperature, high humidity, low humidity, and high smoke concentration;
(4) Relay control of the motor. When the conditions of high smoke, high temperature, and low humidity are simultaneously met, control the relay to engage, indicating fire extinguishing. The design flow is shown in Figure 4-1.
Figure 4-1 Program Design Flow
Chapter 5 Simulation Implementation
5.1 Simulation Implementation
5.1.1 Simulation Circuit Diagram
This system uses the simulation schematic designed in Proteus 8.7, as shown in Figure 5-1.
Figure 5-1 Simulation Schematic
Based on the software design ideas in Chapter 4 and the simulation requirements, we wrote the C code for the simulation design using KEIL5, with detailed comments. Next, we clicked “create HEX file” and recompiled the program, generating the HEX burning file, as shown in Figure 5-2.
Figure 5-2 Debugging and HEX File Generation Screenshot
Next, we open the simulation schematic and burn the generated “HEX” file into the microcontroller chip. By clicking start simulation, we can achieve the relevant simulation, which will be specifically displayed in the next section.
5.1.2 Simulation Results
(1) Display of temperature, humidity, and smoke values
After starting the simulation, once the system powers on and stabilizes, the microcontroller begins to work, and the LCD160 display shows the measured temperature, smoke, and humidity values as shown in Figure 5-3. The simulation circuit displays stable performance, achieving accurate display of temperature, humidity, and smoke values.
Figure 5-3 Display of Temperature, Humidity, and Smoke Values
(2) Setting of temperature and humidity alarm thresholds and smoke alarm thresholds
Next, we press the “adjust” button to start setting the temperature alarm threshold. By using the “increase” and “decrease” buttons, we can set the upper and lower limits for temperature, humidity, and smoke, as shown in Figure 5-4, which is the temperature upper and lower limit setting interface.
Figure 5-4 Temperature Alarm Threshold and Smoke Alarm Threshold
(4) Automatic fire alarm
Next, we adjust the measured temperature to 44℃. Since it exceeds the temperature alarm threshold, the system begins to alarm. As shown in Figure 5-5, during the alarm, the high temperature indicator light is on, and the buzzer sounds.
Figure 5-5 Temperature Alarm
(5) Automatic fire extinguishing
When the conditions of high smoke, high temperature, and low humidity are simultaneously met, the relay is controlled to engage, indicating motor rotation for fire extinguishing. As shown in Figure 5-6.
Figure 5-6 Motor Rotation
5.2 Test Situation Analysis
Through the above series of simulation tests, the “Intelligent Home Control System Based on 51 Microcontroller” designed in this paper meets the system requirements outlined in Section 2.1, specifically achieving the following functions:
(1) Stable and accurate measurement and display of temperature and humidity values; stable and accurate measurement and display of smoke values;
(2) The temperature and humidity alarm thresholds can be set via buttons, and when the measured temperature and humidity exceed the set thresholds, the alarm indicator light flashes, and the buzzer alarms; the smoke alarm threshold can also be set via buttons, and when the measured smoke concentration exceeds the set threshold, the smoke alarm indicator light flashes, and the buzzer alarms;
(3) When the conditions of high smoke, high temperature, and low humidity are simultaneously met, the relay is controlled to engage, indicating motor rotation for fire extinguishing.
Chapter 6 Project Management and Economic Settlement
In the early 1980s, the term Smart Home was proposed by researchers in the United States, attracting attention in related fields. In 1984, a “smart building” was constructed, integrating the information and intelligent technologies of the time, marking the entry of smart homes into the researcher’s vision, leading to the proposal of more smart home solutions.
In 1998, the design of smart homes became increasingly mature, with a “Future Home” model established in Singapore, publicly showcasing the concept of future smart homes, allowing people to get closer to intelligent homes. Since then, smart homes have developed towards safety, intelligence, and comfort, beginning to see a certain degree of application.
China’s smart home development started relatively late. After learning about relevant smart home design solutions and concepts from abroad, it gradually began to introduce related technologies. It has gone through a process from concept, research, experimentation, promotion, to popularization, achieving partial intelligence and safety in residential areas of large and medium-sized cities, which has improved the safety and comfort of living to a certain extent compared to the 1990s. However, compared to foreign countries, there is still a gap in research on smart homes in China. With the improvement of information technology and increased R&D investment from high-tech companies, China’s smart home systems will further develop.
6.1 Overview of Project Management
The hardware circuit of the intelligent home control system based on the 51 microcontroller can be divided into four parts: the microcontroller part, sensor control part, relay control part, and display part; the software technology mainly includes programming technology and testing technology based on the hardware circuit. Currently, the market price for smart home control systems ranges from 500 to 2000, depending on manufacturing costs, including steel, chemical raw materials, electronic components, labor costs, site costs, number of doors, systems, transportation, packaging, and maintenance.
Producing a smart home control system based on the 51 microcontroller generally takes three days, with larger factories processing faster.
6.2 Project Management Content
1. Safety
The intelligent home control system based on the 51 microcontroller is designed using the 51 microcontroller, which has stable performance, enabling good sensor control and driving, with stable detection. The power supply system for this design only requires 5V, posing no significant risk.
2. Quality
The temperature sensor, smoke sensor, humidity sensor, relay module, and 51 microcontroller module used in the intelligent home control system have all been long-term used and verified, ensuring system stability, with high precision and stability in the detection data of each sensor, capable of continuous operation for extended periods.
3. Investment
This system’s microcontroller part uses the STC89C51, generally priced around 5-10 yuan, the display part uses the LCD1602, generally priced between 10-20 yuan, the temperature and humidity sensor costs between 5-10 yuan, and the relay module ranges from 20-50 yuan, excluding programming and testing costs. As shown in Table 6-1.
Table 6-1 R&D Costs
|
Component |
AT89C51 |
LCD1602 |
Sensor |
Other Modules |
Programming Technology |
Other Components |
Total |
|
Cost/Yuan |
5-10 |
10–20 |
25–60 |
60 |
0 |
60 |
160–210 |
Mass production not only requires R&D costs but also other expenses, including employee costs, site costs, transportation, packaging, maintenance, etc. As shown in Table 6-2:
Table 6-2 Production Costs
|
Component |
Employee Costs |
Site Costs |
Transportation Costs |
Packaging Costs |
Maintenance Costs |
Total |
|
Cost/Yuan |
100/Day |
50/Day |
100-200 |
20 |
50 |
320-420 |
In summary, a smart home control system based on the 51 microcontroller requires about 480-630 yuan from initial production to later investment, indicating a significant profit margin.
Conclusion
This paper conducts research on home intelligence, focusing on home safety, and completes the following work through extensive literature review and simulation design:
(1) Draws the circuit schematic and simulation schematic, and writes the program code for the system implementation.
(2) Achieves real-time measurement and display of temperature, humidity, and smoke concentration in areas prone to fire in villas.
(3) Sets alarm thresholds based on actual fire temperature and smoke concentration; when exceeding the set thresholds, the corresponding alarm indicator lights up, and the buzzer alarms; when both temperature, humidity, and smoke exceed the thresholds, simultaneous sound and light alarms and relay control of the motor for fire extinguishing can be achieved.
In summary, the design of this paper meets the expected design goals, has practical value, and can enhance fire and theft prevention capabilities in homes to a certain extent.
Although this paper has successfully implemented the design of the intelligent home system based on the 51 microcontroller, there are still many areas for improvement due to the author’s limited capabilities. In future work, the following points can be explored for related design:
(1) Due to time constraints, this design only performed relevant simulations. In the next step, a PCB diagram will be designed based on the schematic, and hardware will be produced;
(2) This design only alarms when exceeding the warning value. In future designs, different warning levels can be added to achieve multifunctional fire alarms;
(3) In the upcoming design, functions such as mobile alarm information inquiry and mobile control of the smart home system can be added to make the fire alarm system more intelligent and user-friendly.
References
[1] Ke Guoqin. Research on Intelligent Home System Based on Microcontroller [D]. Hefei: Master’s Thesis, Hefei University of Technology, 2010, 4: 1-3
[2] Lu Xueying. Design and Implementation of Intelligent Home Control System Based on Microcontroller [D]. Zhenjiang: Master’s Thesis, Jiangsu University, 2015, 4: 5-10
[3] Bertsch L A. Development tools for home automation[J]. IEEE Transactions on Consumer Electronics, 1990, 36(4):P.854-858
[4] Song Yuchao. Research and Design of Intelligent Home Monitoring System Based on Microcontroller [D]. Changchun: Master’s Thesis, Jilin University, 2018, 4: 5-36
[5] Lou Ranmiao, Li Guangfei. Design Examples of MCS-51 Series Microcontrollers [J]. Microcontroller and Embedded System Applications (02):84
[6] Liu Wentao. Examples of Microcontroller Application Development [M]. Beijing: Tsinghua University Press, 2005, 18-25
[7] Zeng Long, Chen Zefeng, Zeng Xiangui, et al. Wireless Alarm System Based on DSl8820 Temperature Sensor [J]. Instrumentation Users, 2011, 18(6):91-92
[8] Wang Yunfei. Application Design of DS18B20 Temperature Sensor [J]. Electronic World (12):361
[9] Shao Bingqian, Zhang Jian, Zhao Shuai. Remote Multifunctional Fire Alarm System Based on the Internet of Things [J]. Information and Computer (Theoretical Edition), No.405(11):96-98
[10] Du Yang. Application of A/D Conversion Chip ADC0832 [J]. Electronic Production, 2006(1):46-48
[1]
Appendix 1 Schematic
Appendix 2 Simulation Diagram
|
Course Name |
Comprehensive Practice of Professional Technology |
||||
|
Title Name |
|
||||
|
Group Members |
|
Instructor Name |
|
Title |
|
|
Serial Number |
Evaluation Item |
Indicator |
Full Score |
Score |
|
|
1 |
Control System Scheme Design |
In the control system scheme design, the ability to reasonably select sensor units, control units, display units, etc., according to course requirements; design control algorithms and control system debugging plans according to requirements.(Graduation Requirement 3.2, Course Objective 1) |
30 |
|
|
|
2 |
Engineering and Society |
In the design and debugging process of the detection and control system, the ability to consider the impact of the system’s operation on the environment and conduct a rational assessment.(Graduation Requirement 6.2, Course Objective 2) |
20 |
|
|
|
3 |
Report Quality |
The course design report is clearly written, well-structured, coherent, and follows writing norms, with complete and correct figures and tables. The design report analyzes the control process, control principles, and control; provides a rationality verification process for the detection and control system, showcasing design results and solutions.(Graduation Requirement 11.1, Course Objective 3) |
20 |
|
|
|
4 |
Communication |
Clear and fluent explanation during the defense, with a well-designed PPT, able to correctly answer questions posed by the instructor.(Graduation Requirement 11.1, Course Objective 3) |
10 |
|
|
|
5 |
Project Management |
In the design and debugging process of the system, the ability to conduct comprehensive management according to project methods, considering economic indicators throughout the system implementation process.(Graduation Requirement 11.2, Course Objective 4) |
20 |
|
|
|
Total Score |
|
||||
|
Comments: |
Instructor: Year Month Day