Smart test
Temperature and humidity monitoring system based on ZigBee-WSN
Aiming at the problems of complex wiring of the environmental monitoring system, real-time data and low accuracy, a distributed sensor network platform based on ZigBee technology is proposed. The SHT75 sensor is selected to realize the accurate collection of temperature and humidity information at the monitoring point, and the long-distance data transmission and aggregation are completed through the ZigBee network formed by the CC2530 chip and the CC2591 RF front-end. After the data is compared with the threshold, it can be audible and visual alarm or GSM SMS alarm. At the same time, the collected temperature and humidity information will be displayed and stored in real time on the PC through the Z-ScnsorMonitor software. The system improves the real-time and reliability of data, and reduces the cost of environmental monitoring
Introduction
Wireless Sensor Network (Wireless Sensor Network, WSN), as a short network and perception extension layer of the Internet of Things, has been widely used in automotive electronics, industrial control, home automation, and environmental monitoring. However, existing environmental monitoring systems often have shortcomings such as short communication distance, small coverage, low data accuracy, and bulky equipment. At the same time, since most of the monitoring points are in unattended places such as the field, computer rooms, and corporate sewage points, it is necessary for staff to regularly check the operation status of the equipment and maintain them on site, so the real-time data and the timeliness of troubleshooting cannot be obtained. Guarantee. In view of this, this article designed a distributed sensor network (DSN) platform based on ZigBee technology, using distributed collection, centralized management strategy, and collecting environmental temperature and humidity information as an example, to achieve remote real-time temperature and humidity accuracy collection.
1 The overall structure and function of the system
The system adopts the modular design idea. According to the wireless sensor network system architecture, three types of functional units are defined: sensor nodes, aggregation nodes (coordinators and routers) and management nodes. The overall system structure is shown in Figure 1. Sensor nodes are distributed in different locations according to monitoring needs, and have the characteristics of small, mobile and adaptive. The wireless transmission network is responsible for real-time transmission, routing, relay, and aggregation of collected data, including ZigBee wireless sensor network and GSM mobile communication network. The management node can use mobile phones, PDAs, embedded processors or PCs, etc. Here, PCs are used to receive monitoring point information, and provide man-machine interactive operation interfaces to realize real-time display and storage of environmental data; mobile terminals are used to realize remote monitoring and Call the police.
2 System hardware circuit design
2.1 Wireless transmission unit
The wireless transmission unit is a system design, using the CC2530 chip as the system's MCU. It is the second-generation system-on-chip chip supported by the ZigBee/IEEE 802.15.4 protocol launched by TI for the 2.4GHz ISM frequency band. CC2530 integrates an enhanced 8051 core, 8-channel input 12-bit ADC and watchdog timer, etc., so a simple ZigBee node can be constructed with very few peripheral circuits. Among them, the necessary peripheral circuits include crystal oscillator circuit, power supply circuit, reset circuit, wireless transceiver circuit and so on. Because the technology is relatively mature, I won't repeat it here, you can refer to the references.
In order to ensure the transmission quality of the network and expand the coverage area of the network, TI’s cost-effective, highly integrated 2.4 GHz radio frequency front-end CC2591 is selected. It is suitable for low-power, low-voltage wireless transmission systems. The output power of the integrated power amplifier (PA) in CC2591 can reach +22dBm, which ensures the high-power output of the signal; at the same time, it also integrates a low noise amplifier (LNA) with a receiving sensitivity of 6 dB. Based on the above characteristics, the ZigBee node using the CC2591 radio frequency front end can reach a transmission distance of 500-800m under barrier-free conditions, which is more than 10 times the original distance, and the network coverage area is greatly enhanced. The hardware connection diagram of CC2530 chip and CC2591 radio frequency front end is shown as in Fig. 2.
Use the 4 digital pins PAEN, EN, HGM, RXTX of CC2591 to control the state of the chip. When receiving a signal, when HGM=1, the high gain mode is used, and the gain is 11dB; when HGM=0, the low gain mode is used, and the gain is 1 dB; when the signal is transmitted, the signal is amplified regardless of whether the HGM is 1 or 0 or floating. In addition, the RF_P and RF_N pins of CC2591 must be connected to the RF_P and RF_N of CC2530 to ensure that RF_P and RF_N can output positive/negative RF signals from the power amplifier during transmission, and can input positive/negative RF signals during reception. Low noise amplifier.
2.2 Data acquisition unit
Traditional temperature and humidity collection often uses a combination of temperature sensor DS18B20 and humidity sensor HS1101, which has disadvantages such as complex data fusion algorithms and low accuracy. The use of a new digital temperature and humidity sensor SHT75 based on CMOSens technology not only improves the accuracy of data collection, but also ensures the long-term stability of the system. Its relative humidity measurement accuracy is ±1.8%RH, and the temperature measurement accuracy at 25℃ can reach ±0.3℃, so it is especially suitable for accurate collection of temperature and humidity in special environments.
S
HT75 adopts 4-pin single row in-line package, the power supply range is 2.4 ~ 5.5 V, the temperature and humidity acquisition circuit is shown in Figure 3. The DATA pin is a bidirectional serial data receiving and sending pin, which can be connected to any GPIO of CC2530 for data communication. Here it is connected to pin P0_3. In addition, in order to avoid signal conflicts, CC2530 should use low level to drive DATA pin, so a 10 kΩ pull-up resistor is connected. When CC2530 outputs low level, the signal is pulled to high level to drive DATA pin. SCK is the serial clock input pin, which is connected to the P0_2 pin of CC2530 to realize synchronous communication and control the reading of temperature and humidity data.
In view of the expandable parts of the CC2530 system, each sensor node can connect 1 to 3 sensors. At the same time, in order to facilitate the data transmission of CC2530 and GPIO, all ZigBee node applications must ensure multiple data links, and two peer ZigBee nodes use the same wireless channel to create virtual links with multiple interfaces to reduce The cost of the system.
2.3 Alarm unit
The system's alarm unit adopts a combination of sound and light alarm and remote SMS alarm to ensure timely and accurate alarms without missing alarms.
For the audible alarm circuit, in view of the adjustable frequency of the passive buzzer, the system adopts the passive buzzer to realize the differential alarm of temperature and humidity. Because the I/ O pin current of CC2530 is only 20 mA, and the drive capability is limited, a PNP-type transistor 8550 is used to amplify the current to drive the buzzer. When the temperature and humidity exceed the safety threshold, the drive square waves of different frequencies are output through a specific program to send out different alarm signals. The light alarm circuit can be realized by using ordinary light-emitting diodes. Its anode is connected to a 3.3 V power supply through a current-limiting resistor to ensure that the sink current does not exceed the allowable value of the MCU. The cathode can be directly connected to the GPIO of CC2530. The sound and light alarm circuit is shown in Figure 4. The two cooperate with each other to better realize the difference alarm of temperature and humidity.
In addition, in order to realize the remote monitoring and alarm of the system, a GSM SMS alarm unit is added to the coordinator node. The TC35i module from Siemens Germany is selected, which can support Chinese text messages and work in GSM 900MHz and GSM 1800 MHz dual frequency bands; the module is mainly composed of GSM baseband processor, GSM RF module, power supply module, flash memory, ZIF connector, and antenna interface. composition. Its data input/output interface is actually a serial asynchronous transceiver. Its 18-pin RXD and 19-pin TXD are both TTL-level serial communication pins, which can be connected to the GPIO of CC2530 to realize serial data transmission. Send and receive. When in use, you only need to send AT commands through CC2530 to control TC35i for SMS alarm.
3 System software design
3.1 Data acquisition program
The internal front end of SHT75 is integrated with I2C bus, so the data acquisition program needs to be completely in accordance with the communication protocol of I2C bus, that is, CC2530 acquisition instructions and receiving instructions should be written in accordance with the timing of SHT75. The temperature measurement command sent by CC2530 to SHT75 is 00000011, the humidity measurement command is 00000101, and all data starts from the MSB. After the measurement and communication are over, SHT75 automatically switches to sleep mode.
The temperature and humidity data collected by the sensor can be displayed on the PC through the serial port debugging assistant SComAssistant to collect data for SHT75. It can be seen that the relative humidity of the current environment ranges from 49.5 to 50.1% RH, and the temperature is from 25.4 to 25.7°C. The data is stable and reliable, with controllable errors, and accurate collection of temperature and humidity information can be completed.
3.2 ZigBee-WSN software design
The establishment and operation of the ZigBee network is the key to the entire wireless sensor network system, which is related to the reliability of the data and the stability of the system. The workflow of the whole system is shown in Figure 6.
After the system is powered on, first perform hardware initialization and network initialization. CC2530 adopts ZigBee2007 protocol stack. The initialization of the protocol stack can be completed by Z-Stack provided by TI. Z-Stack is a rotating query operating system that can complete most functions such as hardware initialization and network initialization. The establishment of the ZigBee network is actually realized by the "binding" between the coordinator and its child nodes. First, the coordinator establishes the network through the network layer function NLME_NetworkFormationRequest(), and enters the allowed binding mode through the zb_AllowBind() function. After the child node sends out the binding request zb_BindDevice(), the coordinator establishes the binding table and responds to the binding request. The successful binding means that the communication is established. When other nodes join the network, perform the same steps, and continuously update the binding table. The binding table contains the 16-bit network address, 64-bit IEEE address and port number of the node. The network address is used for routing mechanism and data transmission, and the IEEE address is the identification of the node.
After the system is initialized, the front node starts to collect data. The data will be displayed in real time on the PC through the wireless network transmission and aggregation, and the acousto-optic alarm and SMS alarm can be performed after the threshold value is compared.
3.3 Management node software
The management node chooses the Z-SensorMonitor software provided by TI, which can visually display the network topology and the status information of each node. In addition, Z-SensorMonitor provides data storage and recovery functions, and can output hexadecimal data to the suffix. In the log text, a timestamp is added to facilitate future review and reproduction of the system status. Therefore, Z-SensorMonitor can display the temperature and humidity of each monitoring point and the operating status of the entire network in real time. Figure 8 shows the real-time network status information collected during the experiment.
Conclusion
Through the functional test of the wireless sensor network system, it is found that the SHT75 sensor node can accurately collect the temperature and humidity information of the monitoring point, and the data conforms to the actual situation of the monitoring point. After ZigBee wireless sensor network and GSM mobile communication network are transmitted, the data is stable and reliable, and it meets the requirements of long-distance, large-scale real-time temperature and humidity accurate collection.