# Design and Analysis of Home Control Complex System Based on PLC Technology

Authors: Jiangyu Chen
Journal: Mobile Information Systems
 (2022)

---

## Abstract

The wide application of communication, automation, computer and other technologies not only provides a new direction for the development of home furnishing, but also makes the concept of “smart home” popular in recent years. The purpose of this study is to design a complex control system for smart healthcare home based on PLC technology. First, the research significance and background of this study are discussed, and the complex system, traditional PID control, and BP neural network algorithm are summarized. Second, the ZigBee wireless sensor network and PLC control system are studied, and the design of a smart health home control complex system based on PLC technology is analyzed. The experimental results show that when the indoor natural gas concentration is more than 1.25%,Y4 and Y3 are powered on, and Y2 is set as 1, that is, the alarm light is on, and the windows and exhaust fans are on. When the indoor flue gas (CO and CO2) concentration exceeds 0.06%, Y4 and Y3 are powered on, Y2 is set as 1, the alarm light is on, and the window exhaust fan is on. When the infrared detection output is 1, Y4 is powered on, Y2 is reset, the window is closed, and the alarm light is on. The human-machine interface of the Android mobile terminal of this system can be directly operated by the user and real-time monitoring data, reflecting the convenience of the design. Therefore, the design of complex home control system is of great significance in the home industry.


---

## Body

## 1. Introduction

Population aging is an important issue related to the future development of the country. China is now in the period of realizing the great rejuvenation of the nation. In the face of the aging population, which cannot be ignored, all aspects of society must be given full attention, and the aging population will have a huge impact on many aspects of China’s development. In order to make home security intelligent and efficient, China Mobile has specially created a “mobile housekeeping” home security solution, which uses multiform intelligent cameras as a carrier and artificial intelligence technology to provide intelligent home security and family care services for children, the elderly, and other family members.The research on healthcare home design is an important research direction for the suitability of living environment of the elderly, which can meet the needs of the elderly in China for the accessibility design of home space, and solve the related problems of the elderly living environment in the context of the current aging society. Through the research on the elderly healthcare home design, we further improve the elderly healthcare home space research system and lay a solid theoretical foundation for the overall study of healthcare environment construction in China.In view of the application of smart home, Dawadi et al. introduced a new type of intelligent remote control switch socket based on Wi-Fi and PLC technology to replace the traditional wired power supply. It uses Wi-Fi and PLC communication technology to realize the intelligent remote control switch socket and compares it with the existing technical scheme. The advantages of flexible network, low cost, easy to realize, and promote provide a design idea and method of intelligent switch socket for the development and promotion of the smart home system [1]. The smart home system (SHS) is an important application in pervasive computing. It makes home appliances and other information equipment connected with each other, and provides rich, personalized, convenient, safe, and efficient services through the network. Juang and Wu proposed an integrated solution for the smart home system based on OSGi and PLC. It enables people to get all the information they need anytime and anywhere through various intelligent devices. According to the results of pervasive computing to reflect the needs of people, through power line carrier communication, the calculation results will be implemented to various devices controlled in the smart home system [2]. However, at present, because of the defects in equipment and intelligent database, the above research is only in the theoretical stage, and there is no practicality.This system adopts two kinds of data acquisition methods to enhance the redundancy of the system, which can be used for numerical comparison and sensor fault judgment. PLC technology, ZigBee technology, and human-computer interface are selected to design the smart home system, and the communication between the Android mobile terminal and PLC is realized. Different from the general system design based on Android and ZigBee technology, choosing a PLC controller can make the system more stable than SCM. Using a PLC control system is of great significance to the smart home industry.


## 2. Proposed Method

### 2.1. Complex System

The concept of complex system is based on the critical inheritance of reductionism. The complex system theory is not a simple negation of reductionism [3]. Reductionism is effective and reasonable in a certain range, because there are other types of systems in the world besides complex systems. Generally speaking, the systems in the world are divided into three categories: simple system, stochastic system, and complex system [4].Simple system: the main feature of this kind of system is that it has few elements and a simple structure. Generally speaking, it can be described and analyzed by several parameters using mechanics [5]. The simple system has the characteristics of controllability, predictability, and organization. Students queuing in the canteen can be described by a simple system [6].Random system: the main feature of this kind of system is that there are many constituent elements, but compared with the complex system, the correlation between the constituent elements is small, or the correlation between the elements is random [7]. Generally speaking, the statistical method can be used to describe and analyze the stochastic system. The thermodynamic system and the purchase of lottery tickets are typical examples of stochastic systems [8].


### 2.2. Traditional PID Control

The PID control algorithm is one of the earliest developed control algorithms; it has the characteristics of convenient use, good recklessness, and high reliability; and it has these advantages that make the algorithm widely used in practical engineering [9]. The system collects the indoor parameters through external sensors, and then performs A/D conversion of the data and transmits it to the controller. After receiving the data, the controller compares it with the preset value to determine whether to control the data [10, 11].


#### 2.2.1. Control Principle of Traditional PID Algorithm

The principle of the traditional PID control algorithm is to improve the dynamic performance of the system by calculating the proportion, integration, and differentiation of the input data. The expression of the traditional PID control algorithm is as follows:(1)ut=kpet+1TI∫01eτdτ+TDdetdt.In the formula,KP is the proportional magnification; Ti is the integral time constant; and TD is the differential time constant.The following is a simple analysis of each link of the PID control algorithm. The analysis results are as follows:(1)
Proportional link: this link is a response toE(T) (deviation signal) of the control system after proportional processing. Once the signal is found to have deviation, this link will act to reduce the deviation between the actual signal and the system preset [12].(2)
Integration link: this link is mainly to improve the error-free degree of the whole system by eliminating the static error of the system. The strength of the integral action is inversely proportional to the magnitude of the integral time constantTi. The larger Ti is, the weaker the action is; otherwise, the stronger.(3)
Differential link: this link is used to reflect the change trend (change rate) ofE(T) (deviation signal) and generate a correction signal to correct the rate before the rate changes too much, so as to reduce the adjustment time and speed up the algorithm. But the disadvantage of this link is the poor anti-interference ability.


#### 2.2.2. Parameter Tuning of the Traditional PID Control Algorithm

The parameters regulated by the traditional PID control algorithm are proportional coefficientKp, integral time Ti, and differential time TD. The choice of these three parameters directly determines the recklessness, accuracy, and rapidity of the whole algorithm. In the development of the whole PID control history, there are different opinions on the selection methods of these three parameters. We have made a statistics on the commonly used methods, about the following [13, 14]:(1)
Attenuation curve(2)
ISTE optimality determination(3)
Setting method based on comprehensive practice constant(4)
Tuning method based on gain optimization(5)
Parameter tuning based on cross two-point method(6)
Critical scale methodHowever, most of these methods need the existing experience to calculate and select the corresponding formula, which makes the calculation of the system more complex, thus reducing the efficiency of the whole system [15, 16]. Because there are many interference factors in the practical engineering environment, an experienced engineer is needed to regularly adjust the three parameters. In order to overcome these problems, this study uses the BP neural network algorithm to calculate the collected information, adjusts these three parameters in real time, transmits the adjusted parameters to the PID control algorithm for application, and transmits the final results to each module of the system for application [17, 18].


### 2.3. BP Neural Network Algorithm

The BP neural network algorithm is based on the existing algorithm of the BP neural network. It is to set up linear equations by arbitrarily selecting a group of weights and directly taking the given target output as an algebraic sum of linear equations. The weights to be solved are obtained. There are no local minima and slow convergence of traditional methods, and it is easier to understand.With the increasing progress of science and technology, no matter in industry, agriculture, or even household manufacturing industry, there are more and more data needed to control the corresponding industry, and the control methods are more and more complex [19, 20]. The traditional control method has been unable to meet people’s requirements on the accuracy, timeliness, and convenience of the controlled object, so the application of the artificial intelligence network algorithm in various fields has become the inevitable trend in people’s production and development. Because of this, the artificial intelligence network algorithm has also been in rapid development in recent years [21].


#### 2.3.1. Artificial Neuron Model

The artificial neuron model is developed according to the biological neuron network. People want to realize the independent thinking of the target data through the constructed neurons, so as to achieve the fast and efficient data processing. Each artificial neuron is equivalent to a single biological neuron, which is the smallest component of the artificial neural network, and its function is equivalent to a threshold device of multiple inputs and single output [22].There are many kinds of activation functions of the neural network algorithm, which formula should be chosen according to the actual needs of the design. The commonly used activation functionsf(x) are as follows: linear function, slope function, threshold function, S-type function, bipolar S-type function, and so on. In this study, the S-type activation function is used to calculate the data in the neural network. The formula of the S-type function is as follows:(2)fx=11+e−αx0<fx<1,fx=αe−αx1+e−αx2.


#### 2.3.2. Algorithm Thought of the BP Neural Network

The neural network algorithm can be divided into forward learning, feedback (recursive) learning, tutor learning network, and unsupervised learning network. The BP neural network algorithm adopts the learning methods of forward type and tutor, and the algorithm is divided into two propagation stages: forward propagation stage and backpropagation stage [23]. The specific learning steps are as follows: first, we learn and calculate the collected sample data, pass the collected information through the input layer through the hidden layer for forward transmission, and then carry out the data weighting processing, and the weighted data of each layer only affects the data of its next layer [24, 25]. The error is calculated by comparing the processed data with the preset value, and the error signal is propagated back. Through the repeated correction and learning of the collected samples, the output can be accurately and quickly adjusted, so as to reduce the impact of external interference on the system data analysis. The BP neural network algorithm to the function and database module of the smart home system can help the system collect data better.


#### 2.3.3. The PID Control Algorithm Based on the BP Neural Network

The algorithm proposed in this study mainly combines the BP neural network control algorithm with the traditional PID control algorithm and makes up for the shortcomings of the traditional PID control algorithm in function, so that the results are more accurate and faster. The principle of the algorithm is to modify the parametersKP, Ki, and KD through the BP neural network algorithm to achieve the most appropriate value of the experiment, so that the traditional PID algorithm is slow in calculation and the calculation results are not accurate. The algorithm first collects the indoor temperature through the indoor sensor, compares the difference between the collected temperature and the preset ideal value, and then reduces the difference between the indoor temperature and the preset value through the weighting, mapping, and feedback of the BP neural network algorithm, so as to realize that the indoor temperature is always kept at the optimum temperature.Because there is no BP neural network function model in MATLAB Simulink, the sigmoid function is used to edit the BP neural network system, and then, thes function is directly introduced into Simulink simulation to achieve the simulation of the whole PID control algorithm based on the BP neural network. Suppose the BP neural network is a three-layer network, the number of nodes is m in the input layer, Q in the hidden layer, and 3 in the output layer. The output nodes are the three parameters KP, Ki, and KD, which need to be controlled in the PID algorithm.


### 2.4. ZigBee Wireless Sensor Network

The ZigBee network is based on a Z-stack protocol stack, relying on the IAR development environment, taking the CC2530 module as the core controller to control each sensor, and building a wireless sensor network suitable for the smart home system. The sensors placed in each room need a terminal node to collect data, which is sent to the coordinator node through star network wireless mode, and the coordinator node sends parameters to the upper computer for display through serial communication. Generally, sensors are deployed in the area that can be monitored. The ZigBee sensor network has a wide range of application prospects, such as national defense, agriculture, industry, urban management, and other automatic control fields. It consists of sensor nodes, aggregation nodes, and management nodes.Compared with the sink node, the sensor node has a relatively weak ability for signal processing, data storage, and communication. Sensor nodes take into account the functions of terminal nodes and routing nodes. The sink node connects the wireless sensor network and the external network, and converts the two communication protocols, which are mainly used for data collection. The management node, as the name implies, is to manage the sensor network and perform the function of configuring the network; when it publishes monitoring tasks, the sink node also publishes tasks at the same time. Chinese style.In general, many users use wired network connection mode to build the system network when collecting data. Due to the large number of sensor nodes, it is difficult to wire on-site, and the system maintenance is complex and unsightly. The establishment and joining of a ZigBee-based wireless sensor network can effectively avoid these problems. Its characteristics are as follows:(1)
Large-scale network. The distribution area of the infinite sensor network is very large, and the deployment of nodes is relatively intensive. The actual indoor space of the home just needs a wide distribution of network transmission data, many nodes, and large-scale network to meet the functional requirements of the smart home system design.(2)
Self-organizing network. Sensor nodes, with the ability of self-organization, can configure and manage their own wireless network, and automatically form multiple wireless network systems to forward monitoring data through topology control mechanism and network protocol. Chinese style.(3)
Dynamic network. In the process of data collection and transmission, there will be sensor damage, failure, and other phenomena, which will lead to the failure of normal reception and transmission of data. At this time, the wireless sensor network needs to adapt to these changes; the broadband of the communication link will also change, even intermittently. Finally, we should pay attention to the dynamic changes of the network when new nodes join. The sensor also has dynamic characteristics. Chinese style.(4)
Reliable network. The hardware and software of the sensor network are robust and fault-tolerant, and the network can maintain some of its characteristics when the control system has certain parameters of interference. A stable system is the characteristic of the system, and a reliable network is helpful to the stability of the system.(5)
Data-centric network. The sensor network is a task-based network. The command sent by the user is transmitted to the network, and the network will send feedback information to the user at the same time. Wireless networks will also use this data information.The ZigBee wireless information collection network integrates wireless communication, distributed information processing, node data collection, and other technologies; collects sensor data of various environmental factors of the object in real time; processes information through the CC2530 main control chip; and transmits the collected information to the monitoring station through the ZigBee wireless communication network, after data collection, processing, sending, receiving, and other processes.


### 2.5. PLC Control System

The PLC is selected as the intelligent home system. The main controller has stable and reliable performance, multiple functions, and wide application, which alleviates the disadvantages of high failure rate and poor stability of single-chip microcomputer. It can select a special memory; write programs according to the state of input signals such as switching value and pulse; select timers, alarms, and counters; perform logic operation, transmission comparison, floating-point operation, data processing, and other instructions; generate corresponding output signals; and transmit them to the output equipment, through the control of relay, solenoid valve, and other mechanical operations to achieve automatic control. Users can edit or change programs and control peripherals. PLC has made a great contribution in the field of automation.When PLC is running, the CPU scanning process is periodic. According to the written program, it is executed from the beginning in sequence (if there is a jump instruction in the program, select jump) until the end of the program scanning. This is a cycle. Then, the CPU continues to scan and perform the same operation as the previous cycle. Then, the stored output content will change with the completion of these tasks, and the status results of the register will be output, so that the corresponding actions of the output device can be controlled. Features of PLC are as follows: simple to use, stable system, software and hardware, simulation, debugging, maintenance, wiring, expansion, and communication interface.There are many kinds of PLC products. The PLC controller with high-cost performance and suitable for the system must be selected in combination with the electrical specifications, input and output points, programming methods, programming instructions, wiring methods, hardware debugging, communication methods and other characteristics of different models of PLC. On the basis of determining the input, output points, and storage capacity of the system, and counting the total input and output points, it is also necessary to increase some margins as a backup.


## 2.1. Complex System

The concept of complex system is based on the critical inheritance of reductionism. The complex system theory is not a simple negation of reductionism [3]. Reductionism is effective and reasonable in a certain range, because there are other types of systems in the world besides complex systems. Generally speaking, the systems in the world are divided into three categories: simple system, stochastic system, and complex system [4].Simple system: the main feature of this kind of system is that it has few elements and a simple structure. Generally speaking, it can be described and analyzed by several parameters using mechanics [5]. The simple system has the characteristics of controllability, predictability, and organization. Students queuing in the canteen can be described by a simple system [6].Random system: the main feature of this kind of system is that there are many constituent elements, but compared with the complex system, the correlation between the constituent elements is small, or the correlation between the elements is random [7]. Generally speaking, the statistical method can be used to describe and analyze the stochastic system. The thermodynamic system and the purchase of lottery tickets are typical examples of stochastic systems [8].


## 2.2. Traditional PID Control

The PID control algorithm is one of the earliest developed control algorithms; it has the characteristics of convenient use, good recklessness, and high reliability; and it has these advantages that make the algorithm widely used in practical engineering [9]. The system collects the indoor parameters through external sensors, and then performs A/D conversion of the data and transmits it to the controller. After receiving the data, the controller compares it with the preset value to determine whether to control the data [10, 11].


### 2.2.1. Control Principle of Traditional PID Algorithm

The principle of the traditional PID control algorithm is to improve the dynamic performance of the system by calculating the proportion, integration, and differentiation of the input data. The expression of the traditional PID control algorithm is as follows:(1)ut=kpet+1TI∫01eτdτ+TDdetdt.In the formula,KP is the proportional magnification; Ti is the integral time constant; and TD is the differential time constant.The following is a simple analysis of each link of the PID control algorithm. The analysis results are as follows:(1)
Proportional link: this link is a response toE(T) (deviation signal) of the control system after proportional processing. Once the signal is found to have deviation, this link will act to reduce the deviation between the actual signal and the system preset [12].(2)
Integration link: this link is mainly to improve the error-free degree of the whole system by eliminating the static error of the system. The strength of the integral action is inversely proportional to the magnitude of the integral time constantTi. The larger Ti is, the weaker the action is; otherwise, the stronger.(3)
Differential link: this link is used to reflect the change trend (change rate) ofE(T) (deviation signal) and generate a correction signal to correct the rate before the rate changes too much, so as to reduce the adjustment time and speed up the algorithm. But the disadvantage of this link is the poor anti-interference ability.


### 2.2.2. Parameter Tuning of the Traditional PID Control Algorithm

The parameters regulated by the traditional PID control algorithm are proportional coefficientKp, integral time Ti, and differential time TD. The choice of these three parameters directly determines the recklessness, accuracy, and rapidity of the whole algorithm. In the development of the whole PID control history, there are different opinions on the selection methods of these three parameters. We have made a statistics on the commonly used methods, about the following [13, 14]:(1)
Attenuation curve(2)
ISTE optimality determination(3)
Setting method based on comprehensive practice constant(4)
Tuning method based on gain optimization(5)
Parameter tuning based on cross two-point method(6)
Critical scale methodHowever, most of these methods need the existing experience to calculate and select the corresponding formula, which makes the calculation of the system more complex, thus reducing the efficiency of the whole system [15, 16]. Because there are many interference factors in the practical engineering environment, an experienced engineer is needed to regularly adjust the three parameters. In order to overcome these problems, this study uses the BP neural network algorithm to calculate the collected information, adjusts these three parameters in real time, transmits the adjusted parameters to the PID control algorithm for application, and transmits the final results to each module of the system for application [17, 18].


## 2.2.1. Control Principle of Traditional PID Algorithm

The principle of the traditional PID control algorithm is to improve the dynamic performance of the system by calculating the proportion, integration, and differentiation of the input data. The expression of the traditional PID control algorithm is as follows:(1)ut=kpet+1TI∫01eτdτ+TDdetdt.In the formula,KP is the proportional magnification; Ti is the integral time constant; and TD is the differential time constant.The following is a simple analysis of each link of the PID control algorithm. The analysis results are as follows:(1)
Proportional link: this link is a response toE(T) (deviation signal) of the control system after proportional processing. Once the signal is found to have deviation, this link will act to reduce the deviation between the actual signal and the system preset [12].(2)
Integration link: this link is mainly to improve the error-free degree of the whole system by eliminating the static error of the system. The strength of the integral action is inversely proportional to the magnitude of the integral time constantTi. The larger Ti is, the weaker the action is; otherwise, the stronger.(3)
Differential link: this link is used to reflect the change trend (change rate) ofE(T) (deviation signal) and generate a correction signal to correct the rate before the rate changes too much, so as to reduce the adjustment time and speed up the algorithm. But the disadvantage of this link is the poor anti-interference ability.


## 2.2.2. Parameter Tuning of the Traditional PID Control Algorithm

The parameters regulated by the traditional PID control algorithm are proportional coefficientKp, integral time Ti, and differential time TD. The choice of these three parameters directly determines the recklessness, accuracy, and rapidity of the whole algorithm. In the development of the whole PID control history, there are different opinions on the selection methods of these three parameters. We have made a statistics on the commonly used methods, about the following [13, 14]:(1)
Attenuation curve(2)
ISTE optimality determination(3)
Setting method based on comprehensive practice constant(4)
Tuning method based on gain optimization(5)
Parameter tuning based on cross two-point method(6)
Critical scale methodHowever, most of these methods need the existing experience to calculate and select the corresponding formula, which makes the calculation of the system more complex, thus reducing the efficiency of the whole system [15, 16]. Because there are many interference factors in the practical engineering environment, an experienced engineer is needed to regularly adjust the three parameters. In order to overcome these problems, this study uses the BP neural network algorithm to calculate the collected information, adjusts these three parameters in real time, transmits the adjusted parameters to the PID control algorithm for application, and transmits the final results to each module of the system for application [17, 18].


## 2.3. BP Neural Network Algorithm

The BP neural network algorithm is based on the existing algorithm of the BP neural network. It is to set up linear equations by arbitrarily selecting a group of weights and directly taking the given target output as an algebraic sum of linear equations. The weights to be solved are obtained. There are no local minima and slow convergence of traditional methods, and it is easier to understand.With the increasing progress of science and technology, no matter in industry, agriculture, or even household manufacturing industry, there are more and more data needed to control the corresponding industry, and the control methods are more and more complex [19, 20]. The traditional control method has been unable to meet people’s requirements on the accuracy, timeliness, and convenience of the controlled object, so the application of the artificial intelligence network algorithm in various fields has become the inevitable trend in people’s production and development. Because of this, the artificial intelligence network algorithm has also been in rapid development in recent years [21].


### 2.3.1. Artificial Neuron Model

The artificial neuron model is developed according to the biological neuron network. People want to realize the independent thinking of the target data through the constructed neurons, so as to achieve the fast and efficient data processing. Each artificial neuron is equivalent to a single biological neuron, which is the smallest component of the artificial neural network, and its function is equivalent to a threshold device of multiple inputs and single output [22].There are many kinds of activation functions of the neural network algorithm, which formula should be chosen according to the actual needs of the design. The commonly used activation functionsf(x) are as follows: linear function, slope function, threshold function, S-type function, bipolar S-type function, and so on. In this study, the S-type activation function is used to calculate the data in the neural network. The formula of the S-type function is as follows:(2)fx=11+e−αx0<fx<1,fx=αe−αx1+e−αx2.


### 2.3.2. Algorithm Thought of the BP Neural Network

The neural network algorithm can be divided into forward learning, feedback (recursive) learning, tutor learning network, and unsupervised learning network. The BP neural network algorithm adopts the learning methods of forward type and tutor, and the algorithm is divided into two propagation stages: forward propagation stage and backpropagation stage [23]. The specific learning steps are as follows: first, we learn and calculate the collected sample data, pass the collected information through the input layer through the hidden layer for forward transmission, and then carry out the data weighting processing, and the weighted data of each layer only affects the data of its next layer [24, 25]. The error is calculated by comparing the processed data with the preset value, and the error signal is propagated back. Through the repeated correction and learning of the collected samples, the output can be accurately and quickly adjusted, so as to reduce the impact of external interference on the system data analysis. The BP neural network algorithm to the function and database module of the smart home system can help the system collect data better.


### 2.3.3. The PID Control Algorithm Based on the BP Neural Network

The algorithm proposed in this study mainly combines the BP neural network control algorithm with the traditional PID control algorithm and makes up for the shortcomings of the traditional PID control algorithm in function, so that the results are more accurate and faster. The principle of the algorithm is to modify the parametersKP, Ki, and KD through the BP neural network algorithm to achieve the most appropriate value of the experiment, so that the traditional PID algorithm is slow in calculation and the calculation results are not accurate. The algorithm first collects the indoor temperature through the indoor sensor, compares the difference between the collected temperature and the preset ideal value, and then reduces the difference between the indoor temperature and the preset value through the weighting, mapping, and feedback of the BP neural network algorithm, so as to realize that the indoor temperature is always kept at the optimum temperature.Because there is no BP neural network function model in MATLAB Simulink, the sigmoid function is used to edit the BP neural network system, and then, thes function is directly introduced into Simulink simulation to achieve the simulation of the whole PID control algorithm based on the BP neural network. Suppose the BP neural network is a three-layer network, the number of nodes is m in the input layer, Q in the hidden layer, and 3 in the output layer. The output nodes are the three parameters KP, Ki, and KD, which need to be controlled in the PID algorithm.


## 2.3.1. Artificial Neuron Model

The artificial neuron model is developed according to the biological neuron network. People want to realize the independent thinking of the target data through the constructed neurons, so as to achieve the fast and efficient data processing. Each artificial neuron is equivalent to a single biological neuron, which is the smallest component of the artificial neural network, and its function is equivalent to a threshold device of multiple inputs and single output [22].There are many kinds of activation functions of the neural network algorithm, which formula should be chosen according to the actual needs of the design. The commonly used activation functionsf(x) are as follows: linear function, slope function, threshold function, S-type function, bipolar S-type function, and so on. In this study, the S-type activation function is used to calculate the data in the neural network. The formula of the S-type function is as follows:(2)fx=11+e−αx0<fx<1,fx=αe−αx1+e−αx2.


## 2.3.2. Algorithm Thought of the BP Neural Network

The neural network algorithm can be divided into forward learning, feedback (recursive) learning, tutor learning network, and unsupervised learning network. The BP neural network algorithm adopts the learning methods of forward type and tutor, and the algorithm is divided into two propagation stages: forward propagation stage and backpropagation stage [23]. The specific learning steps are as follows: first, we learn and calculate the collected sample data, pass the collected information through the input layer through the hidden layer for forward transmission, and then carry out the data weighting processing, and the weighted data of each layer only affects the data of its next layer [24, 25]. The error is calculated by comparing the processed data with the preset value, and the error signal is propagated back. Through the repeated correction and learning of the collected samples, the output can be accurately and quickly adjusted, so as to reduce the impact of external interference on the system data analysis. The BP neural network algorithm to the function and database module of the smart home system can help the system collect data better.


## 2.3.3. The PID Control Algorithm Based on the BP Neural Network

The algorithm proposed in this study mainly combines the BP neural network control algorithm with the traditional PID control algorithm and makes up for the shortcomings of the traditional PID control algorithm in function, so that the results are more accurate and faster. The principle of the algorithm is to modify the parametersKP, Ki, and KD through the BP neural network algorithm to achieve the most appropriate value of the experiment, so that the traditional PID algorithm is slow in calculation and the calculation results are not accurate. The algorithm first collects the indoor temperature through the indoor sensor, compares the difference between the collected temperature and the preset ideal value, and then reduces the difference between the indoor temperature and the preset value through the weighting, mapping, and feedback of the BP neural network algorithm, so as to realize that the indoor temperature is always kept at the optimum temperature.Because there is no BP neural network function model in MATLAB Simulink, the sigmoid function is used to edit the BP neural network system, and then, thes function is directly introduced into Simulink simulation to achieve the simulation of the whole PID control algorithm based on the BP neural network. Suppose the BP neural network is a three-layer network, the number of nodes is m in the input layer, Q in the hidden layer, and 3 in the output layer. The output nodes are the three parameters KP, Ki, and KD, which need to be controlled in the PID algorithm.


## 2.4. ZigBee Wireless Sensor Network

The ZigBee network is based on a Z-stack protocol stack, relying on the IAR development environment, taking the CC2530 module as the core controller to control each sensor, and building a wireless sensor network suitable for the smart home system. The sensors placed in each room need a terminal node to collect data, which is sent to the coordinator node through star network wireless mode, and the coordinator node sends parameters to the upper computer for display through serial communication. Generally, sensors are deployed in the area that can be monitored. The ZigBee sensor network has a wide range of application prospects, such as national defense, agriculture, industry, urban management, and other automatic control fields. It consists of sensor nodes, aggregation nodes, and management nodes.Compared with the sink node, the sensor node has a relatively weak ability for signal processing, data storage, and communication. Sensor nodes take into account the functions of terminal nodes and routing nodes. The sink node connects the wireless sensor network and the external network, and converts the two communication protocols, which are mainly used for data collection. The management node, as the name implies, is to manage the sensor network and perform the function of configuring the network; when it publishes monitoring tasks, the sink node also publishes tasks at the same time. Chinese style.In general, many users use wired network connection mode to build the system network when collecting data. Due to the large number of sensor nodes, it is difficult to wire on-site, and the system maintenance is complex and unsightly. The establishment and joining of a ZigBee-based wireless sensor network can effectively avoid these problems. Its characteristics are as follows:(1)
Large-scale network. The distribution area of the infinite sensor network is very large, and the deployment of nodes is relatively intensive. The actual indoor space of the home just needs a wide distribution of network transmission data, many nodes, and large-scale network to meet the functional requirements of the smart home system design.(2)
Self-organizing network. Sensor nodes, with the ability of self-organization, can configure and manage their own wireless network, and automatically form multiple wireless network systems to forward monitoring data through topology control mechanism and network protocol. Chinese style.(3)
Dynamic network. In the process of data collection and transmission, there will be sensor damage, failure, and other phenomena, which will lead to the failure of normal reception and transmission of data. At this time, the wireless sensor network needs to adapt to these changes; the broadband of the communication link will also change, even intermittently. Finally, we should pay attention to the dynamic changes of the network when new nodes join. The sensor also has dynamic characteristics. Chinese style.(4)
Reliable network. The hardware and software of the sensor network are robust and fault-tolerant, and the network can maintain some of its characteristics when the control system has certain parameters of interference. A stable system is the characteristic of the system, and a reliable network is helpful to the stability of the system.(5)
Data-centric network. The sensor network is a task-based network. The command sent by the user is transmitted to the network, and the network will send feedback information to the user at the same time. Wireless networks will also use this data information.The ZigBee wireless information collection network integrates wireless communication, distributed information processing, node data collection, and other technologies; collects sensor data of various environmental factors of the object in real time; processes information through the CC2530 main control chip; and transmits the collected information to the monitoring station through the ZigBee wireless communication network, after data collection, processing, sending, receiving, and other processes.


## 2.5. PLC Control System

The PLC is selected as the intelligent home system. The main controller has stable and reliable performance, multiple functions, and wide application, which alleviates the disadvantages of high failure rate and poor stability of single-chip microcomputer. It can select a special memory; write programs according to the state of input signals such as switching value and pulse; select timers, alarms, and counters; perform logic operation, transmission comparison, floating-point operation, data processing, and other instructions; generate corresponding output signals; and transmit them to the output equipment, through the control of relay, solenoid valve, and other mechanical operations to achieve automatic control. Users can edit or change programs and control peripherals. PLC has made a great contribution in the field of automation.When PLC is running, the CPU scanning process is periodic. According to the written program, it is executed from the beginning in sequence (if there is a jump instruction in the program, select jump) until the end of the program scanning. This is a cycle. Then, the CPU continues to scan and perform the same operation as the previous cycle. Then, the stored output content will change with the completion of these tasks, and the status results of the register will be output, so that the corresponding actions of the output device can be controlled. Features of PLC are as follows: simple to use, stable system, software and hardware, simulation, debugging, maintenance, wiring, expansion, and communication interface.There are many kinds of PLC products. The PLC controller with high-cost performance and suitable for the system must be selected in combination with the electrical specifications, input and output points, programming methods, programming instructions, wiring methods, hardware debugging, communication methods and other characteristics of different models of PLC. On the basis of determining the input, output points, and storage capacity of the system, and counting the total input and output points, it is also necessary to increase some margins as a backup.


## 3. Experiments

### 3.1. Subjects

The main goal of this design is to provide users with a practical, convenient, stable, and safe living environment. Mainly by PLC through receiving data, the input signal is judged and processed, and then, the peripheral equipment is controlled.This system will establish a smart home system based on PLC as the main control module, and the overall design includes four parts, specifically detection part, control part, human-computer interface, and Android mobile terminal. The detection part includes the detection of temperature, humidity, smoke concentration, natural gas concentration, noise, rain and snow, infrared detection, and other seven physical quantities. The control part mainly uses air conditioning, humidifier, exhaust fan, and window to control and adjust seven parameters of production environment, such as temperature and humidity; the main functions of the human-computer interface are data real-time display, data storage, parameter setting, human-computer interaction and printing, etc. The main function of the Android mobile terminal is to display the switch status of each household device, and judge according to the collected parameter data part and the user’s own artificial judgment to control and adjust the switch of household appliances.


### 3.2. Selection of PLC

The whole intelligent home control system needs 18 digital input I/O points and 15 output I/O points. Therefore, the dvp14ss host is selected, which includes 8 inputs and 6 outputs; the dvp14ss host contains communication data line interface, is compatible with Modbus ASCII/RTU communication protocol and 4 k program storage space, and has an expansion function. This module is more in line with the function of the system. Chinese style.


### 3.3. Experimental Environment

#### 3.3.1. Hardware of the System

The PLC control part of the smart home system is mainly used to collect temperature, humidity, etc., and convert analog quantities to digital output for PLC operation and processing, and then control and adjust the corresponding output devices through operation judgment. The hardware equipment required in the PLC system is shown in Table1.Table 1
List of main hardware equipment of the system.
Device nameModelExplanationNumberRemarksTemperature moduleDVP-04PTIt can be connected to 4-way temperature sensor1Acquisition temperature analog quantity and digital quantity outputAD conversion moduleDVP-04ADIt can be connected to 4-way sensor2Convert analog quantity to digital quantity outputTemperature sensorPt-100Matching with dvp-04pt1Three-wire platinum resistance temperature sensorHumidity sensorHM15001-4vdc linear voltage output2High reliability, long-term stability, and measurement accuracy: ± 3% RHPyroelectric induction moduleHN911LThe released charge is converted to voltage output through amplifier1Working voltage range 3–15 VThe dvp-04ad analog signal input module, whose function is to convert the analog input signal into 14-bit digital signal, can be externally connected with 4-point voltage or current analog signal input. We receive a voltage signal with an input range of ±10 V and a current signal with an input range of ±20 mA. There are 49 registers in the module, and each register has 16 bits. We read and write the data through the CR data write/read command of the expansion module in the PLC program. The working voltage range of the seven kinds of analog physical quantities is 0∼10 V, so the two-wire system is adopted. There are 8 analog inputs in the system, so 2 ad modules are needed.


#### 3.3.2. External Equipment

In the design of the smart home system, when it is detected that the indoor temperature, humidity, and other physical quantities exceed the set range, the switch operations of air conditioners, humidifiers, exhaust fans, and windows are performed, respectively. When the infrared detection signal is detected as the high-level signal, the window will be opened or closed; in the experiment process of this system, the air conditioner and humidifier are replaced by a DC motor, and the exhaust fan is relay.


#### 3.3.3. Power Module

In the design of this system, there are two ways: DC power supply and solar power supply. In order to prevent the occurrence of household power failure or other power failure, solar power supply can provide guarantee for the normal operation of the smart home system. The working voltage of CC2530 is 3.3 V, and the solar power supply system meets the power supply requirements of the smart home system.


## 3.1. Subjects

The main goal of this design is to provide users with a practical, convenient, stable, and safe living environment. Mainly by PLC through receiving data, the input signal is judged and processed, and then, the peripheral equipment is controlled.This system will establish a smart home system based on PLC as the main control module, and the overall design includes four parts, specifically detection part, control part, human-computer interface, and Android mobile terminal. The detection part includes the detection of temperature, humidity, smoke concentration, natural gas concentration, noise, rain and snow, infrared detection, and other seven physical quantities. The control part mainly uses air conditioning, humidifier, exhaust fan, and window to control and adjust seven parameters of production environment, such as temperature and humidity; the main functions of the human-computer interface are data real-time display, data storage, parameter setting, human-computer interaction and printing, etc. The main function of the Android mobile terminal is to display the switch status of each household device, and judge according to the collected parameter data part and the user’s own artificial judgment to control and adjust the switch of household appliances.


## 3.2. Selection of PLC

The whole intelligent home control system needs 18 digital input I/O points and 15 output I/O points. Therefore, the dvp14ss host is selected, which includes 8 inputs and 6 outputs; the dvp14ss host contains communication data line interface, is compatible with Modbus ASCII/RTU communication protocol and 4 k program storage space, and has an expansion function. This module is more in line with the function of the system. Chinese style.


## 3.3. Experimental Environment

### 3.3.1. Hardware of the System

The PLC control part of the smart home system is mainly used to collect temperature, humidity, etc., and convert analog quantities to digital output for PLC operation and processing, and then control and adjust the corresponding output devices through operation judgment. The hardware equipment required in the PLC system is shown in Table1.Table 1
List of main hardware equipment of the system.
Device nameModelExplanationNumberRemarksTemperature moduleDVP-04PTIt can be connected to 4-way temperature sensor1Acquisition temperature analog quantity and digital quantity outputAD conversion moduleDVP-04ADIt can be connected to 4-way sensor2Convert analog quantity to digital quantity outputTemperature sensorPt-100Matching with dvp-04pt1Three-wire platinum resistance temperature sensorHumidity sensorHM15001-4vdc linear voltage output2High reliability, long-term stability, and measurement accuracy: ± 3% RHPyroelectric induction moduleHN911LThe released charge is converted to voltage output through amplifier1Working voltage range 3–15 VThe dvp-04ad analog signal input module, whose function is to convert the analog input signal into 14-bit digital signal, can be externally connected with 4-point voltage or current analog signal input. We receive a voltage signal with an input range of ±10 V and a current signal with an input range of ±20 mA. There are 49 registers in the module, and each register has 16 bits. We read and write the data through the CR data write/read command of the expansion module in the PLC program. The working voltage range of the seven kinds of analog physical quantities is 0∼10 V, so the two-wire system is adopted. There are 8 analog inputs in the system, so 2 ad modules are needed.


### 3.3.2. External Equipment

In the design of the smart home system, when it is detected that the indoor temperature, humidity, and other physical quantities exceed the set range, the switch operations of air conditioners, humidifiers, exhaust fans, and windows are performed, respectively. When the infrared detection signal is detected as the high-level signal, the window will be opened or closed; in the experiment process of this system, the air conditioner and humidifier are replaced by a DC motor, and the exhaust fan is relay.


### 3.3.3. Power Module

In the design of this system, there are two ways: DC power supply and solar power supply. In order to prevent the occurrence of household power failure or other power failure, solar power supply can provide guarantee for the normal operation of the smart home system. The working voltage of CC2530 is 3.3 V, and the solar power supply system meets the power supply requirements of the smart home system.


## 3.3.1. Hardware of the System

The PLC control part of the smart home system is mainly used to collect temperature, humidity, etc., and convert analog quantities to digital output for PLC operation and processing, and then control and adjust the corresponding output devices through operation judgment. The hardware equipment required in the PLC system is shown in Table1.Table 1
List of main hardware equipment of the system.
Device nameModelExplanationNumberRemarksTemperature moduleDVP-04PTIt can be connected to 4-way temperature sensor1Acquisition temperature analog quantity and digital quantity outputAD conversion moduleDVP-04ADIt can be connected to 4-way sensor2Convert analog quantity to digital quantity outputTemperature sensorPt-100Matching with dvp-04pt1Three-wire platinum resistance temperature sensorHumidity sensorHM15001-4vdc linear voltage output2High reliability, long-term stability, and measurement accuracy: ± 3% RHPyroelectric induction moduleHN911LThe released charge is converted to voltage output through amplifier1Working voltage range 3–15 VThe dvp-04ad analog signal input module, whose function is to convert the analog input signal into 14-bit digital signal, can be externally connected with 4-point voltage or current analog signal input. We receive a voltage signal with an input range of ±10 V and a current signal with an input range of ±20 mA. There are 49 registers in the module, and each register has 16 bits. We read and write the data through the CR data write/read command of the expansion module in the PLC program. The working voltage range of the seven kinds of analog physical quantities is 0∼10 V, so the two-wire system is adopted. There are 8 analog inputs in the system, so 2 ad modules are needed.


## 3.3.2. External Equipment

In the design of the smart home system, when it is detected that the indoor temperature, humidity, and other physical quantities exceed the set range, the switch operations of air conditioners, humidifiers, exhaust fans, and windows are performed, respectively. When the infrared detection signal is detected as the high-level signal, the window will be opened or closed; in the experiment process of this system, the air conditioner and humidifier are replaced by a DC motor, and the exhaust fan is relay.


## 3.3.3. Power Module

In the design of this system, there are two ways: DC power supply and solar power supply. In order to prevent the occurrence of household power failure or other power failure, solar power supply can provide guarantee for the normal operation of the smart home system. The working voltage of CC2530 is 3.3 V, and the solar power supply system meets the power supply requirements of the smart home system.


## 4. Discussion

### 4.1. Temperature Acquisition and Compensation Procedure

#### 4.1.1. Instructions for Use

The DVP series PLC uses this instruction to read CR data of special module, read the content ofK2 in K18 of special module to PLC, and read three times at a time. 2 in K2 refers to the number of foot module, K18 refers to the number of value register, D40 refers to the storage first address of temperature value, and 3 in K3 refers to reading three data at a time. The acquisition procedure is shown in Figure 1.Figure 1
Temperature acquisition procedure.Figure 2
Temperature comparison alarm procedure.On M1000, the conduction is on, and the channel is open. From the first temperature control module, PLC takes out the current temperature values stored in CR × 18 and Cr × 19 and places them inD40 and D41 (among which D40 and D41 store indoor temperature values and D42 store outdoor temperature values). After the indoor temperature values are compensated, they are displayed in the corresponding addresses D43 and D44 of the touch screen. (The outdoor temperature value is only compared with the indoor value, and the accuracy requirement is not high). We calculate the average value of the collected indoor temperature value through the mean command, store the calculated average value in the do address, and display the indoor temperature value on the touch screen.


#### 4.1.2. Error Compensation Description

Due to various factors such as wire resistance, the simultaneous interpretation of the PLC’s temperature will cause some deviation. This requires temperature compensation. Considering the different errors of different sensors, different compensation values are added to each sensor. The compensation values of the two temperature sensors areD14 and D15, respectively, and the compensation values are measured after the system is debugged. Different from the actual measurement, after calculation, the user can directly input the value into the touch screenfig2.


### 4.2. Comparison Alarm Procedure

(1)
The user can refer to the standard value (22°C ∼ 28°C in summer and 16°C ∼ 24°C in winter) and set the upper and lower limits of the alarm by himself (the range of the upper and lower limits of the alarm parameter should be greater than the upper and lower limits of the normal parameter setting). When the collected data are lower than the normal lower limit or higher than the normal upper limit, the collected real-time temperature value continues to decrease or increase,Y0 and Y1 When the power is on, the motor will rotate forward and reverse, respectively, that is, turn on the air conditioner to adjust the temperature, and the alarm light will be on for 60 s, to remind the user to take measures and check whether the equipment is abnormal. After 60 s, T5 normally open contact is closed and the alarm is closed.(2)
Residents’ living environment needs a relatively comfortable environment. Research shows that when the noise exceeds 50 decibels, people cannot rest normally. When the noise exceeds 70 decibels, the noise will disturb people’s conversation and even cause upset. Therefore, the upper limit of noise is set to 70 dB. When the detected noise is greater than 70 dB,Y4’s telegram alarm light will be on, Y2 will reset, and the step motor will stop, that is to say, window closing will be performed.(3)
When the indoor natural gas concentration exceeds 1.25%,Y4 and Y3 are powered on, and Y2 is set to 1, that is, the alarm light is on and the windows and exhaust fans are opened.(4)
When the indoor smoke (CO and CO2) concentration exceeds 0.06 percentage points, Y4 and Y3 are powered on, Y2 is set to 1, the alarm light is on, and the window exhaust fan is turned on.(5)
When the infrared detection output is 1,Y4 is powered on, Y2 is reset, the window is closed, and the alarm light is on. Some procedures in the temperature value comparison alarm procedure are shown in Figure 2.


### 4.3. Display Interface

#### 4.3.1. Real-Time Data

On this page, the main function is to select the operation mode by yourself, and display the indoor temperature and humidity, and the outdoor temperature, humidity, smoke concentration, gas concentration, noise, and other values in real time. This interface is not only to provide operation data of each parameter, and when the temperature is too high, and smoke concentration and gas concentration are too high, there may be hidden dangers of fire, natural gas explosion, and other accidents. When the value reaches the ignition point and explosion point, an alarm will be given to remind the user to avoid accidents and reduce losses. When someone is detected within the detection range of the infrared sensor, the high level is effective, and its output is 1. At this time, an alarm will be given, the alarm light will be on, and the window will be closed to prevent theft or accidents of children. These parameters are for real-time monitoring by the operator. The data display interface is shown in Figure3.Figure 3
Real-time data monitoring diagram.


#### 4.3.2. Main Page

When the man-machine interface is powered on, we first download the touch screen program. After opening the interface, we first enter the main page of the system, as shown in Figure4. At the top of the main page is the date and time display component, and the runtime can display the date, time, and week in real time. Three buttons, manual mode, automatic mode, and stop, are set in the interface to control the interface manually at any time.Figure 4
Main page.


### 4.4. System Program Import and Test

In view of the interference of the external data to the whole experimental measurement, this study adopts the PID control algorithm based on the BP neural network as the algorithm of the whole experiment, and reduces the external interference to the experimental measurement through the combination of PLC and algorithm, making the measurement data of the whole system more stable and accurate. In this study, five groups of temperature values are randomly selected from the report, and the temperature at the same time is measured and recorded. Through the comparative analysis of these two groups of data, the feasibility of the system is proved. The selected temperature is shown in Figure5.Figure 5
Temperature data table.Through the comparative analysis of the temperature measured by the system and the temperature measured by the thermometer, it is proved that the system is accurate and feasible for the indoor temperature detection program, and has the advantages of small fluctuation and convenient operation.


## 4.1. Temperature Acquisition and Compensation Procedure

### 4.1.1. Instructions for Use

The DVP series PLC uses this instruction to read CR data of special module, read the content ofK2 in K18 of special module to PLC, and read three times at a time. 2 in K2 refers to the number of foot module, K18 refers to the number of value register, D40 refers to the storage first address of temperature value, and 3 in K3 refers to reading three data at a time. The acquisition procedure is shown in Figure 1.Figure 1
Temperature acquisition procedure.Figure 2
Temperature comparison alarm procedure.On M1000, the conduction is on, and the channel is open. From the first temperature control module, PLC takes out the current temperature values stored in CR × 18 and Cr × 19 and places them inD40 and D41 (among which D40 and D41 store indoor temperature values and D42 store outdoor temperature values). After the indoor temperature values are compensated, they are displayed in the corresponding addresses D43 and D44 of the touch screen. (The outdoor temperature value is only compared with the indoor value, and the accuracy requirement is not high). We calculate the average value of the collected indoor temperature value through the mean command, store the calculated average value in the do address, and display the indoor temperature value on the touch screen.


### 4.1.2. Error Compensation Description

Due to various factors such as wire resistance, the simultaneous interpretation of the PLC’s temperature will cause some deviation. This requires temperature compensation. Considering the different errors of different sensors, different compensation values are added to each sensor. The compensation values of the two temperature sensors areD14 and D15, respectively, and the compensation values are measured after the system is debugged. Different from the actual measurement, after calculation, the user can directly input the value into the touch screenfig2.


## 4.1.1. Instructions for Use

The DVP series PLC uses this instruction to read CR data of special module, read the content ofK2 in K18 of special module to PLC, and read three times at a time. 2 in K2 refers to the number of foot module, K18 refers to the number of value register, D40 refers to the storage first address of temperature value, and 3 in K3 refers to reading three data at a time. The acquisition procedure is shown in Figure 1.Figure 1
Temperature acquisition procedure.Figure 2
Temperature comparison alarm procedure.On M1000, the conduction is on, and the channel is open. From the first temperature control module, PLC takes out the current temperature values stored in CR × 18 and Cr × 19 and places them inD40 and D41 (among which D40 and D41 store indoor temperature values and D42 store outdoor temperature values). After the indoor temperature values are compensated, they are displayed in the corresponding addresses D43 and D44 of the touch screen. (The outdoor temperature value is only compared with the indoor value, and the accuracy requirement is not high). We calculate the average value of the collected indoor temperature value through the mean command, store the calculated average value in the do address, and display the indoor temperature value on the touch screen.


## 4.1.2. Error Compensation Description

Due to various factors such as wire resistance, the simultaneous interpretation of the PLC’s temperature will cause some deviation. This requires temperature compensation. Considering the different errors of different sensors, different compensation values are added to each sensor. The compensation values of the two temperature sensors areD14 and D15, respectively, and the compensation values are measured after the system is debugged. Different from the actual measurement, after calculation, the user can directly input the value into the touch screenfig2.


## 4.2. Comparison Alarm Procedure

(1)
The user can refer to the standard value (22°C ∼ 28°C in summer and 16°C ∼ 24°C in winter) and set the upper and lower limits of the alarm by himself (the range of the upper and lower limits of the alarm parameter should be greater than the upper and lower limits of the normal parameter setting). When the collected data are lower than the normal lower limit or higher than the normal upper limit, the collected real-time temperature value continues to decrease or increase,Y0 and Y1 When the power is on, the motor will rotate forward and reverse, respectively, that is, turn on the air conditioner to adjust the temperature, and the alarm light will be on for 60 s, to remind the user to take measures and check whether the equipment is abnormal. After 60 s, T5 normally open contact is closed and the alarm is closed.(2)
Residents’ living environment needs a relatively comfortable environment. Research shows that when the noise exceeds 50 decibels, people cannot rest normally. When the noise exceeds 70 decibels, the noise will disturb people’s conversation and even cause upset. Therefore, the upper limit of noise is set to 70 dB. When the detected noise is greater than 70 dB,Y4’s telegram alarm light will be on, Y2 will reset, and the step motor will stop, that is to say, window closing will be performed.(3)
When the indoor natural gas concentration exceeds 1.25%,Y4 and Y3 are powered on, and Y2 is set to 1, that is, the alarm light is on and the windows and exhaust fans are opened.(4)
When the indoor smoke (CO and CO2) concentration exceeds 0.06 percentage points, Y4 and Y3 are powered on, Y2 is set to 1, the alarm light is on, and the window exhaust fan is turned on.(5)
When the infrared detection output is 1,Y4 is powered on, Y2 is reset, the window is closed, and the alarm light is on. Some procedures in the temperature value comparison alarm procedure are shown in Figure 2.


## 4.3. Display Interface

### 4.3.1. Real-Time Data

On this page, the main function is to select the operation mode by yourself, and display the indoor temperature and humidity, and the outdoor temperature, humidity, smoke concentration, gas concentration, noise, and other values in real time. This interface is not only to provide operation data of each parameter, and when the temperature is too high, and smoke concentration and gas concentration are too high, there may be hidden dangers of fire, natural gas explosion, and other accidents. When the value reaches the ignition point and explosion point, an alarm will be given to remind the user to avoid accidents and reduce losses. When someone is detected within the detection range of the infrared sensor, the high level is effective, and its output is 1. At this time, an alarm will be given, the alarm light will be on, and the window will be closed to prevent theft or accidents of children. These parameters are for real-time monitoring by the operator. The data display interface is shown in Figure3.Figure 3
Real-time data monitoring diagram.


### 4.3.2. Main Page

When the man-machine interface is powered on, we first download the touch screen program. After opening the interface, we first enter the main page of the system, as shown in Figure4. At the top of the main page is the date and time display component, and the runtime can display the date, time, and week in real time. Three buttons, manual mode, automatic mode, and stop, are set in the interface to control the interface manually at any time.Figure 4
Main page.


## 4.3.1. Real-Time Data

On this page, the main function is to select the operation mode by yourself, and display the indoor temperature and humidity, and the outdoor temperature, humidity, smoke concentration, gas concentration, noise, and other values in real time. This interface is not only to provide operation data of each parameter, and when the temperature is too high, and smoke concentration and gas concentration are too high, there may be hidden dangers of fire, natural gas explosion, and other accidents. When the value reaches the ignition point and explosion point, an alarm will be given to remind the user to avoid accidents and reduce losses. When someone is detected within the detection range of the infrared sensor, the high level is effective, and its output is 1. At this time, an alarm will be given, the alarm light will be on, and the window will be closed to prevent theft or accidents of children. These parameters are for real-time monitoring by the operator. The data display interface is shown in Figure3.Figure 3
Real-time data monitoring diagram.


## 4.3.2. Main Page

When the man-machine interface is powered on, we first download the touch screen program. After opening the interface, we first enter the main page of the system, as shown in Figure4. At the top of the main page is the date and time display component, and the runtime can display the date, time, and week in real time. Three buttons, manual mode, automatic mode, and stop, are set in the interface to control the interface manually at any time.Figure 4
Main page.


## 4.4. System Program Import and Test

In view of the interference of the external data to the whole experimental measurement, this study adopts the PID control algorithm based on the BP neural network as the algorithm of the whole experiment, and reduces the external interference to the experimental measurement through the combination of PLC and algorithm, making the measurement data of the whole system more stable and accurate. In this study, five groups of temperature values are randomly selected from the report, and the temperature at the same time is measured and recorded. Through the comparative analysis of these two groups of data, the feasibility of the system is proved. The selected temperature is shown in Figure5.Figure 5
Temperature data table.Through the comparative analysis of the temperature measured by the system and the temperature measured by the thermometer, it is proved that the system is accurate and feasible for the indoor temperature detection program, and has the advantages of small fluctuation and convenient operation.


## 5. Conclusions

The smart home is a new industry, which has been born gradually under the influence of the internet of things. It can not only improve the living efficiency of the contemporary people, but also improve the safety, stability, and convenience of the living environment, and improve the comfort of the residential environment. Based on the ZigBee wireless communication technology, PLC technology, and modern sensor technology, this study studies and designs a feasible smart home system.The Android mobile terminal and human-computer interface are designed in this system, which can be operated directly by users, and can monitor data in real time, reflecting the convenience of the design; PLC is selected as the main controller, which can improve the stability of the system; and the ZigBee wireless communication technology is used to collect and send data, which improves the efficiency of the system and saves the design cost. According to the system requirements, the overall architecture of the whole home system is analyzed, and the selection of the required components and the design of the wiring circuit are determined. According to the requirements of the actual smart home, we collect indoor parameters, including temperature, humidity, smoke concentration, natural gas concentration, infrared detection, noise detection, and raindrop humidity detection.In the human-machine interface, the user can set the upper and lower limit values of the parameters and the alarm parameter values according to the comfortable parameter values. There are manual and automatic operation modes for users to choose. Through the analysis and processing of the PLC program, the operation of each peripheral equipment switch state is carried out to adjust the comfort of the indoor environment. Android mobile terminal is mainly for users to directly control the status of output devices on mobile phones. The man-machine interface mainly completes the real-time monitoring of data information, parameter setting, overlimit alarm, historical trend curve, and fault alarm, and can switch the required monitoring interface at any time.



---

*Source: 6830120-2022-08-18.xml*