Design of greenhouse temperature and humidity monitoring and alarm system based on zigbee
[Copy link]
Wireless sensor networks involve a variety of cutting-edge research areas, including sensor technology, wireless communication technology, and distributed signal processing technology. It uses integrated micro-sensors to complete real-time monitoring and collection of information about the environment or detection objects, and transmits the detected information to the host computer in a self-organizing wireless multi-hop network and displays it to the user. Since the emergence of wireless sensor networks, we have integrated the information world and the physical world, changed the way people interact with machines and people with nature, and then realized the connection between the physical world, the computing world, and human society, making humans more capable of understanding the world.
As early as the end of the century, the research on greenhouse monitoring systems began. At that time, the detection was very simple, and it was measured at a single point through some instruments and meters, and then recorded. Later, with the rapid development of sensor technology and single-chip microcomputer technology, the research on greenhouse environment monitoring technology also developed. It was not until the beginning of the 1980s that the introduction of computers and bus technology made the greenhouse system begin to move towards automation. With the vigorous development of software technology, expert systems emerged, and greenhouse monitoring gradually developed towards intelligence. However, there is still a big problem, that is, wiring is difficult and wiring is complicated. But this problem was quickly solved, which depends entirely on the rapid development of wireless communication technology. In foreign countries, wireless technology was first applied to agricultural production, including greenhouse monitoring and control systems, avoiding some problems caused by wired transmission, such as low system test accuracy, poor anti-interference ability, unstable operation, etc.
With the progress of society and the needs of production development, the traditional use of analog instruments for single-point temperature and humidity measurement can no longer meet our needs, so the use of wireless communication to collect temperature and humidity data is very important, and the accuracy of measurement has also been valued by society. The advantages and mature development of wireless sensor networks will surely be the development direction of greenhouse measurement and control systems.
In industrial sites, due to the harsh environment, workers cannot stay on site for a long time to observe the operation of equipment, so they need to collect data and transmit data to the control room, so that workers can send control commands according to the situation. However, there are two ways of data transmission, wired transmission and wireless transmission. Traditional wired data transmission requires many cables and complex wiring. When problems occur, it is difficult to change the line and difficult to repair, and it wastes resources and occupies a large space. The above problems can be avoided by using wireless transmission.
Since the greenhouse occupies a large area, the workload is large and the reliability is poor; the detection targets are also relatively scattered and there are many measurement points,
so the traditional method can no longer meet the needs of current agricultural development. As science and technology advances at a rapid pace,
the development of wireless communication technology has made greenhouse measurement and collection more accurate and easier.
1.2 Design goals
This design selected two important environmental parameters, temperature and humidity, of the greenhouse as the data source for sensor collection. The sensor nodes collect data in real time, and the temperature and humidity data are wirelessly transmitted through the radio frequency module. A wireless network is established based on the protocol to achieve longer-distance data transmission. The network coordinator then transmits the processed data to the host computer and displays it on the computer for staff to observe and process in a timely manner.
Chapter 2 System Overall Design
2.1 Overall design of the scheme
Figure 2-1 Overall design diagram of temperature and humidity detection
Basic design plan: The main content of this design is
the realization of a low-power, low-cost, convenient and simple temperature and humidity detection system based on the protocol, so that farmers can formulate production strategies to protect crop growth and increase yields.
The main contents of the study are the following six aspects:
Understand the working principles of the three logical device terminal nodes, routers, and coordinators, and propose an overall plan for the detection system.
Deeply understand the principles of sensor node circuits, and select appropriate devices to complete the design of sensor node circuits according to the requirements of actual applications, including the design of battery panels and radio frequency boards and anti-interference, and the external connection of temperature and humidity sensors. Propose a set of feasible solutions for detecting temperature and humidity, and reasonably layout sensor nodes to achieve temperature and humidity measurement in different locations. In terms of hardware support, deeply understand the protocol stack, the role of each layer, and the serial port communication program design of the coordinator and the computer. Network and debug the sensor nodes, router nodes, and coordinators, and the sensor nodes realize temperature and humidity detection, and transmit them to the computer interface through routers and coordinators for display. When the transmission power of the node is , and the distance between the node and the adjacent node is less than meters, the data packet loss rate is kept within, and the effective working time of three dry batteries is more than months. The design of our temperature and humidity detection system needs to take into account the minimum cost, that is, try to find cheap, practical and stable hardware chips as nodes. In terms of software design, the algorithm should be as simple as possible and optimized. In order to minimize energy consumption during data transmission, the energy-saving routing algorithm is mainly considered. The hardware work mainly involves the design of data acquisition node circuits, coordinator circuits and related interface circuits. The software
work includes the development of temperature measurement programs based on the main control chip, the development of network algorithms and drivers for wireless transceiver chips, and the development of applications for wireless communication systems, including data acquisition, data transmission, data processing and display. And on this basis, the protocol stack is transplanted.
Innovation: Wired transmission is used for communication and networking, which results in high system complexity, low system reliability and flexibility. However, applying such a short-distance, low-speed, low-cost and low-power wireless communication networking technology to the temperature and humidity measurement system has achieved automation and informatization, effectively reduced the work pressure of the staff, and improved work efficiency. It is a good attempt for the widespread application of wireless sensor networks in the future.
2.2 Introduction to ZigBee Technology
After bees discover a flower bush, they will use a special body language to inform their companions of the location of the newly discovered food source and other information. This body language is the ZigZag dance, which is a simple way for bees to convey information. ZigBee is named as a new generation of wireless communication technology for this reason. Before this, ZigBee was also called "HomeRF Lite", "RF-EasyLink" or "fireFly" radio technology, collectively referred to as ZigBee.
Simply put, ZigBee is a highly reliable wireless data transmission network, similar to CDMA and GSM networks. ZigBee data transmission modules are similar to mobile network bases*. The communication distance ranges from the standard 75m to hundreds of meters and kilometers, and supports unlimited expansion.
ZigBee is a wireless data transmission network platform composed of up to 65,000 wireless data transmission modules. Within the entire network range, each ZigBee network data transmission module can communicate with each other, and the distance between each network node can be infinitely expanded from the standard 75m.
Unlike the CDMA network or GSM network of mobile communication, the ZigBee network is mainly established for industrial field automation control data transmission. Therefore, it must be simple, easy to use, reliable and low-priced. The mobile communication network is mainly established for voice communication. The value of each base is generally more than one million yuan, while each ZigBee "base" is less than 1,000 yuan. Each ZigBee network node can not only be used as a monitoring object, such as the sensor connected to it directly collects and monitors data, but also automatically transfers data from other network nodes. In addition, each ZigBee network node (FFD) can also wirelessly connect to multiple isolated sub-nodes (RFD) that do not undertake the task of network information transfer within the range of its own signal coverage.
2.3 Introduction to Sensors
The DHT11 digital temperature and humidity sensor is a temperature and humidity composite sensor with calibrated digital signal output. It uses dedicated digital module acquisition technology and temperature and humidity sensing technology to ensure that the product has extremely high reliability and excellent long-term stability. The sensor includes a resistive humidity sensor and an NTC temperature sensor, and is connected to a high-performance 8-bit microcontroller. Therefore, the product has the advantages of excellent quality, ultra-fast response, strong anti-interference ability, and extremely high cost performance. Each DHT11 sensor is calibrated in an extremely accurate humidity calibration room. The calibration coefficients are stored in the OTP memory in the form of a program, and these calibration coefficients are called in the sensor during the model detection process. The single-wire serial interface makes system integration simple and fast. The ultra-small size and extremely low power consumption make it the best choice for applications and even the most demanding applications. The product is a 4-pin single-row pin package for easy connection. Accuracy humidity +-5%RH, temperature +-2℃, range humidity 20-90%RH, temperature 0~50℃.
Chapter 3 System Hardware and Software Design 3.1 Hardware Circuit Design
Several terminals receive temperature and humidity and display them on the coordinator. If the temperature and humidity exceed the setting, the light will turn on and the words "too high" will be displayed.
Experimental schematic diagram:
The main control chip of the RF board is CC2530, so the control circuit diagram is as shown in the figure
The alarm phenomenon is observed by the flashing of the LED
PCB design
3.2 Software Programming
Main program flow chart
(The introduction of each sub-function flow chart can be divided into subsections.)
1. Temperature and humidity calculation: The temperature and humidity values can be calculated. The calculation method is given below:
temp (temperature) = byte2. bytel = 28.00 (℃)
humi(humidity)=byte4 .byte3=62.00 ( } RH)
Verify: byte1+ byte2+ byte3+ byte4 = 01011010=90 (= temperature + humidity) (verification is correct)
2. Coordinator establishes network flow chart
3. Complete initialization
Then it initiates the network through primitives. It has the power to reject and allow nodes to join the network, and then sends the data of each node to the
After the data is collected and summarized, it is sent to the host computer for display. The coordinator initiates the network by the function Void ZDO Network For
mation(byte LogicalType,devStartModes_ t StartMode,byte BeaconOrder,byte SuperframeOr
der) to build a wireless network. The meaning of the function parameters are as follows:
Logical path is of Byte type, representing the type of the device. StartMode is of Struct type, MOD
E HARD applies to build a new network, MODE_ OIN applies to join the network, MODE_ RESUME rebuilds the network,
MODE_REJOIN rejoins the network. BeaconOrder is of Byte type and is the information of the ZigBee network to be established.
The sequence number, SuperframeOrder is also a Byte type, which is the superframe signal of the ZigBee network to be established.
When the coordinator is powered on, its application layer initiates the process of establishing a new network by sending the primitive NLME NETWORK-FORMATION.request. After receiving the request, the network layer also sends the primitive NLME-SCAN.request to request the MAC layer to perform energy scan on the channel. The MAC layer reports the scanned available channels to the network layer through NLME_ SCAN.confirm. The network layer then sends NLME-SCAN.request to search for other unused or least used channels in the available channels. The MAC layer reports the search results to the network layer. If no available channels are found, it means that the establishment of the new network has failed; if available channels are found, the coordinator determines a PAN ID and a 16-bit network address. If the PAN ID is specified in the NLME_ETWORK_DISCOVERY request primitive and does not conflict with the original one, the specified PAN ID is used. Otherwise, a randomly selected one is used, but the PAN ID is required to be in the range of 0x0000^-0x3FFF. The network address of the coordinator is generally 0x0000. Afterwards, the network layer sends MLME-SET.request to notify the MAC layer to set these parameters. After receiving the confirmation from MAC, NWK sends MLME-START.request primitive to start the establishment of a new network. After the new network is established, it sends NLMEes NETWORKse FORMATION.confirm primitive to notify the application layer of the final result.
Main code:
Chapter 4 System Debugging and Conclusion
6.1 Preparation
First, we need to eliminate various hardware problems, such as poor contact, short circuit, unstable power supply, etc., and then start the power-on test. Since we are in the experimental stage, we first select a small number of nodes for testing. The hardware used in our test includes:
a computer, an emulator, two terminal nodes (RFD), and a coordinator ((FFD)o
After the ZigBee protocol stack is transplanted, after writing and modifying some software, the program is downloaded to the coordinator
and terminal nodes respectively. The software used for our test is IAR embedded integrated development environment.
In the test, the network topology type selects a star network, the two terminal nodes are powered by three 1.5V batteries, and the coordinator is powered by USB and connected to the computer through the serial port. Since the current laptop does not have a 9-pin serial port, we use USB to serial port to communicate with the computer.
At this time, we need to perform stability and security tests on the terminal nodes and coordinators.
1) Stability test
Set the power mode of the terminal node to full functional mode (CPMO). The coordinator does not have a sleep mode, so it does not need to be set. Run for more than 48 hours, check whether each module is operating normally, whether the voltage is within the normal range, and whether the LCD is clear and visible without flickering.
2) Safety test
Check various interfaces to ensure that there is no short circuit. After running the program for a long time, check the chip temperature and working voltage to prevent burning. After the hardware test is completed, we test whether the sensor collects temperature and humidity normally, and use the serial port debugging assistant to test the communication of the 9-pin serial port.
4.2 Network test
After the hardware test is normal and all parts are tested normally, we start the network test.
1) Configure sensor nodes
After porting the Z-Stack protocol stack, use IAR integrated development software to open the network test program, select SensorBB, select Project->Rebuild All to compile, and after the compilation is completely passed, connect the PC, emulator and target board Q2530BB, press the Reset button of the emulator, and the emulator indicator should be normal at this time. Click the Debug button to download. When the download progress bar disappears and the debug window appears in the upper left corner, click to exit the debug state, unplug the DEBUG line, restart the target board power or press the Reset button of the target board. At this time, LED 1 and LED2 flash slowly, and the target has been set as the terminal sensor node.
2) Configure the coordinator node
Select CollectorEB, select Project->Rebuild All to compile, and after the compilation is completely passed, connect the PC, emulator
and target board Q2530EB, press the Reset button of the emulator, and the emulator indicator should be normal at this time. Click Debug to download. When the download progress bar disappears, the debug window appears in the upper left corner, click the full-speed run button, and the target board LED 1 and LED2 flash at the same time. At this time, the LCD screen displays the IEEE address of the current node.
(1) If you exit the debugging state, unplug the debug line, restart the target board power, and press the reset button, the target board has been set as a network router node.
(2) If you press the UP button of U3 at this time, LED 1 /LED3 will be on and LED2 will flash. Click to exit the debugging state, unplug the debug line on the target board, restart the target board power or press the reset button of the target board. At this time, LED 1 /LED3 will be on and LED2 will flash. The target board has been set as a network coordinator node. Turn off the power of all nodes in the network, connect the serial port of the coordinator to the computer, open the ZigBee protocol analysis software, select COM1 port, the baud rate is 9600, and turn on the coordinator power. In this way, the ZigBee network is established. First, observe the time it takes for the two nodes to join the network. The time it takes for sensor1 to join the network is 2.5 seconds, and the time it takes for sensor2 to join the network is 2 seconds. After the terminal node is bound, it will automatically collect temperature and humidity data, and transmit the collected data to the coordinator through the ZigBee protocol. Then the coordinator transmits the data to the host computer interface through the serial communication protocol for display.
Chapter 5 Summary and Outlook
5.1 Summary
The wireless temperature and humidity monitoring network designed in this paper is a short-distance, low-power wireless communication network based on the ZigBee protocol, which is generally used in greenhouses, gardens, etc. In view of the most suitable temperature and humidity required for the growth of crops, we use the composite digital temperature and humidity sensor DHT 11 to measure temperature and humidity, and together with the CC2530 chip, it forms a sensor node for collecting temperature and humidity. This node has low power consumption, low cost, and stable data transmission. Another major feature is the use of the ZigBee protocol stack to build a wireless sensor network, so that temperature and humidity data can be transmitted wirelessly. Finally, the interface display of the host computer is designed, which can display temperature and humidity data in real time. You can clearly know the temperature and humidity conditions in the greenhouse in the office, which greatly reduces the labor intensity of the staff.
With the improvement of people's living standards, greenhouses have experienced a transition from traditional manual detection using instruments to automatic detection using wireless networks, and are gradually developing towards intelligence.
The focus of this paper is on the networking research of the ZigBee protocol stack. The ZigBee protocol is a protocol based on the IEEE802.15.4 standard and adopts a layered architecture. In the ZigBee protocol stack, the development-based programs are mainly concentrated in the network layer and the application layer. The ZigBee protocol stack implements the system communication function based on the primitive question-and-answer method. For the hardware design, the SOC solution is used, and the circuit diagram of some development boards is referred to, which makes the entire hardware design process less complicated and reduces the development cycle.
|