Building an indoor air quality monitoring system based on the architecture of the Internet of Things

With rapidly changing technology, people have more and more requirements for thermal comforts regarding indoor temperature, humidity, and wind speed, and pay more attention to air quality. Indoor air quality has serious effects on the elderly, children, and those with respiratory allergies. Based on the architecture of the Internet of Things smart home, this study constructed an indoor air quality monitoring system to explore how people can live in an environment with good air quality. Among the numerous air quality indices (AQIs), the carbon dioxide index and AQI of the American Society of Heating, Refrigerating and Air-Conditioning Engineers are selected as the indices suitable for this study. The common points of the two indices are combined, and then, based on the data of the Environmental Protection Administration, indoor and outdoor environmental parameters are analyzed, and controllable environment variables are simulated to analyze their effects on air quality. This study designed effective load control using fuzzy control and developed a fuzzy rule base for simulation of the environment variables. Decision logic was used to replace the threshold control of indoor air quality in the past, and a comfortable air quality monitoring system was designed by combining the Arduino Uno development board and ESP8266 Wi-Fi wireless transmission modules.


1.
Smog's effects on the human body: It is widely known that smog has the greatest effects on the respiratory system because the large area of the respiratory system is most frequently in contact with the environment. While hundreds of atmospheric particles enter the respiratory tract each day, and adhere to lung lobes, most of them will be absorbed by the human body. Harvard University has verified that the patient mortality rate increases by 10-27% for every 10ug/m3 pollutant increase in PM2.5. 2. Smog's effects on traffic: When there is smog, due to poor air quality and low visibility, accidents are more likely to occur to railway, highway, sea transportation, and aviation traffic, which affects traffic order, disrupts people's schedules, and causes inconvenience. 3. Smog's effects on the economy: Smog not only affects respiratory tracts and intelligence, it also reduces of the efficiency of solar power generation, which is reduced due to rain, fog, and smog. Therefore, some scholars have pointed out that solar panel power generation would decline year by year as air pollution becomes the norm.
In Taiwan, the Environmental Protection Administration uses a monitoring network for air quality for the people to view; however, these data only show a large-scale area and there is no way to know the actual situations in homes. The quality of indoor air is the closest to people's living environment. This study focuses on air quality. The Air Quality Index (AQI), which is a nonlinear index that quantitatively describes air quality, is mainly used to explain that severer air pollution is more harmful for human health, including the respiratory tract, and leads to greater index values, higher categories, and darker display colors. However, there are no hourly concentration standards regarding particles with the severest air pollution, and air quality is only measured in 24-h average concentrations. As changes in air quality can be somewhat delayed, for the people to know their true feelings, the Environmental Protection Administration announced the concentration data of a "real-time air quality index", which mainly measures primary pollutants, fine particulate matters, and particle matters. It makes more practical sense that the real-time concentration data shall be monitored when air quality is being observed. Based on the system architecture of a smart home and the IoT, the purpose of this study is mainly to explore how users construct an index system in the home environment. AQI is now the most commonly used index in the world, and mainly explores 6 gases: ozone (O 3 ), fine particulate matters, particle matters, carbon monoxide (CO), sulfur dioxide (SO 2 ), and nitrogen dioxide (NO 2 ). This study further explored the fine particulate matters, CO, and carbon dioxide (CO 2 ) commonly found in homes. The indoor environment was analyzed by MATLAB simulation, fuzzy control was applied to the data of fine particulate matters and CO 2 in the indoor environment, and a logic base was established based on the AQI data for better air quality in homes.
This study conducted on-site measurements of indoor environment data with two sets of equipment equipped with sensor modules for fine particulate matters, CO, and CO 2 . After receiving the data, the 3 modules collected the data of the Arduino Uno board for integration, and then, transmitted them to the computer terminals through the ESP8266 Wi-Fi module for subsequent calculation and analysis. This study adopted Visual Studio C# software as the human-machine and monitoring interface, where AQI estimation applied fuzzy control to decide the time to open the air purifier, window, and ventilation unit, in order to reduce the fine particulate matter and CO 2 concentrations. The system threshold of CO concentration was designed based on AQI, and the users were reminded by automated warnings and buzzers [1].

IoT
The Internet of Things (IoT) was originally mentioned in a speech by Peter T. Lewis in 1985, and in 1999, the Massachusetts Institute of Technology (MIT) combined Radio Frequency Identification (RFID) with the network to realize intelligent planning and management. After that, the International Telecommunication Union (ITU) introduced the concept of the IoT at the World Summit on the Information Society (WSIS), which brought the term IoT into people's lives [2]. IoT refers to combining the information received by sensors from electronic tags or RFID devices, which cannot be connected to the Internet, to collect various data, such as temperature, brightness, and air quality sensors, in order that sensors can record the environmental changes and users can search the information they need through wireless networks, such as Wi-Fi, ZigBee, BlueTooth and LoRa, or wired networks. There are many mainstream IoT technologies, and the communications they use are also different, including NB-IOT, LoRa, and SIGFOX. Various IoT devices have different network nodes, such as IPv4 and IPv6.
Based on the above concept, the 3-layer IoT architecture, as established according to the European Telecommunications Standards Institute (ETSI), is comprised of an Fig. 1 IoT architecture. Based on the above concept, the 3-layer IoT architecture, as established according to the European Telecommunications Standards Institute (ETSI), is comprised of an application layer, internet layer, and a sensing layer according to different work projects application layer, internet layer, and a sensing layer according to different work projects. The architecture is shown in Fig. 1: 1. Sensing layer: the sensing layer is mainly divided into sensing and identification technologies, which carries out different monitoring and sensing of different environments. Sensing technology: temperature, humidity, brightness, infrared, and other sensors are used. Identification technology: the sensor data are transmitted to the internet layer through transport protocols, such as LoRa, ZigBee, RFID tags, and RS232. 2. Internet Layer: the internet layer is between the sensing layer and the application layer, and is mainly a communication bridge. The technologies of the internet layer include a low power and low transmission wireless network, ultra-high-speed shortrange wireless transmission, a long-distance Wi-Fi wireless network, and the latest 5G LTE mobile communication protocol. 3. Application layer: on the application layer, the data measured by the sensing layer are transmitted to the application system of the top layer through the network on the internet layer, and then, the responses to specific events are conducted according to the result analysis to build models, which are similar to human brains and central Fig. 2 Effects of CO 2 concentration on the human body. The indoor CO 2 concentration ranging from 350 to 450 ppm is good, and at a concentration higher than 1000 ppm, people begin to experience symptoms, such as drowsiness, and such higher concentration leads to severe symptoms. Hence, ASHRAE suggests that the indoor CO 2 concentration should not be higher than 1000 ppm nerves, such as logistics management, access control systems, environmental monitoring, smart home appliances, medical care, transportation, and decision support.
As the main technologies of the application layer are cloud computing, massive data analysis, and big data analysis, these technologies will be widely used in the future.

CO 2
CO 2 , which is easily accumulated in poorly ventilated places, is a high-density greenhouse gas with contents approximately ranging 300-400 ppm in the atmosphere. People produce CO 2 with every breath they take, and while CO 2 is non-toxic, it may cause hypoxia if its concentration is higher than the general level in the air, which is bad for  4 Effects of fine particulate matters entering the human body. After entering the blood, they cause inflammation in organs, such as hearts, blood vessels, brains, and reproductive systems the human body. If one spends a lot of time in an overly crowded environment or a place with poor ventilation, the CO 2 concentration will exceed the standard and cause discomfort. CO 2 is used as a hygienic index by the State to measure indoor air pollution; the CO 2 concentration shall not exceed 0.07-0.1% in the case of a long stay in a crowded area, and shall not exceed 0.15% in the case of a short stay. The Ministry of Labour has also stipulated the immediate danger to life or health concentration (IDLH) for acute respiratory hazards. At a CO 2 concentration of 4%, people are in danger; at a CO 2 concentration of 7.5%, people begin to experience palpitations, dizziness, and headaches; at a CO 2 concentration above 10%, people lose hearing, start to vomit, and feel nauseous; at a CO 2 concentration above 30%, people lose consciousness and go into convulsions. The indoor CO 2 concentration ranging from 350 to 450 ppm is good, and at a concentration higher than 1000 ppm, people begin to experience symptoms, such as drowsiness, and such higher concentration leads to severe symptoms. Hence, ASHRAE suggests that the indoor CO 2 concentration should not be higher than 1000 ppm. The detailed effects of CO 2 concentration on human health are shown in Fig. 2 [3].

CO
As a compound, CO is a colorless, tasteless, non-irritating, and odorless gas, and the most common toxic gas in daily life. While the activities of general organisms produce CO, it mainly comes from fire, engine exhaust, and incomplete gas combustion [4]. In  the blood, as its heme-binding capacity is 200 times more than that of oxygen (O2), it is difficult for the heme to carry O2 after binding, and after inhaling CO, people will experience various symptoms, such as headaches, vomiting, dizziness, and chest pains. Hence, the United States Environmental Protection Agency (USEPA) stipulated that the maximum CO concentration in the air shall not be more than 10 mg/m 3 , and the National Fire Protection Association (NFPA) also defined the toxic symptoms for people inhaling different levels of CO, as shown in Table 1 [5].

Fine particulate matters
The air quality has slowly deteriorated since the Industrial Revolution, and is now further affected by climate change and denser urban vehicle use. In recent years, while Taiwan's smoking population has decreased year by year, the rate of cancers, such as lung cancer, have increased year by year, and poor air quality may be an important factor in this phenomenon, with particle matters having the most serious effects on the human body. Particle matters are referred to as "smog", and can be divided into 4 categories according to the size, including total suspended particulates (TSP), 10 μm particle matters (PM10), coarse particulate matters (PM2.5-10), and fine particulate matters (PM2.5), with the details shown in Table 2. Fine particulate matters are mainly discussed in this study. There are 3 main sources of fine particulate matters (PM2.5): natural, primary, and derived. A natural source generally refers to forest fires or volcanic eruptions; primary fine particulate matters are generally produced by incomplete combustion in factories, including many toxic substances, such as organic carbon, dioxin, and heavy metals; derived fine particulate matters refer to oxycarbide and oxysulfide emitted by factories and in petrochemical industries, and oxycarbide and oxysulfide often produce secondary toxic pollutants due to sunlight, such as nitrate and sulfate. Fine particulate matters mainly invade human's blood circulation through alveoli, indicating their tiny sizes, as shown in Fig. 3 [6]. After entering the blood, they cause inflammation in organs, such as hearts, blood vessels, brains, and reproductive systems, as shown in Fig. 4 [6], which mainly occurs because fine particulate matters are toxic substances containing heavy metals.  In 2005, the World Health Organization (WHO) developed measures to restrict fine particulate matters. In Taiwan, fine particulate matters were included in AQI in May 2012, and specific indices were developed for fine particulate matters, with details as shown in Table 3 and Eq. 2-1 [7].

Wireless transmission
People choose the most suitable methods to transmit data depending on the circumstances, and such transmission modes are divided into wired and wireless transmissions, which have their own advantages and disadvantages, as shown in Table 4. Smart homes show their effects through IoT applications. In smart homes, the transmission distance is basically within the residence, and the data to be transmitted will   not be a large amount; hence, without emphasizing transmission rate, wireless transmission was selected in this study. The transmission rate involves several factors, such as indoor environment, sheltered areas, and different floors, meaning the transmission rate at all locations is basically the same on the same floor, provided it is not too heavily sheltered, and while the transmission rate on different floors is more or less affected, the main difference of the transmission rate on different floors is stability. The greater the distance between the floors, the more unstable the transmission rate. The wired network line shall be arranged first when designing smart homes; otherwise, it will be troublesome to modify or build a new wired network. Therefore, if the system is set up on different floors and without a line arrangement, it is suggested that wired transmission is more stable than wireless transmission. However, the disadvantages of wired transmission are that the network cannot be modified or rearranged as easily as those with wireless transmission, thus, wireless networks are gradually replacing wired networks in smart homes. The network architecture of wireless transmission consists of 4 layers: application layer, transport layer, internet layer, and link layer, and is often referred to as the TCP/ IP or DoD (Department of Defense) model. With their own responsibilities, all layers are closely related and work together, and the detailed transmission flow chart is shown in Fig. 5.
The major network types are shown in Table 6, and the local area network architecture is mainly used in this study. Different network architectures, such as the Wireless Personal Area Network and Wireless Local Area Network (WLAN), are developed according to the 3 network types in Table 5.
WLAN was developed according to IEEE 802.11, as published in 1997 [7]; however, with the rapid advances in technology, many WLAN transmission modes have been developed, such as Bluetooth, ZigBee, LoRa, and Wi-Fi.  [8]. There are many types of Bluetooth, such as traditional Bluetooth, standard Bluetooth, and the recently well-used Bluetooth low energy (BLE), as detailed in Table 6.

ZigBee
ZigBee protocols are the wireless communication protocols [9] Table 7.

Wi-Fi
The Wireless Ethernet Compatibility Alliance (WECA) was founded in 1999. At that time, 802.11a and 802.11b defined 5 GHz and 2.4 GHz, respectively, and the rates of the  [10].
In recent years, due to the popularity of 3C devices, such as mobile phones and computers, Wi-fi tends to be complete and mature in the use of WLAN. The detailed Wi-Fi protocols are shown in Table 8.

Communication comparison
This study compares the above-mentioned 3 wireless transmission technologies recently used by most people, including Bluetooth, ZigBee, and Wi-Fi, and lists their advantages, as shown in Table 9.

Air Quality Index (AQI)
In recent years, due to the rapid development of global technology, the air in the world is becoming increasingly worse. At the end of October 2018, in order to remind people of the irreversible effects of air pollution on human health, WHO held the first global conference on "air pollution and health" in Switzerland, specially emphasizing that children are the most seriously hurt by air pollution.
Internationally, PM2.5 has been classified as a high-risk cancerogen by the WHO, and the United States has used the new AQI since 1999. Taiwan's Environmental Protection Administration previously used the pollution standard index (PSI); however, the system's disadvantage was that PM2.5 could not be monitored, and the new AQI was launched in July 2014. The difference between AQI and the old PSI is the addition of O 3 and PM2.5, as well as more prudent evaluation; for example, when calculating the days of air pollution, AQI has 50 days more than PSI, which indicates that AQI is more accurate in calculating air pollution.
The AQI refers to the classification of the effects of the CO, O 3 , fine particulate matter (PM2.5), particle matter (PM10), SO 2 , and NO 2 concentrations in the air test data of the Environmental Protection Administration on that day on human health, and the detailed classifications of effects on human health are shown in Table 10. The calculated results according to various pollutant concentrations and air quality sub-indices are shown in Eq. 2-2, where all values are compared to calculate the maximum value, and then, the maximum value of the data is set as the AQI of that day, as shown in Eq. 2-3 [11].  According to the hazard degree and air pollution, the index is divided into six equal levels, namely, good, normal, unhealthy for sensitive groups, unhealthy for all groups, very unhealthy, and harmful, which are represented by green, yellow, orange, red, purple, and maroon, respectively, including the degree of pollution above the purple level. The 6 grades, and their related colors, represent different effects on the human body. Based on the AQI level evaluation standards, this study analyzed the air quality levels at which people can go out, the air quality levels at which people are suggested not to go out, and the air quality above the purple level at which people shall not go out, in order to avoid placing greater burdens on the body. The detailed comparison of the effects on the AQI is shown in Table 11.

Indoor Air Quality (IAQ)
As outdoor air pollution has become more and more serious in the last 2 decades, we encourage our children and elderly to stay at home. However, according to the EPA investigation of the U.S., indoor air pollution is 5 times worse than outdoor air pollution, thus, the hazards of indoor air quality are gradually taken seriously by people. Most people spend 85% of a day in an air-conditioned closed indoor environment, such as (2-3) AQI = max IAQI 1 , IAQI 2 , IAQI 3 , . . . , IAQI n Fig. 7 The structure of system fusion model. The air environment detection system has a large number of sensors, a wide distribution, and a large amount of information. a decentralized two-level fusion scheme is adopted for local fusion integrate with the whole domain schools, offices, and homes, and while people enjoy such a comfortable environment, closed buildings often lead to insufficient ventilation, and result in the sick building syndrome [12], as defined in 1982 by WHO.
The sick building syndrome is caused by poor indoor air quality resulting from constant accumulation of air pollutants indoors, which lead to abnormal issues, such as irritation to the eyes and nose, and in some cases, asthma. The detailed critical concentration of indoor air quality is shown in Table 12.

Clean air delivery rate
The Clean Air Delivery Rate (CADR) is defined by the Association of Home Appliance Manufacturers (AHAM) for cleaning technology, as shown in Fig. 6. CADR mainly refers to the rate at which an air purifier is used to clean the common sources of air pollution, such as pollen, dust, and dirt.
The calculation of CADR is shown in Eq. 2-4, where Ka represents the descending rate of air pollution when useing an air purifier; Kn represents the natural settlement rate of pollutants; V represents the interior volume. The CADR value represents the natural Fig. 8 The main program of vector Kalman filtering. Vector Kalman filter is a basic algorithm of prediction plus correction as its recursive filtering. Using this feature, it is easy to use a computer to filter the real-time signal Fig. 9 The subroutine of the vector Kalman filtering. Vector Kalman filter is a basic algorithm of prediction plus correction as its recursive filtering settlement of indoor air pollutants without external interference, but at a slow rate. Therefore, if an air purifier is turned on, the concentration will decrease significantly and rapidly, and during this process, the difference of the pollutant descending rate is the CADR value [13].
V: tested interior volume, Unit: ft 3 . K a : measured decay rate, unit: number of dust particles/minutes. K n : natural decay rate, Unit: number of dust particles/minutes.
After the CADR is calculated, the area in pings can be converted. AHAM's standard is 5 times per hour; however, there is no standard rule in Taiwan. The equation of area conversion is shown in Eq. 2-5, where S denotes square meters, and the area in pings is obtained after multiplying by 0.3025; H is the building height; 5 is the number of cleaning tis per hour according to AHAM.
H: building height.

Fuzzy theory
Binary logic, which is a classical logic commonly referred to, was proposed by Aristotle; however, the disadvantage of such classical logic is that only discrete events, but not continuous events, can be determined. Hence, the fuzzy theory is applied to deal with continuous problems. The detailed differences [14] between the classical theory and fuzzy theory are shown in Table 13.
The fuzzy theory is the fuzzy sets proposed by Professor L.A. Zadeh in 1965, and mainly covers 4 parts: fuzzy sets, fuzzy logic, fuzzy control, and fuzzy measurement [14].
In this study, defuzzification, rule base setting, and fuzzy inference in fuzzy control were used to evaluate the output of the experimental load.

Multisensor information fusion algorithm
Multi-sensor data fusion refers to the collected data of several sensors obtained from different information sources. The system automatically analyzes and synthesizes the information processing process under certain criteria to achieve a better understanding of the observed phenomenon. The application of information fusion technology to the water environment monitoring and control system to process the data provided by multiple heterogeneous sensors at multiple levels and in multiple aspects has many advantages. For example, multi-sensor data fusion has more comprehensive and accurate system information than single-sensor data. The information collected by a group of similar sensors is redundant, and the appropriate fusion of such redundant information can reduce the uncertainty of the information as a whole. The information collected by some different types of sensors has obvious complementarity. After proper processing, this complementarity can compensate for the uncertainty of a single sensor and the limitations of the measurement range. Multiple sensors can increase the reliability of the system. For example, when one or several sensors fail or fail, the system can still work normally [15,16].
The air environment detection system has a large number of sensors, a wide distribution, and a large amount of information. In order to reduce the burden of communication lines and reduce the amount of calculation in the fusion center, the system is divided into several subsystems for analysis, and then the analysis results are integrated to obtain the fusion result of the entire system, that is, a decentralized two-level fusion scheme is adopted for local fusion integrate with the whole domain, as shown in Fig. 7.
This data fusion method allocates sensors to air detection points according to design requirements, and uploads data after each air detection point has completed feature extraction. The relay station of the system performs partial fusion; the total detection station performs global fusion and generates auxiliary decision-making [17,18].

Local fusion algorithm
Since the number of air detection points is often not too many, that is, the dimensionality of the subsystem is low, the local fusion can be realized by the classic vector Kalman filter algorithm. Assuming that there are a total of q air detection points, the signals from each air detection point form a q-dimensional vector X(k) = [x 1 (k)x 2 (k) · · · x q (k)] T . Process noise is a sequence of independent white noise ω(k) = [ω 1 (k)ω 2 (k) · · · ω q (k)] T , then the mathematical model of the multi-dimensional random signal can be expressed as.  among them, A = diag(a 1 a 2 · · · a q ) is the coefficient matrix.
(3-1) X(k) = AX(k − 1) + ω(k − 1)  In order to optimally filter the q-dimensional random signal X(k), the first r components of X(k) (r < q) are measured simultaneously at k time, and an r-dimensional measurement data vector Y(k), its mathematical model can be expressed as     Vector Kalman filter is a basic algorithm of prediction plus correction as its recursive filtering. Using this feature, it is easy to use a computer to filter the real-time signal. Figures 8 and 9 respectively show the algorithm block diagrams of the main program and the sub-program of the vector Kalman filter [19,20].

Global fusion algorithm
The air data filtered and processed by the fusion station more accurately reflects the air environment in space [21,22]. The processing of the data uploaded by each relay fusion station by the total inspection center station can be regarded as a system transformation from a set of input modes to a set of output modes. Therefore, the global fusion algorithm uses a forward neural network model, such as the single hidden layer neural network shown in Fig. 10. The output of each relay fusion station forms a vector X(k) = [x 1 (k)x 2 (k) · · · x n (k)] T , as the input group of the neural network, the output group is Y(k) = [y 1 (k)y 2 (k) · · · y n (k)] T , which depends on actual engineering needs.
Take the activation function of the hidden unit as the sigmoid function The implicit output is  Taking the excitation function of the output node as a linear function, the output of the entire network is For the training of the forward neural network weight matrix, the BP algorithm is generally used. However, the traditional BP algorithm is essentially a least squares estimation, robustness is poor, and very sensitive to outliers, so this article uses the robust BP algorithm (RBP algorithm)  Among them, f(x) is the Sigmoid function.refere (3)(4)(5)(6)(7)(8)(9)(10)(11)

System architecture and hardware
The system architecture of this study was established based on the concepts of the IoT smart home, and divided into 4 major parts: Part 1-environmental sensing, Part 2wireless transmission, Part 3 -analysis, and Part 4-load control, as shown in Fig. 11. Regarding environmental sensing, the nodes of 2 environmental sensors were set up, including an indoor sensing device and an outdoor sensing device, as shown in Figs. 12 and 13, respectively. The indoor nodes contained 3 sensors for fine particulate matter, CO 2 , and CO, as well as an infrared emitter; the sensors retrieved the data of the control panel for subsequent processing; the infrared emitter was used to control the ventilation unit and air purifier, and was installed in the center of the laboratory due to the  laboratory's small space; the outdoor node was a fine particulate matter sensor installed next to a window [23][24][25]. The detailed locations of the 2 sensors are shown in Fig. 14.
In wireless transmission, after the Arduino board obtained the data, in order to transmit the received data to the computer terminal and the webpage, the ESP8266 Wi-Fi module was used as the communication bridge for data transmission. Fuzzy control was mainly used for analysis by combining it with the Visual Studio C# 2015 software to realize the AQI, as mentioned in Sect. 2, and C# software was used as the human-machine interface for users to inspect the environmental values. Regarding load control, after fuzzy analysis was conducted on the data captured in environmental sensing, the corresponding loads were activated for different values of various data, in order to achieve good indoor air quality. The loads under control were the window, air purifier, and the ventilation unit. When CO increases slightly, the buzzer will be activated first to remind the users to open the window as soon as possible to reduce CO concentration; when the

Fig. 29
Effects of fine particulate matters on AQI values. MATLAB was also used to simulate the effects of fine particulate matters and CO in the environment on the air quality sub-indices CO 2 or fine particulate matters exceed the standard, the Arduino Uno board will activate the ventilation unit and air purifier through the infrared emitter to reduce the concentration [26][27][28].
The software architecture consists of 2 parts: the indoor node flow chart, as shown in Fig. 15, and the outdoor node flow chart, as shown in Fig. 16. The 3 sensors and 1 sensor were set in the indoor and outdoor nodes, respectively, which returned environmental data to the Arduino Uno board at regular intervals and communicated with each other through ESP8266 Wi-Fi wireless transmission. Among them, the indoor nodes were equipped with the infrared emission module and buzzer, which could receive the results of the computer analysis to determine whether to turn on the air purifier, ventilation unit, or load strength setting, and whether the buzzer gave off warning sounds, in order to further remind the users to pay attention to environmental issues [29][30][31].
This study used the Arduino Uno module as the core architecture of the overall system for indoor air monitoring, as shown in Fig. 17. The core of the Arduino Uno board is an ATmega328 microprocessor with a built-in analog-to-digital converter (ADC for short) and 14 digital input/output pins numbered from 0 to 13, including 6 pins for PWM control, 1 for UART control, 1 for SCL/SDA of I2C, and 6 analog input/output pins. It is supplied by a transformer or USB, and the detailed specifications are shown in Table 14.
In this paper, the Arduino Uno board was used as the main body, and combined with the ESP8266 ESP01 module, infrared receiver, infrared emitter, and various gas sensors [32].

CO sensor module
This study used MQ-7 as the indoor CO sensor module, as shown in Fig. 18. The gas sensitive material used in this sensor is stannic oxide (SnO 2 ), which is an inorganic compound with low conductivity in general air. Sensor conductivity depends on the CO concentration in the air, where higher concentration leads to higher conductivity. MQ-7 detects CO by the high and low temperature circle detection Fig. 30 Effects of CO on AQI values. The simulation results show that fine particulate matters and CO are nonlinearly related to AQI values. If one of the indices is too high, the maximum value of all values will be set as the current AQI, resulting in unsatisfactory AQI method, where the voltages for high and low temperatures are 5 V and 1.5 V, respectively. Low temperature is used to detect CO, and the changes in conductivity can be known with the simple circuit design and be converted into output signals related to the CO concentration; high temperature is used to clean the gases absorbed at a low temperature. MQ-7 is highly sensitive in sensing CO and is a low-cost and suitable sensor for CO detection (Table 15). Fig. 31 Fuzzy system architecture. The fuzzy theory was used to control the load in this study, in order that the air quality could meet the best air quality stipulated by international standards

CO 2 sensor module
This study used the NDIR infrared sensor module (MH-Z14A) as the CO 2 sensor module, as shown in Fig. 19, which mainly senses CO 2 in indoor air using the theory of the non-distributed infrared ray. In addition to long service life, it has internal temperature compensation, digital and analog output, and the sensing range of 0-5000 ppm. The detailed specifications are shown in Table 16.

Fine particulate matter sensor module
The sensor for measuring the fine particulate matter (PM2.5) concentration in this study was designed by SHARP, namely, the GP2Y1010AU0F model, as shown in Fig. 20. With the range of 0-520 μg/m 3 , it mainly measures dirt, dust, and fine particulate matters indoors. This sensor detects particle matters in the air using an LED light source, and the actual operating circuit is shown in Fig. 21.  Fuzzy inference. When the CO 2 concentration is 382 ppm, the indoor PM2.5 is 39.6 µg/m 3 , the outdoor PM2.5 is 28 µg/m 3 , the indoor AQI is calculated to be 112, and the outdoor AQI is 82. At this time, the fuzzy inference results show that the ventilation unit is 1, the air purifier is 0, and the window is 0.5

Wi-Fi wireless transmission module
This study used ESP8266 ESP-01 in the Wi-Fi wireless transmission module, as shown in Fig. 22, which was taken as the bridge for wireless transmission between the computer and the Arduino Uno board for the indoor environment data. Due to its very low power consumption, the UART-Wi-Fi transmission module is compatible with numerous    Table 16.

Infrared emission module
The infrared emission module used in this study is shown in Fig. 23, which has an operating temperature range of − 25 to 80 °C and wasted power of 90 mW. This module can effectively control the system load, and through wireless remote control, can adjust the air purifier and ventilation unit, in order to minimize the trouble caused by the requirements of line arrangement for wired control.

Infrared receiving module
As shown in Fig. 24, the infrared receiving module is the component that combines receiving, amplification, and demodulation, and can complete internal decoding. In   addition, the emitter and receiver shall be used in pairs, otherwise they cannot be used due to the effects of sensitivity or failure to pair.

PL2303 USB to TTL
As shown in Fig. 25, the PL2303 USB to TTL in this study is a data converter, which converts the single chip USB into UART. Through PL2303, ESP8266 can communicate with the PC, thus, the PC can use ESP8266 to install the local area network of the wireless Wi-Fi base station, and be the bridge of wireless transmission among the various environmental data, load devices, and computer terminals in the system.

Load control
There were mainly three loads for control used in this study, namely, air purifier, ventilation unit, and buzzer, as shown in Figs. 26, 27 and 28, respectively.

Air quality evaluation and MATLAB simulation analysis
In order to maintain the indoor air quality within a good range, this study first evaluated the indoor air pollutant evaluation method, and selected the suitable AQI In 1993, the Environmental Protection Administration proposed the air pollution index of the Republic of China, which monitors particle matters, SO2, NO2, CO, and O 3 , but not the fine particulate matters responsible for the severe damages to human bodies recently. Accordingly, the air pollution index of the Republic of China has been gradually replaced by AQI. The air evaluation standard commonly used in Taiwan in the past was the Air Pollution Index (API), as based on the cancelled GB3095-1996 Fig. 48 Connection interface of the monitor system. The data were stored for historical data experimentation, analysis, and research. After entering the online system, users will see a reminder showing that the system is online Fig. 49 Main interface of the monitor system. The main interface of the monitoring system, where the current connection quality is shown in the upper left of this interface, as well as the 2 indoor environment nodes and the outdoor environment node, the current states of the load devices, and the measurement of the overall indoor air quality ambient air quality standard, which only evaluated SO 2 , NO 2 , and particulate matters. Compared with the air pollution index of the Republic of China and API, AQI is universal and has the advantages of stricter standards, more pollutant indices, and evaluation results closer to the public's feelings, thus, AQI was selected as the evaluation standard.
AQI in this study mainly refers to CO, fine particulate matters, O 3 , particle matters, SO 2 and NO 2 , by cooperating with the CO 2 evaluation standard proposed by ASHRAE. In order to effectively control loads to achieve the ideal environment, MATLAB was used to simulate the indoor CO and fine particulate matters, and the effects of the 2 different indices on the indoor air quality were analyzed as the experimental basis for subsequent load control. MATLAB was also used to simulate the effects of fine particulate matters and CO in the environment on the air quality subindices, and the results are shown in Figs. 29 and 30, respectively.
The simulation results show that fine particulate matters and CO are nonlinearly related to AQI values. If one of the indices is too high, the maximum value of all values will be set as the current AQI, resulting in unsatisfactory AQI. According to the ASHRAE CO 2 index, AQI shall be less than 50 and the CO 2 index shall be less than 450 ppm for the environment with the best indoor air quality. As the indoor fine particulate matters mainly come from the outside, the indoor fine particulate matter concentration can be reduced by closing windows; however, closing windows for a long time will increase the CO 2 concentration, and it is necessary to open windows or turn on ventilation units for ventilation. Hence, how to deal with the indoor and outdoor air quality is the main evaluation method of fuzzy logic.

Fuzzy control
In order to use AQI and ASHRAE's CO 2 index as the load control standards, it is necessary to use the nonlinear multi-input multi-output (MIMO) mathematic model, as formed by the interaction between the input parameters and the output loads, as it is difficult for the traditional PID control or constant control to achieve accurate control of air quality. Therefore, the fuzzy theory was used to control the load in this study, in order that the air quality could meet the best air quality stipulated by international standards: 0 < AQI < 50, 0 < CO 2 concentration < 400. The detailed fuzzy architecture is shown in Fig. 31, and the fuzzy control flow chart is shown in Fig. 32.
In the fuzzy system, according to the inputs simulated by MATLAB and the data settings provided in the literature review, the function results of CO 2 membership, indoor PM2.5 membership, and outdoor PM2.5 membership, as based on the data indices, are shown in Figs. 33, 34 and 35, respectively. The output membership function controls the loads of this study including the air purifier, ventilation unit, and window, as shown in Figs. 36, 37 and 38, respectively.
The fuzzy rule base is designed by collecting indoor and outdoor environmental data, analyzing massive data, and cooperating with reference data. There is an ideal method in fuzzy control for nonlinear environmental data. The fuzzy decisions for different environments also test the designers' familiarity with the environment, which requires massive experimental data for analysis and comparison to design a perfect fuzzy logic rule base, as shown in Fig. 39. The detailed rule base settings are shown in "Appendix 1".
As the focus of fuzzy control, the fuzzy inference simulates the thinking of human beings in different environments and makes corresponding actions by setting the rule base. When the CO 2 concentration is 382 ppm, the indoor PM2.5 is 39.6 μg/m 3 , the outdoor PM2.5 is 28 μg/m 3 , the indoor AQI is calculated to be 112, and the outdoor AQI is 82. At this time, the fuzzy inference results show that the ventilation unit is 1, the air purifier is 0, and the window is 0.5, as shown in Fig. 40. Regarding the inferred 3D load diagrams; the relationship between indoor PM2.5, CO 2 and the air purifier is shown in Fig. 41; the relationship between outdoor PM2.5, CO 2 and the air purifier is shown in Fig. 42; the relationship between outdoor PM2.5, CO 2 , and the window is shown in Fig. 43; the relationship between outdoor PM2.5, indoor PM2.5, and the window is shown in Fig. 44; the relationship between indoor PM2.5, CO 2 , and the window is shown in Fig. 45; the relationship between indoor PM2.5, CO 2 , and the ventilation unit is shown in Fig. 46. The final step of the fuzzy theory is defuzzification, which has the purpose of converting sets into specific data. The ventilation unit is 1, indicating the ventilation unit operates at a low speed; the air purifier is 0, indicating closed; and the window is 0.5, indicating the window is half open.

Comparison of 3 types of environmental monitoring
According to the explanation of the above fuzzy control methods for air quality, the 3 conditions are compared, namely, no control, constant control, and fuzzy control. As the environmental data changed slightly in a short time, the indoor and outdoor sensing data were captured every 30 s in this study. No control is to sense the air quality after closing the door and window, turning off the air purifier and ventilation unit, and without any load; constant control is to sense the air quality by opening the door and window, and the ventilation unit and air purifier operate at a low wind speed; fuzzy control is to control the air quality under the load by integrating the sensing data through the C# interface and fuzzy analysis.
The best air quality can also be obtained with no controlled load, as most indoor air pollution sources come from the outside, thus, the best air quality can be achieved if the door and window are closed. However, if the room is closed for a long time, due to poor ventilation, the CO 2 concentration will be the highest of the three; hence, the key to this study is to strike a balance between the two. The detailed comparison of the no control mode is shown in Table 17.
Under constant control, because the door and window are opened and good indoor and outdoor air circulation is achieved, the CO 2 concentration is obviously highly reduced; however, the dirty outdoor air is also brought into the room. In the room, the low efficient air purifier and ventilation unit will indirectly lead to unsatisfactory indoor air quality. The detailed comparison of constant control mode is shown in Table 18.
Under fuzzy control, the CO 2 concentration and AQI can be in good condition provided the fuzzy rule base is properly set, and energy will not be wasted by leaving the load on all the time. The detailed comparison of the fuzzy control mode is shown in Table 19. The detailed comparison of air quality under no control, constant control, and fuzzy control is shown in Fig. 47.
The no control mode achieves the best air quality because the window is kept closed for a long time. Under constant control, the door and window are kept open for a long time, but regardless of the good ventilation rate, the cleaning speed of the load cannot keep up with the environment changes, thus, the air quality is poor. Therefore, the correlation between indoor air quality and outdoor air quality can be determined. Under fuzzy control, after long-term measurement and observation, the rules are established and good choices are made according to the current environment, thus, indoor air quality and CO 2 can achieve the standard of the ideal environment.

System implementation and application
This study transmitted environmental data to the computer using Wi-Fi wireless transmission technology, and the values measured by the sensors are shown through the C# graphical human-machine interface. Moreover, with the Microsoft Excel database, the data were stored for historical data experimentation, analysis, and research. After entering the online system, users will see a reminder showing that the system is online, as shown in Fig. 48. Figure 49 shows the main interface of the monitoring system, where the current connection quality is shown in the upper left of this interface, as well as the 2 indoor environment nodes and the outdoor environment node, the current states of the load devices, and the measurement of the overall indoor air quality. The CO 2 , indoor fine particulate matter and outdoor particulate matter data are combined with fuzzy control for indoor air quality control. CO is controled by the threshold, and if the CO is greater than 9 ppm, the buzzer will sound. Different colors directly reflect the AQI indices in reality, in order that users can directly understand the indoor and outdoor air quality without consulting other information.
The above experiment found that, under the 3 control modes, the fine particulate matter concentration is the minimum under no load control, followed by fuzzy control and constant control. Regarding the CO 2 concentration, fuzzy control is best, followed by constant control and no control, which indicates the importance of outdoor and indoor air circulation for CO 2 concentration and the necessity of avoiding air quality deterioration during air circulation. In this study, all experiments of the fuzzy theory reached the ideal range, thus, the proposed method is effective.

Conclusions
In this study, an indoor air quality control system was developed under the architecture of an IoT smart home. The Arduino Uno board, ESP8266 wireless transmission technology, and various sensors were taken as the core of the hardware, and C# and Excel were used for terminal processing of the software. According to the experimental results, the data of indoor environment were analyzed, and the load was controlled by combining the fuzzy logic rules. The purpose of this study was to improve the living quality in all residences and maintain good indoor air quality, in order that children and people with allergies are less likely to suffer from asthma and respiratory problems due to poor air quality, and people are less likely to have reduced office efficiency and fall asleep because of high CO 2 concentrations, thus, creating good air quality environments for the public.
AQI and the CO 2 concentration index by ASHRAE were taken as the standard to evaluate indoor air quality, and the indoor fine particulate matters, outdoor particulate matters, CO, and CO 2 standards were developed according to the common relation between the 2 indices. Scholars consider that AQI values between 0 < AQI < 50 have the best quality, and the CO 2 concentration shall be between 0(ppm) < CO 2 (ppm) < 450(ppm) in the CO 2 concentration table, as developed by ASHRAE. MAT-LAB was used for simulation, and the controllable environmental factors that could be used as the fuzzy rule base were analyzed. The outdoor air quality had the greatest effects on the indoor air quality, meaning the indoor air quality improved provided the door and window were opened for a short period of time under any control, while the CO 2 concentration increased if the door and window were closed for a long time. Hence, through data integration, the purpose of this study was to immediately respond to increased pollution concentration and poor air quality, in order to prevent people from physical and mental diseases due to staying in a bad environment for a long time. In this study, the data of no control, constant control, and fuzzy control were stored in Excel, in order to improve the reliability of the fuzzy control mode, and to carry out the subsequent analysis and development of the data.
This study analyzed the common fine particulate matters, CO, and CO 2 . Many families have pets at home these days, which we hope to add to the fuzzy inference in the future, as human dander and pet hair cause air pollution, and some volatile gases can also lead to temporary poor air quality. Therefore, by adding these components, indoor environmental quality measurements may be more detailed, and more appropriate actions may be taken to reduce allergies and physical discomforts. In the future, various factors can be integrated, such as temperature, humidity, home safety, and hygiene, in order that everyone can have a clean and safe environment, and achieve a truly ideal home environment.