Design of Indoor Temperature and Humidity Monitoring System based on ZigBee and Fuzzy PID Technology

In order to solve the problems of complicated wiring and high cost in the existing indoor temperature and humidity monitoring system, an indoor temperature and humidity monitoring system based on CC2530 and fuzzy PID control strategy was designed and developed. The system consists of four sensor nodes, a gateway node and a monitoring center. It takes CC2530 as the core to develop wireless sensor nodes, and completes the real-time monitoring of indoor temperature and humidity. The communication between nodes follows ZigBee protocol, and realizes the self-organized network of wireless sensor networks and automatic aggregation of monitoring data. The system realizes temperature and humidity regulation based on fuzzy PID control technology and improves control precision. It uses embedded database management mode to realize sensor node management, environmental data management and early warning functions. The experimental results show that the system has good stability, high reliability of data transmission, strong adaptability, good openness, economy and short development cycle.


Introduction
With the improvement of people's living standard, the requirement of temperature and humidity in daily life and surrounding environment is also increasing. Therefore, monitoring and control of temperature and humidity has become a very important technology in daily life and production [1]. Most of the traditional indoor environment temperature and humidity monitoring systems are wired. Fieldbus and distributed control bus are mostly used, but their shortcomings are obvious: the wiring is cumbersome, which is not conducive to system layout changes and maintenance [2], and cannot be widely applied. The rapid development of wireless communication technology and embedded system provides a new option for the development of indoor temperature and humidity monitoring system [3]. Wireless sensor network (WSN) [4] [5], composed of a large number of sensor nodes, is a new advanced technology for data acquisition, processing and wireless transmission [6]. With the advantages of convenient deployment and low cost, it can effectively realize the collection and transmission of environmental information, timely adjust the management strategy without on-site maintenance, and has broad application prospects in the field of environmental monitoring [7,8].
This paper designs an indoor temperature and humidity intelligent monitoring system. The ZigBee CC2530 wireless communication module is used to constitute a data acquisition terminal, which can monitor the environmental information in real time. The data acquisition terminal is effectively controlled by the upper computer software, and the information is real-time. Display, storage, analysis and processing, using fuzzy PID control technology to deal with temperature and humidity data deviation, improve the control accuracy, so as to achieve intelligent monitoring of indoor temperature and humidity.

System Requirement Analysis.
Through investigation and analysis, indoor environment temperature, humidity, and other controlled objects are characterized by large lag and large inertia. Therefore, the application requirements of the monitoring system mainly include the following aspects:  Real-time acquisition, processing and uploading of environmental temperature and humidity on-line all day.  Real-time transmission and aggregation of collected data using low-cost and low-power wireless communication.
 In addition to providing fault diagnosis and over-limit alarm to understand the indoor environment conditions, the upper computer can also construct an intuitive system management platform to realize the functions of sensor management, environmental information storage and analysis and processing. The information is processed based on detection, and the control output is formed according to the predetermined control strategy.

System Overall Design.
The system is based on ZigBee tree topology, which includes terminal node, gateway node and monitoring center. The terminal node is composed of sensors based on ZigBee, whose task is to collect indoor environmental temperature and humidity data and forward it to the gateway node. The gateway node is served by ZigBee coordinator, which receives data information and communicates with the monitoring center through serial port. The monitoring center includes a PC computer and related management software. For graphical operation environment, data display and staff query.

Hardware Design of Node.
Sensor nodes are the basic components of indoor temperature and humidity monitoring system. They need to have the functions of environmental temperature and humidity data acquisition, processing, wireless communication and so on. Under the background of indoor monitoring application, sensor node design focuses on low cost, low power consumption, stability, reliability and other factors. Terminal node consists of sensor module and CC2530.
CC2530 is the processor and wireless communication unit of the system. It is a real ZigBee wireless SoC on chip system. With the characteristics of low power consumption, low data rate and high reliability, the sensing data is transmitted to the receiving node in the form of wireless multi-hop, using the global universal frequency band (2.4 GHz) which is currently preferred by sensor networks.
The specific task of gateway node is to process and transmit the collected information, and its storage capacity and communication capacity are not high requirements for temperature and humidity monitoring. Therefore, CC2530 can still be used, which is similar to the composition and design of sensor nodes. Gateway node function is to complete data correction, fusion, and send to the monitoring center, but also get instructions, after processing, send to the control equipment. In order to realize the communication of each node monitoring computer, the TTL level output by microprocessor is converted to RS232 level of PC by using level conversion chip MAX232, and 5V power supply is adopted, which requires fewer peripheral components and follows EIA/TIA232 communication standard.

Hardware Design of Sensor Measuring Circuit.
Sensor nodes need to complete the collection of various environmental factors, so sensors are required to have high accuracy and low power consumption. Sensor output can be directly connected to the P0 port of CC2530. ADC in CC2530 can convert analog output to digital output.
In this design, the temperature sensor adopts AD7418, developed by ADI Company, and humidity sensors, Model HM1500, produced by Humirel Company. In this design, two I/O ports of CC2530 are used to simulate the clock line and digital line of I 2 C bus respectively, which simplifies the circuit design and saves the I/O port of CPU. The technical parameters are shown in Table 1. As an important branch of intelligent control field, it imitates human thinking to control, and has the advantages of simple design and strong robustness. Therefore, the fuzzy control algorithm is selected to control the environmental factors of the indoor temperature and humidity monitoring system, and the software tool is used to assist the design of the fuzzy control system. According to the actual change of control quantity, the fuzzy PID controller is designed, the fuzzy rule table is established, and the experiment is carried out, which can achieve good control effect.

Structure Design of Indoor Temperature Fuzzy PID Control.
Combining fuzzy control with PID control, using the basic principles and methods of fuzzy mathematics, the condition and operation of the rules are expressed by fuzzy quantities, and these fuzzy control rules are stored in the computer knowledge base. Then, according to the actual situation of the control system, the computer can automatically realize the PID by using fuzzy reasoning. The fuzzy PID control structure is shown in Fig. 1. In this design, the fuzzy PID controller is applied to temperature control. The error and change rate of the fuzzy PID controller are taken as input language variables, while the change of input variables and control variables in the controlled process are taken as output language variables, which is helpful to ensure the stability of the system and reduce the overshoot of the response process and weaken its oscillation phenomenon. Combining fuzzy control with PID control, using the basic principles and methods of fuzzy mathematics, the condition and operation of the rules are expressed by fuzzy variables, and these fuzzy control rules are stored in the computer knowledge base. Then, according to the actual situation of the control system, the computer uses fuzzy reasoning to realize the optimum PID parameters. Good adjustment.

Terminal Node Software Design.
In the design of node software, the device initialization, network configuration and network start-up of network management layer are completed by calling API function provided by ZigBee protocol stack, and the self-organized network of wireless sensor nodes distributed in multiple aquaculture ponds is realized. Sensor nodes are mainly responsible for collecting environmental data and transferring these data to routing nodes. When no data is sent or received, it is switched to sleep mode to minimize the power consumption of nodes. Its software flow chart is shown in Fig. 2.

Fuzzy PID Control Software Design.
Fuzzy-PID control takes error e and error variation ec as input, makes fuzzy inference through a series of fuzzy control, reappears automatic adjustment of PID parameters, thus enhancing the adaptive ability of the controller and improving the performance of the control system. The change of temperature error ec and temperature error e is selected as input variable, and the increment of PID controller parameters is used as output variable. The premise linguistic variables in the fuzzy rules constitute the fuzzy input space and the conclusion linguistic variables constitute the fuzzy output space. For each linguistic variable, its fuzzy set has the same universe of discourse. According to the actual engineering experience, the extracted fuzzy rule table of p K is shown in Table 2.   Fig. 3.

Software and structure design of monitoring center.
Monitoring center management system is responsible for sending acquisition commands, receiving acquisition data, and publishing data on the server to meet client browsing. The main tasks of the management center are:  Monitoring all flowmeters synchronously, realizing on-line monitoring functions such as over-standard alarm.
 Collecting data and checking cyclic redundancy (CRC) to ensure data reliability;  Using wireless transmission mode, data are transmitted to monitoring center in real time;  Monitoring data and time information can be automatically stored in database server; realizing real-time.
 Curve display, historical curve query, data report printing and real-time display according to need, and historical query according to time;  Recording and alarming in order to eliminate hidden dangers when the data collected by a node is abnormal. The software task of the monitoring center is to communicate with the gateway node through RS232 serial port in order to receive the data of the sensor node and realize the functions of human-computer interaction, network management, sensor information reception, data processing and analysis and database management.
This design is based on Mscomn control, and is developed by Visual C++6.0. Mscomn can provide all functions of serial communication. It can read or write data from serial port to serial port. This control encapsulates the underlying operating procedures in the communication process. Users only need to set and monitor the attributes and events of the control. It can easily realize asynchronous serial communication between users and applications.  Fig. 4. Fig.4. Software block diagram of monitoring center

Application Environment.
After the system design is completed, the installation is convenient and flexible. The development board is used to monitor the environment temperature and humidity in the laboratory. After testing, it can realize the collection and transmission of temperature and humidity. Four slave nodes and one central node are installed in the range of 50m2 laboratory, labeled as N1-N4 respectively. The system can realize the collection, transmission and list display of data. After testing, temperature and humidity sensor nodes can pass through obstacles such as instruments and equipments on the sensor test-bed in the range of 15 meters. The network has good self-correcting ability and high data accuracy.

Application result analysis.
Through the test, the temperature and humidity sensor in the range of 15m, through the sensor experiment equipment and other obstacles, can realize the collection, transmission and data list display, network self-correction ability, and high precision data. The error of temperature detection is not more than 0.5 degrees, and the relative humidity detection error is within 5%. Once the detection parameters overrun, computer response time is generally less than 3S, to display the address and limit parameters, and alarm. The two nodes (N1 and N2) monitor data at several time points, as shown in Table 3.
It can be seen from the table that the data measured by the system are more accurate and are located near the best value. The maximum error of temperature and humidity is 0.4 C and 5% respectively. The curves of temperature and humidity are shown in figures 5 and 6 respectively.

Conclusions
The software and hardware of indoor temperature and humidity monitoring system are designed with wireless sensor network technology. The real-time monitoring and management of temperature and humidity parameters in indoor temperature and humidity environment monitoring are realized. It provides a feasible, applicable and relatively low cost solution for the automatic production management of indoor temperature and humidity monitoring. . Each sensor node in the system is within the effective communication range of the sink node; the distribution of points is flexible, and the communication lines need not be arranged indoors. The nodes can collect, process, transmit and store the information of environmental parameters with high density, high intensity and full automation at any time interval to realize the indoor temperature and humidity of people's lives. Real time and accurate monitoring of the environment.