# Indoor Smart Design Algorithm Based on Smart Home Sensor

Authors: Ruili Zheng
Journal: Journal of Sensors
 (2022)

---

## Abstract

Modern home furnishings have solved the most basic housing problems, but how to make homes more informatized and modern has become the focus of people’s growing concern. With the rapid development of information technology, improving the intelligent level of family life and modern lifestyle is bound to be the trend of future development. This paper studies a smart home control system based on wireless sensor network positioning, which can perceive the home environment through the sensor module, and the control module can automatically control common electrical appliances to achieve real-time data monitoring and alarm functions. Specifically, it includes a positioning module, a communication module, and a server: the positioning module is connected to the server through the communication module, and the positioning module is used to obtain user location information in real time and report user location information to the server at intervals. The server receives the user reported at intervals through the communication module. Location information and remotely control smart home devices based on user location information. The research results show that the method proposed in this paper can separately monitor each part of the home and send it to the home appliance control module through the server to control the home appliance, optimize the living environment, and realize the remote control and monitoring of the smart home.


---

## Body

## 1. Introduction

In related technologies, the startup or shutdown of smart home devices requires the user to actively operate on the mobile phone. No matter this operation is to open and close the smart home device in real time or at a fixed time, the mobile phone will send a command to the server through the network after it is triggered. And then, the smart home device can be turned on or off remotely by the server through the network. This control method that completely relies on the user’s active operation to remotely control smart home devices is too rigid and inflexible. Once the user forgets to operate and triggers the mobile phone, it will bring a lot of inconveniences, the experience of smart home devices [1–8].The design of smart home (as shown in Figure1) should be implemented in accordance with the following principles: first, convenience and practicality. The purpose of designing smart homes is to provide people with a more comfortable and safe working and living environment. The key to analyzing smart home products is to take practical applications as the core, abandon the design that only has display functions, and integrate humanity at the same time. The second is the principle of reliability. The intelligent building includes various intelligent subsystems in the architecture. To realize 7×24 uninterrupted operation of these subsystems, attention must be paid to their safety, reliability, and fault tolerance. For each subsystem, use power system backup and other means to ensure the normal operation of the system in order to cope with a variety of complex environmental changes. The third is standardization. The design of traditional smart home solutions should be implemented in accordance with national and regional standards to ensure the scalability and redundancy of system applications. The fourth is convenience. The simplicity of the wiring installation will affect the installation cost. The design of a more convenient installation system can better reduce the installation and maintenance costs. You can choose to arrange it during the broadband wiring process. Smart homes can control various devices with the help of Internet of Things technology. As a brand-new industry, it is still in the groping and development stage and has not yet formed a market consumption concept. However, with the gradual popularization of the smart home market, it will be more difficult to recultivation of consumer habits. The safety precaution system in the smart home is to be fully prepared to prevent dangerous situations and keep family members in a safe state where there is no infringement and no accidents [9–14].Figure 1
Smart home.As early as January 1984, technology companies applied integrated and informatized equipment buildings to an old 38-story financial building in the United States at the time and systematically systemized the elevators, lighting, and air conditioning equipment in the building, detection and control, and use voice communication in information provision. This is the first “intelligent building” recognized in the world. In the early 1980s, with the introduction of a large number of household appliances using emerging electronic technologies, the concept of home electronics (HE) began to appear. Bill Gates’ Microsoft has spent a huge amount of money to build a technologically advanced mansion. The electrical equipment in the house is connected through the network, and there is a dedicated server in the control background, and the home system is controlled and managed by the computer. In May 1998, Singapore launched an intelligent home system. Nearly 30 residential communities have adopted the system. Residents have also installed the system in the United States. The system mainly includes security alarms, monitoring functions, electrical control functions, and message functions. In 2016, Google released a smart home device called GoogleHome [15–23]. To this end, many modern technologies have been concentrated, such as, sensor technology, computer technology, and electronic communication technology.In August 2014, Samsung acquired SmartThings, an open platform for smart homes, and focused on promoting its plans for the “Internet of Things.” SmartThings technology allows users of hardware devices such as Samsung smart phones and smart watches to easily control smart home devices by manipulating these daily devices. Therefore, SmartThings has been regarded as the top priority of Samsung’s smart home and “Internet of Things” plans. Samsung is also constantly expanding the company’s other equipment to adapt, so that more mobile terminals can be connected to this platform and actively cooperate with third-party manufacturers to make this platform cover household energy, safety management, medical care, health, and other fields. In terms of function, the smart home forms the only management center, and the control center can be mobile phones of various brands or smart bracelets [24–27].Apple held the Worldwide Developers Conference (WWDC) in 2014, where Homekit was grandly released. Apple said that the platform is a joint Siri function and allows users to control their homes through devices such as Apple phones and tablets. Apple is preparing to carry out Apple (MFi) certification for third-party products to improve the portability and versatility of the products. On June 3, 2015, Apple’s first public release of Homekit smart home products came from 5 manufacturers. These products can control lights, temperature, air conditioning, TVs, and other household appliances through iPhone, iPad, or iPodTouch. As a very practical smart home platform, Homekit smart home platform is loved by many consumers and brings users a very good smart home control experience. On June 13, 2016, the Apple Developer Conference was held in San Francisco. The meeting announced that builders began to support Homekit. The Homekit platform will allow users to control all mobile terminals through OS devices and can convert iphones or iPads into command systems for thermostats, lights, garage doors or door locks, and many other smart home devices.In 2009, Haier cooperated with China Telecom to launch U.S. home, the future development direction of home furnishing is considered to be the convenient, innovative, comfortable, and high-quality living environment and lifestyle advocated by Haier Group. It is not only a global R&D base for manufacturing intelligent products but also the world’s leading smart home appliances and household products are also developed and manufactured by them, and it is also a supplier and developer that provides a full set of intelligent solutions and products. Let the world and home become the life concept of human beings simultaneously, and allow people to experience and enjoy the high-quality life around the world and give users more opportunities to use personalized Haier products. Haier Group has won many patents and its own proprietary science and technology thanks to Haier Group’s own U.S. company, home development team, and the world’s top laboratories, among which U. The home development team is composed of a number of highly qualified and capable Ph.Ds and professional intelligent developers and has proposed solutions for smart homes and smart supermarkets. Haier’s high-quality and innovative smart lifestyle is the trend of the future family. Haier Group has a legal SP service qualification and a full line of smart appliances and positions the SMS service as a basic platform, providing a series of guarantees for SMS notification and remote control measure [28, 29].Due to the vigorous development of the home furnishing market, many companies in the industry have emerged. The products they produce provide some functional devices that are scattered and cannot be concentrated for users to experience. This violates the smart home’s outstanding features of intelligence and convenience. The main work that Huawei has done is to develop from the general direction and integrate the interconnection issues of various devices in the home. Focus on research to solve the problem of how to connect and communicate between mobile and cloud devices. Hilink was created to enable the terminal nodes of various home furnishing platforms to communicate and connect with each other to create a good experience to serve consumers and feel the real home experience. Node devices with Hilink can be connected together in its area, without us having to retype the password again; completely eliminating this link can not only save the user’s precious time but also enjoy the convenience brought by the device and a quick experience. Terminals that support the Hilink open protocol allow us to use APP or cloud technology to remotely control device nodes that support the protocol. It can connect quickly, shorten the process, have high security, support multiple protocols, and support SDK opening.In addition, the home functions designed by Xiaomi are mainly operated and used by mobile phones, and as far as the equipment is concerned, they are also developed and designed by themselves. In order to make users feel better, Xiaomi has launched a router of its own brand that is the entire data and control core. And Xiaomi’s products are not priced high, the main consumer group is young people, because young people are more receptive to new things plus they have a relatively good appearance and low prices. Since 2015, its products have ranked first in terms of router sales and mobile phone software downloads. In addition to most of the common functions, the home furnishings designed by it not only have rich functions but also have the design of air purification and personalized scenes.


## 2. System Algorithm

A smart home control system based on wireless sensor network positioning proposed in this paper is shown in Figure2. It includes a positioning module 1 and a communication module and a server; the positioning module is connected to the server through the communication module. The positioning module is used to obtain user position information in real time and report the user position information to the server at intervals. The user location information reported at intervals is received through the communication module, and the smart home equipment is remotely controlled according to the user location information.Figure 2
Smart home control system.The remote control of the smart home device according to the user’s location information shown in the figure includes the following: the server compares the received user location and the location of the smart home device each time with the map and judges that the user is close to the smart home device’s home trend or stays away from the smart home device trend and calculates the road distance between the two, when the user is away from the home trend and the road distance is greater than the user set threshold, it will issue an instruction to turn off the smart home device. When the road distance is less than the threshold set by the user, an instruction to start the smart home device is issued. The server shown in the figure includes a user location information receiving module connected in sequence, a distance calculation processing module, and an instruction sending module. The positioning module outputs and connects to the user location information receiving module.The solution proposed in this paper can make intelligent judgment and analysis by collecting user location information. Server remotely activates or closes group smart home equipment, which is flexible and reliable in use and significantly enhances the user’s experience. The positioning module includes a target node worn on a user and a beacon node for assisting in the setting. The beacon node is a target node with known position coordinates, and the target node is based on an improved artificial bee colony algorithm positioning, specifically:(1)
Initialize the population size; generateM initial nectar sources (i.e., M initial coordinates) of the target node and the maximum number of cycles(2)
Picking bees to search for new nectar sources. For the bee picking in stepL, set the total number of bees to N, the size of the bee group to M, and the spatial dimension of the bees to search for new nectar sources as D, and search in the neighborhood of the current nectar source. The new nectar source includes:(a)
The space of the current nectar source’s dimension is divided into intervals according to the following formula:(1)Yi,jh=Xij+2h−HHXij−Xkj,h∈0,H,where Y represents the hth interval point obtained by the division. x represents the ith current honey source generated in the jth dimension space, and x represents the kth current honey source generated in the jth dimension space, i=1,2,⋯, j=1,2,D, k=1,2,⋯M, and k≠i(b)
For each intervalY, divide the interval into Z subintervals according to the following formula:(2)Yi,jh,z=Yi,jh+sinz−rand0,12ZπYi,jh−Yi,jh+1,z∈1,Z.In the formula,Y represents the zth subinterval point obtained by dividing the interval Y wrongly, rand01 represents a uniformly distributed random value between 0 and 1, and Y+1 represents the h+1th interval point obtained by the division
(c)
Calculate the fitness function value of each subinterval point, select the subinterval point with the largest fitness value as the representative nectar source of the corresponding interval(d)
Calculate the difference between the fitness value of each representative nectar source andX:(3)Wij=minfUi,jh−fXij,fUi,jh−fXij>0,h∈1,H.In the formula,Wi represents the smallest difference between the fitness value of each representative nectar source and X, fU represents the fitness value of the representative nectar source in the interval Y, fx) represents the fitness value of X(e)
SelectWi correspondingly represents the source of nectar, as the new source of nectar found(3)
Calculate the fitness value of the new nectar source and the current nectar source, compare the fitness value of the new nectar source and the current nectar source, and eliminate the nectar source with a smaller fitness value(4)
Follow the bees to select the pickers according to the selection probability, update their own nectar sources according to the nectar sources corresponding to the selected pickers, and search for new nectar sources in the neighborhood near the current nectar source(5)
Repeat the operations of (2) and (3), record the nectar source with the largest fitness value, and add 1 to the current number of cycles(6)
After reaching the maximum number of cycles, take the nectar source coordinates with the maximum fitness as the optimal coordinates of the target nodeWhen the traditional artificial bee colony algorithm searches for a new nectar source in the neighborhood of the current nectar source, the search has a large randomness, and the update is unstable. The space is divided into multiple intervals for searching, which improves the efficiency of search and the stability of nectar update, which can achieve more efficient target node positioning and ensure the real-time and accuracy of user positioning in the smart home control system. TheM initial nectar sources that generate the target node specifically include:
(1)
Use the following formula to randomly generate an initial nectar source:(4)Xij0=Xminj0+rand0,1Xmaxj0−Xminj0.In the formula,xi represents the ith initial honey source generated in the jth dimension space, and xmin represents the minimum value of the ith initial honey source generated in the jth longitude space. xmax represents the ith initial honey source generated in the jth dimension space. The maximum value in the original, rand0,1, represents a uniformly distributed random value between 0 and 1
(2)
Calculate the corresponding reverse honey source for each initial honey source:(5)Xij0′=rand0,1Xmaxj0+Xminj0−Xij0.In the formula,xi represents the reverse honey source of the ith initial honey source generated in the jth dimension space;
(3)
Calculate the fitness values of all initial nectar sources and reverse nectar sources, and sort all the initial nectar sources and reverse nectar sources generated in descending order of fitness value to form a nectar source set and the fitness in the nectar source set. The firstM nectar sources with better values are screened out and used as the M initial nectar sources of the target nodeCompared with the traditional artificial bee colony algorithm that directly randomly generates the initial nectar source at the beginning stage, the method of generating the initial nectar source described in this article can improve the quality of the initial nectar source and the efficiency of solving, so that the initial nectar source is distributed as evenly as possible, thereby improving the overall. The stability and speed of target node positioning ensure that the target node can obtain its own location attribute information quickly and well, laying a good foundation for the smart home control system to remotely control smart home equipment in real time and accurately. Suppose the position coordinates of the nectar sourceX are (a,b) to define the calculation formula of the fitness value as:
(6)fX=mina−xi2+b−yi2−D¯λxi,i=1,⋯,Φ,where fX represents the fitness value of nectar Xxii represents the position of the ith beacon node, D represents the average hop distance sent by the first beacon node received by nectar X, and xi represents the number of hops between the honey source X and the ith beacon node; Ф is the set number of beacon nodes.This article defines the calculation formula of the fitness value and participates in the target node positioning based on the improved artificial bee colony algorithm according to the above formula, which can better improve the positioning accuracy of the target node, reduce the positioning error, and balance the communication task of the sensor node. The speed of locating the target node is improved, which is beneficial to realize the effective remote control and monitoring of the accurate angle of the smart home.Assuming that the coordinates of the three base stations Al, A2, and A3 in Figure3 are (xl,y1), (x2,y2), and (x3,y3), and the mobile node Mx,y is the three circles of intersection. The distances from the mobile node M to the base stations A1, A2, and A3 are d1, d2, and d3, respectively. Then, the following formula can be obtained:
(7)x−x12+y−y12=d12,x−x22+y−y22=d22,x−x32+y−y32=d32.Figure 3
Triangulation method.Subtracting the first two formulas from the third formula in the above formula, we get:(8)2x1−x3x+2y1−y3y=x12−x32+y12−y32+d32−d12,2x2−x3x+2y2−y3y=x22−x32+y22−y32+d32−d22.From this, the position coordinates of the mobile nodeM can be obtained as shown in the following formula:
(9)xy=12x1−x3y1−y3x2−x3y2−y3−1x12−x32+y12−y32+d32−d12x22−x32+y22−y32+d32−d12.The hyperbolic positioning method is shown in the following formula, assuming that we can use a certain measurement method to calculate the distance between the moving nodeM and the base stations S1 and S2, where dl,2=d1.d2. The mathematical equation of the hyperbola is shown in the following formula:
(10)MF1−MF2=2a.M is a point on the curve, 2a is the distance between the two focal points F1 and F2 on the two curves, and we can conclude from the above formula that the position of node M is at the focal point where S1 and S2 are located, sum on the hyperbola with two focal differences of dl,2. Suppose that the coordinates of S1, S2, and S3 are (0, 0), (0, y2), and (X3,y3), and the coordinates of the mobile node M are X,y. inferred:
(11)d1,2=d2−d1=x2+y−y22−x2+y2,d1,3=d3−d1=x−x32+y−y32−x2+y2,d2,3=d3−d2=x−x32+y−y32−x2+y−y22.After simplifying the above formula, we can get:(12)4d1,22b2+1−4y22y2+8abd1,22+4y22−d1,22y2y+4a2d1,22−y22−d1,22=0.From the above, two answers can be drawn, one is the interference position and the other is the position ofM. If you want to accurately estimate the position of the M node, you can use some auxiliary conditions such as the azimuth angle of incidence to eliminate the interference node. The method obtains the approximate location of the mobile node M. The positioning algorithm experiment result graph is shown in Figure 4. Correspondingly, the data vs. distance is shown in Figure 5.Figure 4
Positioning algorithm experiment result graph.Figure 5
Data vs. distance.


## 3. Smart Home System Design Based on Sensor Technology

For people, the home environment is not just a living space. From its warmth and beauty to the present, people care about its comfort, controllability, convenience, safety, and the ability to intelligently control home appliances and other equipment. With the advancing of the times, it is an inevitable trend to realize the networking and intelligence of the home. Based on the use characteristics of home intelligence, the design of the smart home software system needs to meet the goals of convenience and easy operation. In addition, the existing smart homes are expensive, with high installation costs, and difficult to maintain in the later stage, so that smart homes cannot be popularized in ordinary households on a large scale. Through analysis, it can be seen that the key points that the existing smart home system needs to be improved include the security and timeliness of network formation and the unity of the agreement. According to the current development of smart homes, the specific requirements will be described from economics and functionality, mainly as follows: (1) economics: considering that smart homes can be universally distributed to households of all classes, first, consider product design low. The system should not be too complicated, as long as it meets the main needs of life. (2) Functionality: the design of the home system can best be manipulated through the mobile phone, which is convenient for users to check at any time. Also, pay attention to environmental protection; hardware can run with low energy consumption. Strengthen safety monitoring to detect the danger of gas leakage and home invasion in time. Real-time response speed must be fast, power supply must be long-lasting, etc. Through the analysis of the user’s economic and functional requirements, the smart home system designed in this paper is mainly composed of three major blocks. They are the ZigBee network, server, and mobile terminal remote control APP in the home. There are mainly terminal devices (temperature and humidity sensors, light sensors, gas sensors, human infrared sensors, switch control modules) and gateways inside the home. The gateway device is composed of CC2530 module and ARM processor (detailed introduction will be given later). The ZigBee wireless technology is used for the communication between the terminal device and the gateway. Add the IP address in the gateway to the router, and join the Internet in this way. The gateway and the server use socket technology for communication, and the mobile APP and the server also use socket technology for mutual data access. Finally, the user can use the mobile phone client to control the terminal device. At the same time, the user can also use the voice keyword dialogue to switch and control the household appliances in the family to enhance the user’s sense of experience. The convergence is shown in Figure6.Figure 6
Convergence.The whole system uses STM32RCT6 single-chip microcomputer as the control core, integrates a variety of sensors, and uses WiFi technology to upload sensor data to the cloud in real time to complete the data interaction between the system and the cloud. Users can login to the cloud through WeChat, mobile APP, and computer web pages to remotely monitor the peripheral sensor data of the system in real time. When the system detects an abnormal home environment, it will send an alarm email via the cloud to the mailbox designated by the user and at the same time automatically control the corresponding electrical appliances to reduce its harm. In addition, the system has a home appliance control module, which is composed of a relay and an infrared remote control circuit. Relays are used to control low-power appliances in the home, and infrared remote controls are used to control high-power air conditioners. The system perceives the home environment through the sensor module, the control module can automatically control common electrical appliances, and the communication module can realize real-time data monitoring and alarm functions.The hardware design part of this system mainly includes sensor module, WiFi module, control module, and power circuit design.Sensors play a vital role in the system. All the perception of the external environment is detected by sensors, and a variety of sensors with different functions are applied according to design requirements.


### 3.1. Smoke and Gas Sensors

The MQ sensor series includes smoke, liquefied gas, natural gas, coal gas, carbon monoxide, alcohol and air quality detection, and other rich smoke and gas sensors, and all support digital and analog output methods. When the digital output mode is selected, the threshold of the sensor can be adjusted by an external hardware potentiometer. The hardware interfaces of different types of sensors in the MQ series are completely the same. In the system design process, the MQ-2 smoke sensor is selected. In order to be compatible with a variety of smoke and gas sensors, the module reserves multiple digital output sensor interfaces, which can detect multiple air quality safety parameters at the same time, and there is no need to modify the software during use.When there is a detected gas in the air, the conductivity of the MQ-2 smoke sensor will increase, and the weak signal output by the sensor will be amplified, filtered, and level adjusted through the front circuit in the conversion circuit to change the conductivity. The change corresponds to the output signal of gas concentration. If you need to accurately monitor the detected gas, you can choose the analog signal output. Its analog voltage output is proportional to the concentration of the ambient gas to be detected, which can be measured by using the system main control chip STM32RCT6 with its own ADC peripheral. The sensor has high sensitivity and good stability and can detect fire smoke and combustible gas leakage in the home. The data is compared in Figure7.Figure 7
Data comparison.


### 3.2. Photosensitive Sensor

The photosensitive sensor is a sensitive element that uses a photosensitive element to convert a light signal into an electrical signal. It is mainly composed of a photosensitive resistor and an LM393 voltage comparator. The working principle is based on the internal photoelectric effect. The sensor voltage comparison threshold is adjusted by the potentiometer hardware. When the ambient light changes, the voltage at both ends of the photoresistor changes accordingly. The voltage comparator can be compared with the threshold voltage to make the system know the current brightness of the environment.


### 3.3. Other Sensor Temperature and Humidity Sensor

In addition to the above-mentioned sensors, the sensor module also includes a temperature and humidity sensor and a human body infrared pyrosensor. This system uses DHT11 temperature and humidity sensor to sense the temperature and humidity parameters of the home environment. It is a temperature and humidity composite sensor with a calibrated digital signal output. The accuracy humidity is ±5%RH, the temperature is ±2°C, and the range humidity is 20% to 90%. RH: temperature is 0~50°C. Using single-bus communication, only one wire can be used to communicate with the main control chip, which has the characteristics of convenient use, small size, and low power consumption. The pyroelectric sensor uses the temperature change feature to detect the infrared radiation of the human body. The human body has a constant body temperature, generally at 37°C, which emits infrared rays with a wavelength of about 10μm. Passive infrared probes work by detecting infrared rays of about 10 μm emitted by the human body. The infrared light of about 10 μm emitted by the human body is enhanced by the Feiner filter in the sensor and then collected on the infrared sensor source. The infrared sensor source loses the charge balance when the temperature of the infrared radiation of the human body changes and discharges the charge outward. The subsequent circuit will detect the presence of the human body after the detection process. The power comparison is shown in Figure 8.Figure 8
Power comparison.As an IoT device, the quality of system communication affects the stability of the entire system. The communication module of this system adopts the industrial grade WiFi module ESP8266. The main control chip communicates with the WiFi module through the serial port, and the WiFi module is connected to the Internet through the TCP/IP protocol, thereby connecting the system to the Internet in real time, achieving the purpose of remote control of smart homes and environmental data monitoring.For the control part, this system not only uses a common relay module to control low-power electrical appliances but also adds an infrared remote control circuit to control high-power air conditioners. Relay is a commonly used device for weak current control and strong current. It is used in the system to control the main automation equipment, but has limited capacity for high-power air-conditioning. Therefore, an infrared remote control module is added to the system to simulate infrared codes through the main control chip, which can be flexibly used for switching and temperature control of high-power air conditioners, and has the advantages of low power consumption and stable performance.This system needs to use 3.3 V and 5 V dual power supply. The power module is powered by 5 V DC, which can be directly supplied to the 5 V module circuit, and then through the 3.3 V voltage regulator module to generate 3.3 V voltage for use by other modules. The Fourier analysis is shown in Figure9.Figure 9
Fourier analysis.


## 3.1. Smoke and Gas Sensors

The MQ sensor series includes smoke, liquefied gas, natural gas, coal gas, carbon monoxide, alcohol and air quality detection, and other rich smoke and gas sensors, and all support digital and analog output methods. When the digital output mode is selected, the threshold of the sensor can be adjusted by an external hardware potentiometer. The hardware interfaces of different types of sensors in the MQ series are completely the same. In the system design process, the MQ-2 smoke sensor is selected. In order to be compatible with a variety of smoke and gas sensors, the module reserves multiple digital output sensor interfaces, which can detect multiple air quality safety parameters at the same time, and there is no need to modify the software during use.When there is a detected gas in the air, the conductivity of the MQ-2 smoke sensor will increase, and the weak signal output by the sensor will be amplified, filtered, and level adjusted through the front circuit in the conversion circuit to change the conductivity. The change corresponds to the output signal of gas concentration. If you need to accurately monitor the detected gas, you can choose the analog signal output. Its analog voltage output is proportional to the concentration of the ambient gas to be detected, which can be measured by using the system main control chip STM32RCT6 with its own ADC peripheral. The sensor has high sensitivity and good stability and can detect fire smoke and combustible gas leakage in the home. The data is compared in Figure7.Figure 7
Data comparison.


## 3.2. Photosensitive Sensor

The photosensitive sensor is a sensitive element that uses a photosensitive element to convert a light signal into an electrical signal. It is mainly composed of a photosensitive resistor and an LM393 voltage comparator. The working principle is based on the internal photoelectric effect. The sensor voltage comparison threshold is adjusted by the potentiometer hardware. When the ambient light changes, the voltage at both ends of the photoresistor changes accordingly. The voltage comparator can be compared with the threshold voltage to make the system know the current brightness of the environment.


## 3.3. Other Sensor Temperature and Humidity Sensor

In addition to the above-mentioned sensors, the sensor module also includes a temperature and humidity sensor and a human body infrared pyrosensor. This system uses DHT11 temperature and humidity sensor to sense the temperature and humidity parameters of the home environment. It is a temperature and humidity composite sensor with a calibrated digital signal output. The accuracy humidity is ±5%RH, the temperature is ±2°C, and the range humidity is 20% to 90%. RH: temperature is 0~50°C. Using single-bus communication, only one wire can be used to communicate with the main control chip, which has the characteristics of convenient use, small size, and low power consumption. The pyroelectric sensor uses the temperature change feature to detect the infrared radiation of the human body. The human body has a constant body temperature, generally at 37°C, which emits infrared rays with a wavelength of about 10μm. Passive infrared probes work by detecting infrared rays of about 10 μm emitted by the human body. The infrared light of about 10 μm emitted by the human body is enhanced by the Feiner filter in the sensor and then collected on the infrared sensor source. The infrared sensor source loses the charge balance when the temperature of the infrared radiation of the human body changes and discharges the charge outward. The subsequent circuit will detect the presence of the human body after the detection process. The power comparison is shown in Figure 8.Figure 8
Power comparison.As an IoT device, the quality of system communication affects the stability of the entire system. The communication module of this system adopts the industrial grade WiFi module ESP8266. The main control chip communicates with the WiFi module through the serial port, and the WiFi module is connected to the Internet through the TCP/IP protocol, thereby connecting the system to the Internet in real time, achieving the purpose of remote control of smart homes and environmental data monitoring.For the control part, this system not only uses a common relay module to control low-power electrical appliances but also adds an infrared remote control circuit to control high-power air conditioners. Relay is a commonly used device for weak current control and strong current. It is used in the system to control the main automation equipment, but has limited capacity for high-power air-conditioning. Therefore, an infrared remote control module is added to the system to simulate infrared codes through the main control chip, which can be flexibly used for switching and temperature control of high-power air conditioners, and has the advantages of low power consumption and stable performance.This system needs to use 3.3 V and 5 V dual power supply. The power module is powered by 5 V DC, which can be directly supplied to the 5 V module circuit, and then through the 3.3 V voltage regulator module to generate 3.3 V voltage for use by other modules. The Fourier analysis is shown in Figure9.Figure 9
Fourier analysis.


## 4. Conclusion

A set of smart home system is designed, which can sense the home environment through the sensor module, and the control module automatically controls the common electrical appliances to realize real-time data monitoring and alarm functions. This system combines sensor technology and smart home system design, which has important practical significance for the application of smart sensors in smart home in the future.Due to the limitation of my own ability and experimental resources, the realization of the functions of the smart home system is not perfect. The distance threshold in the node localization algorithm is only obtained by RSSI measurement and calculation in the laboratory environment. The actual home environment is more complicated. Therefore, the next step needs to consider the selection of the lower threshold that affects the complex home environment. This is also an issue that needs to be further optimized in the future.



---

*Source: 2251046-2022-04-11.xml*