Design of Wireless Temperature and Humidity Acquisition System

With CC2530 Radio frequency transceiver chip and DHT22 digital temperature and humidity sensor as the core, a wireless temperature and humidity acquisition system based on Z-Stack protocol stack and Zigbee wireless communication technology is designed and implemented. And use the upper computer software in a GUI manner to display the temperature and humidity changes on the display terminal in real-time. This paper mainly describes the key technologies and implementation methods of wireless temperature and humidity acquisition systems, such as structure design, data acquisition process, and graphical interface monitoring. The final experimental results show that the wireless sensor system can collect temperature and humidity data in real-time, with good scalability and high reliability and excellent stability, which can use in many fields.


Introduction
With the rapid development of electronic technology, computer technology, and communication technology, the Internet of Things technology arises at the historic moment. The research and application of Bluetooth, GPRS, WIFI, Zig-Bee, and other wireless sensor network technologies have promoted the rapid development of new generation sensor network technology. Combining wireless network technology with the Internet of Things technology has brought a very far-reaching influence on people's lives and various areas of production and has a broad application prospect.
This work is mainly based on ZigBee wireless sensor network technology, with the RF(Radio Frequency) transceiver CC2530 chip as the core, and TI (Texas Instruments) company's Z-Stack protocol stack, a self-organizing network for wireless temperature and humidity monitoring is constructed. After collecting and receiving the data, it communicates through the serial port and uploads it to the upper computer to display the real-time monitoring situation in a GUI manner.
The advantage of this system is that it can use ZigBee wireless networking to access a large number of data collection point sensors. The experimental results indicate that the wireless nodes used by this system for monitoring have good scalability and can be used to collect multiple sensor parameters including air pressure, temperature, humidity, light, wind speed, and wind direction. [1]. In addition, it has stable performance and can be widely applied in the * Corresponding: zhu. field of temperature and humidity monitoring in the household, industrial, and agricultural environments.
2. Z-Stack protocol stack and the wireless sensor network 2.1 Z-Stack protocol stack Z-Stack protocol stack is a ZigBee protocol stack developed by TI company, it has been accepted by the ZigBee Alliance and widely adopted by many developers around the world. The source code of TI Z-Stack protocol stack is mainly composed of three parts: the hardware abstraction layer, the operating system abstraction layer, and the ZigBee protocol layers [2]. Only from the perspective of program operation, to understand Z-Stack protocol Stack well, we can consider it as the process of performing by the operating system [3], which makes it specific, simple, easy to understand and clear in the hierarchy.

Wireless sensor network
Wireless sensor network(WSN) have huge application prospects and is considered to be one of the technologies with significant influence on the 21st century, has a lot of application space in many fields, such as defense technology, traffic management, medical health, intelligent agriculture, and urban informatization construction. Moreover, with the continuous improvement and innovation of computer technology, wireless communication technology, and sensor technology, the application of wireless sensor networks has brought farreaching influence on people's life and production.
ZigBee wireless sensor network [4]∼ [6] is one of the emerging short distance, low-rate wireless network technologies. It has many advantages, such as easy to apply, low power consumption, low cost, flexible working frequency, high reliability, self-organizing network and self-recovery capability. Therefore, it is very suitable for wireless temperature and humidity monitoring system [7].

System structure hardware design
The wireless temperature and humidity acquisition system consists of two parts: the upper computer monitoring system and the lower computer ZigBee wireless selforganizing network. The system structure and networking diagram are shown as Fig. 1.
It can be observed from Fig. 1 that each sensor with a debugger connects to Zigbee's master control chip CC2530 module via a serial interface. At the same, the lower computer includes ZigBee coordinators, routers, and sensor modules with different functions, they form a wireless network through RF transceiver, and the upper computer is composed of monitoring terminal computer and interface graphics software.

CC2530
The master control chip CC2530 can build a stable network node with an extremely low total material cost. The CC2530 chip used in this design has a built-in enhanced 8-bit 51 single-chip microcontroller and RF transceiver. The system has 256 KB programmable flash memory and 8 KB RAM. The on-board intelligent digital sensor expansion port connects two sets of 2× 8PIN interfaces, and this interface provides power for the sensor and conducts UART communication.
There are two on-board LED indicators used to indicate power on and different communication functions. The USB-to-serial port can be used for the wireless communication module's serial port debugging function, and Mini USB cable is connected to the upper computer and is implemented by USB-to-serial port. Each node and module is independently powered by a 12V DC power adapter, which ensures the lasting stability of the entire wireless network [8].

Temperature and humidity sensor
The DHT22 temperature and humidity sensor adopted in this design is a digital temperature and humidity sensor with calibrated digital signal output. It applies special digital module acquisition technology and temperature and humidity sensing technology to ensure the sensor has high reliability and excellent long-term stability. The signal transmission distance of this product can reach up to 20 meters, temperature range:-40∼80 • C, resolution 0.1 • C, error ±0.5 • C, and humidity range: 0 ∼ 100%RH, resolution 0.1%RH, error ±2%RH. In general, it has the advantages of ultra-small volume, extremely low energy consumption, excellent quality, ultra-fast response, strong anti-interference ability, and high-cost performance. At the same time, compared with the DHT11, the output accuracy is higher, making it the best choice for various applications [9].

Wireless communication hardware implementation
The digital temperature and humidity sensor DHT22 is connected to the master control chip CC2530 via the on-board expansion interface. The core CC2530 chip in each module integrates the 8051 MCU chip with storage function to control the data collection of temperature and humidity sensors in the node module. Then sends the data to the routing device through the wireless network. And subsequently, the routing device communicates with the coordinator through the wireless network, and the coordinator sends the data sent by each node to the monitoring terminal through the serial port.
When powering on the device with different functions modules, the two indicators on the ZigBee module have different displays. Specifically, LED1 shows the status of power, and LED2 shows the data transmission situation, respectively. When a coordinator module acting as a gateway is started, the LED1 on the ZigBee module starts blinks. Once the networking is successful, the LED1 will be always on, indicating that the ZigBee protocol is running normally. Following, the LED2 will blink after receiving data from other wireless modules. When the router module started acting as a gateway, the LED1 on the ZigBee module starts blinks. And after successfully connecting to the network, both LED1 and LED2 are all on simultaneously. The last one, when the terminal node module connected with sensors is started, the LED1 on the ZigBee module starts blinks, after successfully connecting to the network, both LED1 and LED2 blink rapidly simultaneously to coordinate communication.
The above experimental results give a strong indication that in ZigBee, the LED is non-blocking. When the function is called, the LED will complete the corresponding action in the backstage (such as blinking 50 times). This unified way to manage devices in the backstage, minimal use of system resources [10].

Software implementation
The software design is mainly based on the development environment of the upper computer. Specifically, it based on the sample app project programming development in the Z-Stack protocol stack, and implement the communication function of the coordinator, router, and terminal temperature and humidity collection respectively, make them coordinate communication with each other according to the ZigBee communication protocol, and finally implement the function of the self-organizing wireless network and terminal graphical interface display.

IAR implementation
In this design, Wireless communication node in wireless sensor network(WSN) adopts TI's CC2530 processor. The upper computer's Win- dows development environment is based on the Z-Stack-CC2530-2.3.0-1.4.0 protocol stack and uses the embedded integrated development environment IAR ew8051-ev-751a for the software development of the upper computer. Finally, the terminal display software Z-Sensor Monitor implements the interface display of the upper computer terminal. This development environment integrates a good function library and tool support for the target processor and supports online download, simulation, and debugging functions [11]. After starting the system, select the serial port connection in the terminal software of the upper computer, and according to the serial port number of the hardware connection, set the corresponding communication parameters including serial number, baud rate and parity bit, and then open the serial port connection for data communication. After the ZigBee coordinator module of the lower computer is powered on and started, the ZigBee network is formed by itself and wait for network access requests from routing nodes and end nodes.
When the routing node and terminal node are powered on, they will automatically form a network according to the protocol. And then after the networking is completed and displayed successfully, the temperature and humidity sensor nodes distributed in each effective ranges will collect realtime temperature and humidity data independently, communicate with the CC2530 module connected to the bottom layer Via the serial interface protocol and send the detected temperature and humidity data to the CC2530. At this time, CC2530 first preprocesses the received data information and then forwards it to the routing module node in the ZigBee network through the wireless network. The routing module subsequently communicates with the coordinator wirelessly. Finally, the coordinator sends data to the upper computer through serial port communication [12].

Temperature and humidity data acquisition process
In this design, DHT22 temperature and humidity sensors are used to collect temperature and humidity data. Specifically, each sensor acquisition node can collect real-time temperature and humidity data within an effective range, and periodically store the collected data into the CC2530 node device at a fixed interval. At the same time, the sensor adopts a standard single-bus communication mode. When the bus is idle, its state is high level. When the host calls the sensor, the sensor responds, and after receiving the start signal from the host, it begins to send the serial data packets regularly-the data packets information, as shown in Table 1. The sensor sends 40 bits of data from the data bus at one time, and high priority transmission. The entire reading process of temperature and humidity sensor, as shown in Fig. 2. It can be observed from Fig. 2 that because the temperature and humidity value read by the sensor each time is the result of the previous measurement. Therefore, the sensor needs to read twice in a row each time, and the minimum interval time between each reading should be longer than 2 seconds to obtain accurate real-time temperature and humidity data. The final real-time measurement results are displayed digitally.

Coordinator workflow
The coordinator is the core of the whole ZigBee wireless network, and the node uses the CC2530 chip, which has essential networking and collaboratiion functions. Firstly, the coordinator initiates a network in a specific frequency band by the protocol rules, is responsible for formulating the network channels, and then after scanning, selects the optimal channel to form a wireless network. Besides, it is responsible for network monitoring and maintenance during the entire network construction and operation.
At the same time, during the operation of the entire network, the coordinator also needs to identify the data received from the upper computer, and then determines and forwards it to the specific corresponding nodes. Meanwhile, the coordinator is also responsible for adding network addresses to the data frames sent by the remaining nodes to the upper computer, and then forwarding them to the upper computer [13]. The RS-232 communication interface is used for communication between the coordinator and the upper computer, and the data collected by each node is sent to the computer through the serial circuit. Finally, the computer terminal stores and displays the received data.
Specifically, for the temperature and humidity acquisition system designed in this paper, the bottom layer of the system of each node uses the Z-Stack protocol stack, and the network parameters of each node are configured accordingly. The coordinator first initiates a network in a certain frequency band, and the definition of the network frequency band is placed in the "DEFAULT CHANLIST" configuration file, and "PAN ID" is established according to the definition of "ZDAPP CONFIG PANID". Then, scan all channels specified by "DEFAULT CHANLIST" and selects the optimal channel to form a network.That is, after the sensor node is started, it scans the channel specified by "DEFAULT CHANLIST" and automatically joins the network according to the "PAD IP" defined by "ZDAPP CONFIG PANID" [14]. The workflow of coordinator as shown in Fig. 3.

GUI terminal display
Open the ZigBee Sensor Monitor display terminal on the upper computer, select the corresponding serial communication port and set it up, make the communication port maintain the same baud rate. When the coordinator is not powered on, the terminal interface displays "SINK NO RESP and shows a gray state. Once power on, we can see that the icon representing the coordinator turns red, which means that the coordinator is successfully connected to the computer and can communicate normally. The next step is to power on the routing module, which serves as the routing function. After pressing the "RESET" key to restart, the routing module will send an analog data to the coordinator. And after the coordinator receives this data, it will send the data to the computer terminal through the serial port and display the network structure and the node connection status through the terminal "TI Sensor Monitor" software interface, At the same time, the address of the corresponding module and the time of data transmission will also be displayed on each node. Finally, when the sensor terminal node is power on, the terminal interface of the upper computer will display the node, and the network structure of the node after it joining the network. Meanwhile, the address, the last received data time, and the temperature and humidity value received through the serial port will also be displayed on the node.
It can be found that through the upper computer terminal's visual interface, it is convenient and intuitive to observe and master the networking process, network structure, and temperature and humidity of the ZigBee network. After the coordinator, router, and sensor terminal on the upper computer successfully access the network, the GUI interface display, as shown in Fig. 4.

Conclusions
This paper is mainly based on ZigBee wireless sensor network technology, with the Radiofrequency(RF)transceiver CC2530 chip as the core, and based on TI(TEXAS IN-STRUMENTS) company's Z-Stack protocol stack and development environment, a wireless sensor network(WSN) for wireless temperature and humidity monitoring is constructed using ZigBee self-organizing network. After the real-time temperature and humidity data are collected and received, upload it to the upper computer through the serial port. It visually displays the real-time temperature and humidity situation in a GUI interface, which provides convenience for people's life and research.
After several tests and applications for a long time, it has been proven that this system design has many advantages, such as simple and flexible networking, low cost, low power consumption, real-time data collection, and stability, etc. Therefore, it has good practical value and good promotion prospects in intelligent agriculture and smart homes.