0 Preface
With the ever-increasing contradiction between global water supply and demand, water-saving agriculture has become one of the world's most important issues of today. Countries all over the world have attached great importance to the development of water-saving agriculture. Israel, Japan, the United States and other countries have adopted advanced water-saving irrigation systems. Through the use of remote sensing and telemetry to monitor new technologies such as soil moisture content and crop growth, monitoring and forecasting water use in irrigation areas and realizing the dynamic management of water resources in irrigation areas have not only successfully increased agricultural production, but also saved a lot of irrigation water. In some parts of the country, a certain soil moisture monitoring system is also adopted. However, existing systems generally adopt the form of wired networking, and data transmission (such as RS232 protocol, RS485 protocol, etc.) is realized through an industrial bus. This type of networking has the disadvantages of wiring difficulties, long system installation and commissioning cycles, complicated use, and the need for routine maintenance by professionals, which seriously hinders its further promotion and application.
The Zigbee technology and the combination of modern sensor technology are proposed in this paper. At the same time, the monitoring of soil moisture content is achieved through wireless networking. Thus, a soil moisture monitoring system based on Zigbee is developed. In fact, the determination of soil moisture can be done in a simpler way. It can be directly measured by instruments such as a soil moisture monitor or a soil moisture temperature recorder. Simply by inserting the instrument into the soil, the moisture content of the soil at different depths can be measured. Of course, Zhejiang Top Instrument Co., Ltd. took into account the needs of customers in other areas, but also developed a multi-parameter instrument can be measured, such as soil moisture temperature tester, multi-point soil temperature and humidity recorder. In this system, the distribution of measurement and control nodes is installed in various parts of the irrigation area. Then, the collected data is transmitted to the central node using the WSN, and then the collected data is analyzed through the central node. Then, the status of the irrigation control system is controlled to achieve irrigation in the irrigation area. "Fine irrigation." Compared to the wired soil moisture monitoring system, the soil water monitoring system based on Zigbee has the following advantages:
(1) Wireless transmission is adopted, and the environmental constraints of the irrigation area are small;
(2) The system has micro power consumption characteristics;
(3) The cost of communication nodes is low;
(4) The network is easy to set up and fast;
(5) The network structure is flexible. It is self-organizing and can be dynamically routed and forwarded to achieve networked communication. When the monitoring scope is expanded, the network can automatically accommodate new nodes without the need for rigorous daily maintenance and management.
(6) Large network capacity and wide coverage;
(7) High safety;
(8) Short communication delay.
1 Zigbee Protocol Introduction
Zigbee is an emerging short-range, low-complexity, low-power, low-data-rate, low-cost wireless network technology. Mainly used for short-range wireless connection. The technology is based on the IEEE 802.15.4 standard and can coordinate with thousands of tiny sensors to enable communications. Zigbee (led by the Zigbee Alliance) Standards generally define the network layer, security layer, application layer, and profile of various application products; and the International Association for Electromechanical Engineering The IEEE 802.15.4 standard defines only the PHY Layer and Media Access Control Layer (MAC Layer). Zigbee has the characteristics of low data transmission rate, low power consumption, low cost, large network capacity, short delay, safety, small effective range, and flexible working frequency band. Its main application areas include industrial control, consumer electronics, automotive automation, home and building automation, and medical device control.
2 overall system design
Zigbee-based soil moisture monitoring system consists of a large number of monitoring and control nodes. These nodes form a WSN network through Zigbee technology. These nodes can be divided into a central node, an all-purpose node, and a terminal node according to their implemented functions. The central node is the center of the network. It is the originator of the entire WSN network and manages and maintains the entire network. The all-round node functions as a router in the network and controls the opening and closing of irrigation valves. The all-round node also has the ability to measure. The soil moisture content of the node can be measured. The terminal node is the end of the entire network. Compared with the all-round node and the central node, the terminal node only has the measurement function without the motor control circuit.
Under normal circumstances, according to the actual irrigation capacity of irrigation tools in the irrigation area, the irrigation area can be divided into several small irrigation blocks. These small irrigation blocks can usually be composed of a single all-energy node and several terminal nodes to form a small star network. Then, the all-energy node controls the water supply valve of the small irrigation block, and the terminal node is responsible for collecting the soil moisture content of each area of ​​the irrigation block. The all-round nodes, terminal nodes and the center are interconnected between each small irrigation block to form a WSN network. The network only functions as an all-round node for routing functions, which can ensure the reliability of network communication. After the network is set up successfully, the terminal node will collect the soil moisture data at regular intervals and upload the data directly to the central node. At the same time, the multi-hop function of the WSN network can also be used to transmit data to the upper-level all-round nodes, and then relay through several universal nodes. , The data is transmitted to the central node. After the central node analyzes the signal, it sends the analysis result to the all-round node of the small irrigation block, and controls the valve through the all-round node to adjust the amount of irrigation water. Zigbee-based soil moisture monitoring system diagram shown in Figure 1.
3 system hardware design
The hardware design of the wireless sensor network node is the basis of establishing the WSN network. The hardware design of the node mainly includes power supply, data transmission and processing, sensors, motor drive and other modules. The power module is mainly used to provide a reliable and stable power supply for the system, wherein the power supply modes of the universal power supply node and the terminal node are different, and the terminal nodes are distributed in the irrigation area. Therefore, the battery power supply is generally used. The all-round nodes generally need to be powered on continuously, and the power consumption is relatively large. Therefore, an irrigation pipeline control system can be used for power supply in design.
The second is the data transmission and processing module. The core control chip of this system selects Jnbee module JN5121 module that Jennic Company produces, this module integrates the control circuit and radio frequency circuit, and is compatible with 2.4GHz IEEE802.15.4. At the same time, a 51 core is also integrated inside. In addition, it has 96 KB of RAM and 64 KB of ROM, 4 12-bit ADCs, 2 11-bit DACs, 2 UART interfaces, 21 IO, and SPI and I2C bus interfaces. By calling the API function provided by the company, the module can be implemented
Operation, and can establish a wireless sensor network with a self-organizing, multi-hop dynamic routing mechanism. The sensor module is mainly responsible for connecting various types of sensors, including moisture sensors, temperature and humidity sensors. The motor drive module is mainly used to drive the motor of the external irrigation valve. With the motor drive system and the JN5121 module, the opening and closing of irrigation valves can be controlled in real time.
Figure 2 shows the hardware block diagram of the system node.
4 Formation of WSN Network Platform
4.1 Node Initialization and Networking Process
The software flow of various nodes in the WSN network is shown in Figure 3. The software differences between different nodes mainly lie in the initialization of the Zigbee protocol stack. Since the central node is the creator of the network, it must be started first in the entire WSN network. When the Zigbee protocol stack is initialized, the channel selection and the PAN ID can be completed in the function by calling the afmeAddSimpleDesc() function, thereby completing the network setup. The omnipotent node and the terminal node may initialize the Zigbee protocol stack by calling the afmeAddSimpleDesc() function to initialize the node to be networked into an all-round node or a terminal node, and then scan all available channels to find a network matching the PAN ID of itself. After scanning to the matching network, the to-go network node will send a network access request data frame to the central node.
After receiving the network entry confirmation signal returned by the center, it indicates that the node has successfully accessed the network.
4.2 Task Scheduling Mechanism of BOS System
The Basic Operating System (BOS) is a simple non-preemptive task scheduling system. Each task has the same priority level. Other tasks can only be called after a task has finished running. The operating flow of the BOS system is shown in Figure 4.
The BOS system can control the execution of Zigbee Task and DefaultUser Task, where Zigbee Task can be executed as a separate task and APS (Application Sub-layer) and ZDO (ZigbeeDevice Objects) are executed in the Zigbee Task. The DefaultUser Task is created when the BOS system is initialized. When the BOS system is initialized, up to two User Tasks can be defined. According to the needs of the function implementation, the application program can be defined in the Default User Task. Hardware Peripheral Event and MACSub-Layer are random events that can be handled in Optional Task in the form of interrupts.
4.3 Network Topology Management
After the network is deployed, the central node must establish a topology table and establish the parent-child relationship of a node. Topology discovery is divided into two phases. The first is backbone network discovery. In this phase, the central node sets its own network level to a zero-level node. Then all nodes in the broadcast domain of the central node send packets. The packet contains the type of the sending node. At the network level, when all nodes in the broadcast domain of the central node receive a packet sent by the central node, the terminal node will ignore the packet information, and the all-encompassing node will set its own network level to the network level in the packet plus 1, which is the first Level 1, then broadcast its own node type and network level as new discovery packets. When a node receives the broadcast packet of the i-th level node, it records the level of the node that sent the broadcast packet and sets its own level as (i+1). This process will continue until each all-powerful node in the network has a level. If the node has established its own level, it ignores other level discovery packets. The second stage is terminal node discovery. At this stage, each omnipotent node sends a packet to all its terminal nodes in its own broadcast area. After the terminal node receives the packet, it sets itself as an affiliate node of the omnipotent node, and sends its own network information to the omnipotent node. . After a terminal node establishes a subordinate level, the packets sent by other all-purpose nodes will be ignored. After completing the network discovery, all nodes will send their own node type and network level to the central node. In this way, the central node can establish a current network topology map. After that, when a new node joins the network, the central node can find the node in the network, update the topology table, and add nodes. When a node is deleted, the central node also updates the topology table and deletes the node.
4.4 Network Data Transmission
JN5121 module can use KVP and MSG two kinds of data packet format to transmit data. The system uses the data packet format MSG format, that is, through the afdeDataRequest () and JZA_u8AfMsgObject () two functions to achieve the data transmission between nodes, which afdeDataRequest ( The function is used to implement node data sending. JZA_u8AfMsgObject() is responsible for data receiving. The JZA_u8AfMsgObject() function belongs to the Zigbee Task task in the BOS system. Therefore, during BOS operation, the system will continuously query the task information. When new data is received, the system calls the JZA_u8AfMsgObject() function and parses and processes the data packet in the JZA_u8AfMsgObject() function.
5 System Power Control
The low-power design of the system node uses device low-power design and precise power management strategies. One of the devices' low-power designs is to select low-power devices and, when idle, put the device into a low-power or sleep mode by software. The precise power management strategy is to use the power supply selection method to control the power supply time of the equipment through the CPU. The system design is to use the device low-power design at the same time, according to the node needs to complete the function, to develop precise power management for the node. The system design terminal nodes for the timing acquisition method, which greatly shorten the working time of the terminal node, so that the terminal node is in low power or sleep mode most of the time, the working time of the terminal node battery of this system can be up to 12 months To 24 months. However, the omnipotent node must always be in working condition. Therefore, the power consumption of the omnipotent node relative to the terminal node is relatively high. Therefore, the circuit design of the omnipotent node should be simplified as much as possible, and the external control mode should be used to supply power to the irrigated control system.
6 system debugging
After the assembly of the soil moisture monitoring system based on Zigbee given in this paper was completed, the system was stable. The communication success rate of the Zigbee wireless communication system is 98.392%, and the accuracy of the soil moisture sensor can reach 1%. With a low-power design, the standby current at the termination node is approximately 17μA and the operating current is approximately 30mA. Within 24 hours a day, the node in this system collects data every 60 minutes. The collection time is 17 seconds (tested), the system works within 0.12 hours in 24 hours, standby time is 23.887 hours, and the theoretical power consumption is (0.113×30 + 0.017×23.887) 3.796mAH. For a normal 800mAH alkaline battery, its terminal node can continue to work for 7 months. The omnipotent node is powered by the irrigation control system in the irrigation area, which ensures that the omnipotent node continues to work throughout the day. In fact, the system's continuous operation time depends on many external factors such as: battery type, capacity, and application. In practical applications, the reasonable configuration of the working time of the terminal node can also increase the working time of the node.
7 Conclusion
This paper introduces the design and implementation of soil moisture monitoring system based on Zigbee JN5121 module and Zigbee. At the same time, it gives detailed solutions to the problems of node hardware design, network formation, data communication and low power consumption design of the system. , And successfully implemented the establishment of the WSN network. Experiments have shown that the Zigbee-based soil moisture monitoring system can greatly improve the ability to monitor soil moisture in agricultural soils. At the same time, the use of wireless data transmission methods also enhances the flexibility and reliability of the system. It is more conducive to the promotion and application of the system. The system can realize unattended work and can save manual operations, thus realizing automation of irrigation in a real sense.