System Design of Online Monitoring and Controlling System Based on Zigbee in Greenhouse

. To solve the problem that online monitoring and controlling system in greenhouse, a wireless monitoring and controlling system which based on ZigBee has been proposed in this paper. The system consist data acquisition module and data gathering module. The data acquisition module adapted DHT11 as the temperature and humidity sensor, it monitor the information of temperature and humidity and transmit the information to the data gathering module by wireless RF Module CC2530, the data acquisition module is powered by solar battery. It realized wireless monitoring and easy to maintain. When received the monitoring results, the data gathering module will take logical judgment and realize automatic controlling of the temperature and humidity. The wireless monitoring and controlling network was connected by star topology, it adapted the ZigBee protocol. The network has the function of self-organize and self-adaptive. The result has shown that the system is more suitable for greenhouse monitoring and controlling. The paper has constructed star self-organization network based on ZigBee, the developed system can solve the technical problems of transmission of remote data, and also avoid the drawbacks of installing a large number of sensors and terminal equipments. The system meets the requirements of multi-point, multi-factor, mobility and convenience in environmental monitoring. Finally, the experimental results show that the network can achieve good self-organization, scalability, stability, performance systems built for wireless monitoring and control of temperature and humidity in greenhouse-site needs. The working performance of the system built is stable, suitable for wireless monitoring and control of temperature and humidity in greenhouse-site.


Introduction
In China, the greenhouse occupies an important position in vegetable production, quality and yield of vegetable is closely related to the temperature and humidity [1].
With the development of computer network and wireless sensor technology, wireless sensor network technology has played a revolutionary role in the data acquisition process [2]. It's difficult to lay the wires which have interference when we transmit information in long-distance. This traditional way brings a lot of inconvenience to the practical application [1]. In addition, the traditional measurement ways commonly adopt thermocouples, thermistors, temperature sensors and humidity sensors, which are susceptible to the sites of measurement and environmental restrictions. However, it will degrade performance of measurement system in long-term, and the inspecting and replacing the cable transmission regularly is indispensable in traditional ways. To sum up, it's inconvenient to update and maintain the system with the traditional methods on account of many shortcomings, for instance, the difficult mobility, the weak anti-interference, the inaccuracy of measurement and so on [3].
In view of the current situation lacking of effective means of online measurement and control in greenhouse, difficulties of monitoring and wiring and other issues, respectively from the collection of environmental information, wireless transmission and intelligent control, this paper designed and developed temperature and humidity acquisition module combining DHT11 and 8051, and developed wireless transceiver module based CC2530 to achieve a temperature and humidity information. In addition, the LCDs adopted in system display data in real-time and the actuators achieve the control of environment in greenhouse. All of them are for purpose of satisfing the environmental requirements in the greenhouse. The ZigBee technology can transmit the remote data and read each greenhouse's data to be unattended in a real application. The monitoring system has lower power, lower cost and larger network capacity compared with traditional wireless technology.

The Overall Structure of System
The ZigBee network supports star, tree and mesh, this paper adopts star including a coordinator node and three temperature and humidity acquisition terminal nodes. The overall structure is simple and the cost is very low, the system is easy to transplant and maintain. In a star network [4], all nodes can only communicate with the coordinator, the communication between each other is prohibitive. This system includes a coordinator node and three temperature and humidity acquisition terminal nodes, the hardware components of coordinator node includes microcontroller AT89S51, LCD 1602, ZigBee module (coordinator), 5V DC power supply. The acquisition terminal node includes temperature and humidity sensor, microcontroller AT89S51, 1602 LCD display, ZigBee module (terminal node), 5V DC power supply. Figure 1 is a star network.
(1) Acquisition node: It collects the real-time temperature and humidity data, display on the LCD screen and transmit wirelessly to the coordinator node through the ZigBee.
(2) Coordinator node: It receives temperature and humidity data from the acquisition nodes through ZigBee, displays which on the LCD 1602 every 30 seconds depending on the needs in the different season and real-time parameters through man-machine interface [5]. You can set upper and lower parameters of temperature and humidity via touching screen. If data exceeds the predesigned threshold, four different alarm lamps will be lit up by micro-controller, and the relays open related device which can change the temperature and humidity, such as the humidifiers, fans, sprayers and heating.

The Overall Structure of the System
The ZigBee [6][7][8] wireless sensor network consists of three terminal nodes and a coordinator node. The coordinator is the core of the sensor network because it is responsible for establishing, connecting, joinning and exiting network. In addition, it can assign network address for terminal nodes. The terminal nodes deployed in the monitoring area collect the information which is sended to the collected temperature and humidity data regularly to coordinator [3]. If finished, the terminal equipments enter into dormancy after receiving the coordinator's response. This method can ensure power consumption is ultra-low. The coordinator node is Full Function Device (FFD), and the terminal equipments are Reduced Function Device (RFD) [9]. A wireless sensor node contains the data acquisition module, data processing module, wireless transceiver module and power supply module, the node structure is shown in Figure3. Data acquisition module is responsible for collecting temperature and humidity data adopting a digital sensor DHT11, the data signal is amplified and transmitted to the processing module via the port P1_1. The data processing module uses CC2530 chip as micro-controller converting analog signals into digital signals. The wireless transceiver module is responsible for communicating with other sensor nodes, the power supply module provides energy [1] [9] for the other three modules.

) Temperature and Humidity Sensor Node
The DHT11 is a composite temperature and humidity sensor containing digital output calibration table. The sensor uses these calibration coefficients stored in OTP (One Time Programmable) memory in the process of detecting signals, with this method, it has high reliability and excellent long-term stability. Because the sensor consists of a NTC (Negative Temperature Coefficient) temperature sensor and a resistance element sensitive to humidity, it measures the temperature and humidity accurately at the same time. More importantly, the transmission distance is up to 20 meters with ultra-small size and low power consumption. To sum up, the sensor has many excellent qualities, such as the power consumption, the quick responsiveness and strong anti-interference. It's the best option for applications in greenhouse. The DHT11 is connected to an 8 bit micro-controller with high performance. It is a four-wire package transmitting temperature and humidity signals to CC2530's P1_1 port via data line DATA.

(2) LCD Screen
The LCD 1602 displays letters, numbers, symbols and other dot matrix. LCD 1602 means the displayed content is 16*2, that's to say, it can display two lines and 16 characters each line. The first line shows the temperature and the second line shows the humidity. The LCD displays the data post-processed by the microcontroller, the CC2530's port P0, P2_0, P2_1, P2_2 connect with data ports of LCD 1602, port P1_0, P0_7, P0_6 are respectively connect with RS, R/W, E of the 1602 modules.

(3) CC2530 Processing Module
The CC2530 is an IEEE 802.15.4 on-chip system that integrates an enhanced 8051 kernel, so it's easy to set up their wireless communications network combined with TI Z-STACK protocol stack. The internal configuration includes: enhanced 8051 CPU, programmable 256 kb flash memory, 8 kb RAM, a 16-bit timer, an 8-bit timer, an IEEE 802.5.4 MAC timer, a watch dog timer, a AES security coprocessor, a 5-channel DMA and 2 USART. The CC2530 support a variety of serial communication protocols with high stability, low power consumption, less peripheral devices and so on [10]. In addition, The CC2530 has different operating modes, and the transition time between modes is very short, so it can ensure low energy consumption [11]. The application of CC2530 circuit is shown in figure 6.

(4) Energy Supply Module
The temperature and humidity monitoring nodes are used in agricultural greenhouse where environment is relatively poor, but battery-powered nodes can be changed frequently, integrating the above two points, the greenhouse requires the batteries with high-performance, large-capacity, long life and maintenance-free. Without any low-power measures, 2 ordinary battery can work for acquisition node over one day [12], and ZigBee wireless transceiver can control data sampling interval and take other low-power measures. Judging from the experimental results, 2 batteries can insure acquisition node working for more than one week, so the energy module reduces energy consumption significantly and farmers' production costs.

Hardware Design of Coordinator Node
Compared with the sensor node, the coordinator does not have a sensor module but increases the alarm module and relay module, The LCD displays temperature and humidity data of the three sensor nodes alternately at intervals of 10 s, the SCM (Single Chip Micyoco) triggers the corresponding relay when the alarm module lit the different LEDs. According to the actual situation of the greenhouse, the actuators connected with the relays can adjust the temperature and humidity in the greenhouse effectively.

Fig. 7. Principle diagram of relay driver
As shown above, if the P1_6 pin is high, the triode will break over. Then the power supply applied to the relay coil make the normally open contact of relay closed. This equate to closing switch and triggering the related motors. On the contrary, if the output of P1_6 pin is low, the triode will cut off and there is no potential difference between the relay coils. It means the normally open contact of relay is released, it equate to switch off.
Alarm module use SCM to drive four LED lights L1, L2, L3 and L4. When the greenhouse temperature exceeds a preset maximum temperature lit L1, when the minimum temperature is lower than a preset minimum temperature lit L2, when the humidity is higher than the preset maximum humidity lit L3, when the humidity is lower than the preset minimum humidity lit L4.

Design of System Software
The CC2530 chip is the core of ZigBee and built-in ZigBee protocol stack, we can develop software on the application layer reducing the difficulty of programming, so we can shorten the development period of the system. The programming environment of CC2530 is the IAR embedded workbench [13]. The temperature and humidity Fig. 9. Program flow chart acquisition system includes temperature and humidity data acquisition, data display, wireless data transmission and control. The system of coordinator includes wireless data receiving, results display and alarm relay. The total program flow chart is shown in figure 9. At first, the terminal node initializes the LCD 1602 and keeps in a dormant state. When the coordinator had a request, it reads and displays the data collected by sensor. Secondly, the coordinator shows the data received by terminal nodes. Finally, the coordinator starts to analyze and judge whether reaching the limit of temperature and humidity, if the data excess the preset value, the system triggers the executor.

Software Design of Temperature and Humidity Data Acquisition System
The sensor node is responsible for collecting and transmitting temperature and humidity data, and receiving the control command. Firstly, initialize the system and network configuration after opening the node, then scan effective network channel actively to find a suitable parent node. Finally, the node joins the network created by the coordinator through association. In the absence of data request, the sensor node is in a sleep state [1,14]. Onc have a data request, the sensor node enters working state immediately to parse and response to the data request. That's to say, when during the period of dormancy, if there is an external interrupt or timer interrupt, the node will be restored to working condition and begin to perform the task.

Fig. 10. Flow chart of acquisition node
Because the DHT11 is equipped with a standard interface without an external A/D converter, it is easy to control and implement. The flow chart of acquisition node is shown in figure 10.

Software Design of Coordinator Node
The purpose of network coordinator is to establish and manage a wireless network, transfer the data to LCD through the serial ports. Firstly, the coordinator establishes a wireless LAN. Secondly, scan a channel for receiving a new node to join, which is assigned to a specific address, it's called the binding between the nodes. Finally, the coordinator initializes the LCD and trigger, if acquisition node sends data successfully the coordinator will reset the serial port.The coordinator program flow chart is shown in figure 11.

Fig. 11. Flow chart of coordinator program
After the coordinator receives temperature and humidity data from acquisition sensor nodes, the information takes turns to show data every 10 s in LCD1602. The coordinator analyzes and judges whether the number is over the acquisition nodes, and then executes a subroutine to judge whether reaching the limit of temperature and humidity, if reaching the limit, the system will trigger corresponding relay. The logic judgment flow chart is shown in figure 12.

Results and Conclusion
The wireless sensor network is composed of four nodes which contain a coordinator and three terminal nodes. In addition, the four nodes constitute a star network and the distance between nodes is about 70 m. Turnning the power on and seting the baud rate to 38400, the coordinator starts to send broadcast information and distribute address for terminal nodes. And the network address is respectively 0x0035, 0x0036 and 0x0037, showing that the system has completed the binding. Then the coordinator sends temperature and humidity acquisition command. The terminal nodes respond command to collect and send the temperature and humidity data. When you remove a terminal node, the LCD corresponding to this terminal node displays 0. And if you join it again, the LCD starts to display the real temperature and humidity. So the system has a self-healing capability. During the experiment, we programed aim at ZigBee protocol to realize the three to one wireless communication between nodes, so we achieved the collection and control of temperature and humidity in greenhouse. In this paper, by using the technology of forming the network automatically between terminals and coordinator, we can achieve the data transmission of many to one and monitor the temperature and humidity of several greenhouses at the same time. Except for gathering environmental information, the coordinator is devoted to triggering alarm lamp and striking the corresponding relay when the parameter value exceeds the predetermined value. Therefore the coordinator can control temperature and humidity by controlling the motor drive. This system has several features: Firstly, terminal node adopts digital temperature and humidity sensor which has the features of high accuracy and good stability. Secondly, the SCM adopts CC2530, integrating RF-chip and microcontroller unit, which has the different operating modes to ensure low energy consumption with short conversion time. Thirdly, the wireless transceiver module adopts ZigBee wireless network technology to reduce the problems caused by wiring. Fourthly, the system has advantages of simple structure, easy to transplant and high accuracy to meet the modern intelligent management in agriculture.