Design and implementation of smart home control system

The


Introduction
As a major disaster in modern urban life, fire causes thousands of deaths and hundreds of millions of property losses in our country every year.According to the survey, nearly half of the fires occurred in residential houses, and most of the causes of household fires were not detected early, careless, and failed to take preventive measures in time.Therefore, it is very meaningful for the prevention and early detection of household fires.At the same time, with the economic development, more and more citizens live in high-rise residential buildings.For families with children at home, it is necessary to prevent children from jumping through windows and causing injuries from falling buildings.This design can monitor the indoor temperature and smoke concentration data conveniently and quickly.If the concentration exceeds the standard, it will remind the people at home in time to prevent the fire from spreading, so as to avoid casualties and property losses.In addition, this design can also detect the dangerous behavior of children approaching the window at the first time, and can close the window in time to prevent the fall injury caused by children jumping over the window.

System design requirements
The system design requirements are as follows: Temperature monitoring and alarm: when the temperature is greater than the set value, the buzzer starts to alarm.
Smoke concentration monitoring and alarm: When the smoke concentration value reaches the lower limit of the set value, the fan starts to rotate.When the smoke concentration value reaches the upper limit of the set value, the fan starts to rotate and the buzzer starts to alarm.
When the pressure sensor detects that the pressure is greater than the preset value, close the window.

System design scheme
The block diagram of this design system is shown in Fig. 1.This design includes data collecting module, single chip data processing module, display module, executive module and alarm module.The data collecting module collects room temperature, smoke and pressure values at windows through temperature sensors, smoke sensors and pressure sensors, respectively.The data processing module of the single-chip microcomputer processes the collected data and displays data in real time on the display module.When the room temperature data is greater than the threshold, alarm module will alarm.When the smoke concentration value reaches the lower limit of the set value, the fan starts to rotate; When the smoke concentration value reaches the upper limit of the set value, not only the fan starts to rotate but also the buzzer starts to alarm.When the window pressure value greater than the preset value, close the window to protect children from falling. 4 Hardware design

Main control module
The main parameters of the STM32F103C8T6 microcontroller are shown in Table 1.

Temperature detection module
This design uses DS18B20 to monitor the temperature.Its pins are relatively simple, with only 3 pins, which are voltage, ground and data pins.The receiving signal performs temperature data conversion by receiving a 9-bit digital signal.The module can read the temperature data in a short time.When the module receives the temperature data, it reads the data into the built-in data storage unit, and then according to the specific data needs to be read.Its circuit schematic is shown in Fig. 2.

Smoke detection module
In this design, MQ-2 is used for smoke concentration monitoring.The detection principle is to make the gas-sensitive material on the sensor surface contact the smoke in the air, and sense the smoke concentration by increasing or decreasing the conductivity.The larger the detected smoke concentration value is, the higher the corresponding conductivity is; On the contrary, the smaller the detected smoke concentration value is, the smaller the corresponding conductivity is.The MQ-2 sensor has higher sensitivity for the detection of liquefied gas and city gas.Its circuit schematic is shown in Fig. 3.

Pressure detection module
This design uses strain sensor and HX711 to complete pressure detection.HX711 is a 24bit A/D converter chip.HX711 has a total of 16 pins.The schematic diagram is shown in Fig. 4. 5 Software design

The overall process of the system
The overall flow chart of this design is shown in Fig. 5. First of all, the system is initialized, the temperature sensor detects the indoor temperature, and displays the detected value.If the detected temperature value is less than the threshold value, the smoke concentration is detected.If the temperature value is greater than the set threshold value, the buzzer alarms.
The smoke sensor detects the smoke concentration in the air, and displays the detected smoke value on the display screen.If the smoke concentration is less than the lower limit of the threshold, the pressure sensor detects the pressure.If the smoke concentration is greater than the lower limit of the threshold, the fan is turned on.When the upper limit of the threshold is set, the fan will be turned on, the buzzer will alarm to remind the occupants at the same time, aiming to prevent the occurrence of fire.Finally, the pressure sensor detects the pressure.If the pressure is greater than the set threshold, it will return to continue to detect the temperature value.If the detected pressure value is greater than the set threshold, the window will be closed, and the program will return to repeat and continue to detect the temperature.

Software flow of the temperature collecting module
The flowchart of the temperature collection module is shown in Fig. 6.After the system initialization is completed, the temperature sensor DS18B20 starts to collect temperature data, and the display module displays the temperature.When the detected temperature value is greater than the set threshold value, the buzzer starts to alarm.When the detected temperature value is less than the set threshold value, it returns to continue to collect temperature values.

Software flow of the smoke collecting module
Fig. 7 shows the flow of the smoke concentration collection module.The power supply of the system starts to work, and the program is initialized first, the smoke sensor detects the smoke, and the display module displays the smoke concentration value.When the smoke concentration is less than the lower limit of the set threshold, the system returns to continue to detect the smoke concentration.When the value of the smoke concentration is greater than the lower limit of the set threshold, the system turns on the fan, and the sensor continues to detect the smoke concentration.When the smoke concentration is greater than the upper limit of the set threshold, the system starts the alarm when the fan is turned on.

Software flow of the pressure collecting module
Fig. 8 shows the flow of the pressure acquisition module.The power supply of the system starts to work, the program initialization is completed, the pressure sensor starts to collect the pressure value, and performs A/D conversion.When the pressure value does not reach the set value range, the system returns to perform pressure detection.When the pressure value reaches the set value range, the system automatically close windows.

Start
Whether the smoke value is greater than the lower limit of the threshold

Software flow of the display module
The flowchart of the display module system is shown in Fig. 9.The system starts to work, first set the command address, then read the read status word.If the read status word is busy, The actual design is shown in Fig. 10.This design adopts the idea of modularization to debug the software and hardware of the system.The overall debugging sequence is as follows: System power supply: connect the power supply and check the power supply of different modules.
Code burning: code burning into the development board.Sub-module debugging: modular debugging one by one.
Overall debugging: overall system debugging.

Conclusion
This design realizes the detection of indoor temperature, smoke and pressure next to the window.When the detected value exceeds the set threshold, this design will alarm to remind people to prevent fire and children from falling.This design has low cost and high data collection accuracy, and is suitable for widespread promotion.

Fig. 5 .
Fig. 5.The software flowchart of this design.

Fig. 6 .
Fig. 6.The flowchart of the temperature collection module.

Table 1 .
Parameters of the STM32F103C8T6.
ITM Web of Conferences 47, 01023 (2022) CCCAR2022 https://doi.org/10.1051/itmconf/20224701023read it again, otherwise start to write the command register.After that, the module is initialized.If the initialization fails, the set command address is returned.If the initialization is successful, the data port address is set.Next, continue to read the status word.If the channel is occupied, return to the status read.If there is no internal operation, write data to be displayed.