# Construction of a Wireless Sensing Network System for Leisure Agriculture for Cloud-Based Agricultural Internet of Things

Authors: Yao Shen
Journal: Journal of Sensors
 (2021)

---

## Abstract

This paper provides an in-depth study and analysis of the construction of a cloud-based agricultural Internet of Things system for a wireless sensing network system for leisure agriculture. Using more mature agricultural sensor technology, compliant economy designed for indoor feeding and planting of distributed and integrated two sensor collection and transmission scheme, analysis of environmental factors selected high-performance various types of sensors and regulation equipment, between nodes based on SI4432 for wireless communication, and controller nodes selected STM32 as a microprocessor, through the W5500-based network port access module or ESP8266-based WiFi module for broadband access. In response to the development of mobile technology and the reality of diversified types of mobile terminals, to make all kinds of terminals accessible to the leisure agriculture system, the server software adopts the SOA software architecture, which makes the system have good openness and scalability. The NoSQL database MongoDB is used for the cloud storage of massive data, and the data structure design is completed after analyzing the database requirements, including collections, documents, and fields. The autosharding technology is used to build a database sharding cluster in the cloud, which realizes the high-speed cloud elastic storage of massive data and rewrites the database access object DAO to ensure that the WEB application is normal. Traditional leisure agriculture is mostly based on field tourism and agritourism methods, and the model is developing slowly and has increasingly failed to attract the interest of urban residents. The introduction of IoT technology in traditional leisure agriculture can increase the interest of leisure agriculture and improve the interest of urban residents in leisure agriculture.


---

## Body

## 1. Introduction

With the increasing richness of material life, urban dwellers need to relax after their stress. After work, they need to relax their mental state, so they naturally need leisure and recreation. Urban leisure has become more familiar to people, and at the same time, residents who have lived in the city for a long time also want to experience the quiet life of the countryside [1]. At this time, leisure agriculture has emerged, not only to meet people’s dream of returning to the field but also to bring people a new way of leisure. Leisure agriculture is a new crossover industry with both agricultural and leisure tourism functions, and at present, leisure agriculture appears in the form of agritourism and ecological gardens. People can not only sightsee and travel in the field but also experience it first-hand, achieving both physical and spiritual leisure [2]. Leisure agriculture is an agricultural business form that uses resources such as field landscape and natural ecological environment, combines agricultural production and operation, rural culture, agricultural product processing, and farming life, and after scientific planning, gives play to the leisure function of agriculture and rural areas, satisfies many leisure needs of tourists such as vacation, experience, entertainment, and sightseeing, and aims to enhance urban residents’ experience of agriculture as well as rural areas [3]. It is a new type of agriculture that integrates one, two, and three industries [4]. Leisure agriculture expands the function of agriculture from a single production function to a multifunctional one such as product production, leisure service, and ecological protection. The wireless sensor network is a special kind of ad hoc network that has many densely distributed sensor nodes in or around the observed object. With the continued maturation and development of wireless sensor network technology, the application market of WSN has a very broad prospect, and the application scope includes industry, agriculture, coordination, transportation, energy conservation, and environmental protection, medical care, public safety, and many other fields [5]. The economic potential market in the field is very broad, oil and gas extraction, petrochemical, metallurgy, sewage treatment, and other high energy consumption; high pollution industry has a wide range of application prospects.Wireless sensor network technology can be widely used in industrial processes, and its characteristics are closely related. The construction of a wireless sensor network determines its flexible deployment, large range, low cost, high stability, mobile support, and other characteristics, to a large extent to make up for the shortcomings of the traditional wired approach [6]. Leisure agriculture is a new type of cross-industry that combines the functions of agriculture and leisure tourism. At present, leisure agriculture appears in the form of farmhouses and ecological gardens. People can not only go sightseeing on the spot but also experience it personally to achieve double leisure of body and mind. WSN consists of multiple dedicated sensor nodes with sensing and computing capabilities of the wireless self-assembling network, real-time fine sensing of the physical parameters of the monitoring object, and through multihop relay mode to send data to the datacenter for researchers to apply, in the field of single-individual, multiparameter, and fine-grained farmland environment, crop growth information sensing has its unique technical advantages: first of all, the large-scale arrangement of the network (the number of nodes), the use of multiple nodes to monitor the same parameter, greatly improves the overall accuracy of the acquired data, which can reduce the requirements for the accuracy of a node; at the same time, the deployment of a large number of nodes increases [7]. The fault tolerance of the system network is increased. Secondly, the network can be self-organized, which saves line cost and is flexible compared with wired networks. Again, the dynamic nature of the flexible network allows WSNs to adapt to a variety of complex environments. Finally, data-centric WSN can be multilevel and multifaceted access to data. It is due to these advantages that WSNs are widely used for information acquisition in many monitoring fields such as hydrology, industry, battlefield, and smart home and are also well suited for application in the intelligent acquisition of precision agricultural information.The development history of leisure agriculture and its application status at home and abroad are analyzed, summarized, and concluded. And the importance of its development is discussed. Based on the Internet of Things and wireless sensor theory, the application of wireless sensor networks in agriculture is studied and analyzed, and according to the application environment and characteristics of farmland, wireless sensor nodes are deployed in farmland so that the cost of node deployment reaches the minimum and the formed monitoring network can effectively cover the whole farmland. At the same time, to address the problem of node energy consumption in the network, a data fusion routing protocol based on minimum cost is proposed to optimize the wireless sensor network so that the energy consumption of nodes in the network is balanced and the lifetime of the network is extended. After studying and analyzing the current development trend of leisure agriculture and existing forms of leisure agriculture, an IoT-based leisure agriculture system is designed by combining IoT technology and theories related to wireless sensor networks, and it is modeled and analyzed by using software engineering methods. The user self-customization module in the core function of the system is analyzed and designed, and the abstract factory pattern is introduced into it through the systematic study of design pattern principles and methods, and it is analyzed and extended so that the extended abstract factory can adapt to the changes of new requirements of the system. At the same time, a remote-control system is designed using hardware devices such as P-camera and microcontroller to realize the remote operation of users locally.


## 2. Current Status of Research

The Internet of Things in agriculture is also the example of Israel, which has developed a world-leading agricultural system on barren land. Using QR codes, radio frequency technology, network monitors, and various types of environmental sensor devices, Israeli agriculture has achieved precise watering, environmental information collection, and anger control for farming, using big data to guide users in fertilization, irrigation, after-sales, and other key operations in the process of agricultural production [8]. The solar system takes advantage of Africa’s natural conditions of abundant light to power the entire system; the water-drawing system draws water from any source (rivers, wells, groundwater, etc.) and stores it in tanks on the farm; and the drip system fine-tunes irrigation to the needs of the crops [9]. The SunCulture system is inexpensive and helps farms to reduce production costs and increase efficiency and is used in a wide range of orchards and gardens in Africa. The business has also won awards and support [10]. Agriculture is divided into four main types: agroforestry park type, food and culture type, rural landscape ornamental and mountain-dwelling type, and lifelong learning type, the model combined with IoT technology has opened new paths for the development of agriculture, and the pilot program of deploying wireless LAN in farmland and using it to map plant growth and enable remote control of greenhouses to increase productivity and save labor has been well results [11]. The potential of self-organizing wireless sensor network technology in experimental animal research was explored by studying the effect of the environment on animal body temperature [12].Several research results have been generated in fine crop cultivation, livestock breeding, and traceability of agricultural products. Bansal et al. used wireless technology and computer technology to develop a modern greenhouse control system that can collect data and control wirelessly. The system can control the greenhouse temperature and maintain a constant value of CO2 concentration [13]. Nicolescu et al. proposed the concept of recreational farming with the main function of land adoption for the characteristics of recreational agriculture, in which users can know the growth of land plants in real-time through the network; on the other hand, it also provides a platform for farm owners to exchange experiences and share their joy [14]. Traditional industry IoT technology applications are customized according to customer needs, and leisure agriculture is a new industry application of IoT technology; there is also no unified industry standard, and many closed-loop IoT products are developed and produced [15]. Leisure agriculture IoT requires the deployment of various sensors such as air temperature and humidity, soil temperature and humidity, and various monitoring devices in the field.Leisure agriculture is an important development direction of agriculture in the future, and it is of great significance to enhance the structure of the agricultural industry. And the development of the leisure agriculture model is slow; how to improve the attractiveness of leisure agriculture is a place worth thinking about. In recent years, agricultural IoT has started to be widely used, but most applications focus on remote monitoring of plant and animal growth environment, agricultural product quality traceability, and plant and animal growth process decision making, among which the first two are more used. A form of agricultural management aimed at enhancing urban residents’ experience of agriculture and rural areas. It is a new type of agriculture integrating primary, secondary, and tertiary industries. However, there is relatively little research on the application of IOT technology in leisure agriculture, only a few WAP and IPTV technologies are used for leisure agriculture information display, and no systematic application has been formed. In this paper, the application of sensor technology, video technology, and remote-control technology in leisure agriculture will be studied and analyzed. Coupled with the initial development trend of the park itself, it is in line with the national agricultural development trend to actively use a series of development advantages and advanced IoT technology for the optimization and adjustment of agricultural production structure and the transformation and upgrading of modern agricultural parks and innovative development. Combining the wisdom concept of modern agriculture and agricultural tourism and actively developing green ecological agriculture will create a beautiful business card for Xuanhua Town and make new contributions to the county’s beautiful new rural construction and the implementation of the rural revitalization strategy and the county’s agricultural economic development.


## 3. Analysis of Building a Wireless Sensing Network System for Leisure Agriculture in the Cloud-Based Agricultural Internet of Things

### 3.1. Design of a Cloud-Based Wireless Sensing Network System for Agriculture

The core of wireless sensor network is sensing data, the wireless sensor network is widely used this year accompanied by a huge amount of sensor data storage and management problems, big data storage and mining need to rely on high-speed processors and large-capacity hard disk, and along with many hardware resources required is the high cost of network construction and continuous resource maintenance and site costs, which means a huge loss of funds. Hardware resources to a certain extent limit the wireless sensor network for the core sensing data mining and their development [16]. The rapid development of cloud computing technology has injected new vitality into sensor networks, which greatly improves the capability of WSNs in data processing and storage, and will bring a qualitative leap to the development of WSNs. The user can view the monitoring data of the designated area in real time on the spot or remotely using various terminals through the software system. At the same time, the user can set the environmental thresholds of various environmental factors required for the growth of a certain crop, and the system will set the threshold range based on the current monitoring data difference between. The design of this thesis is based on the traditional agricultural wireless sensor network system, proposes a new field application scheme and design for data collection at the sensing layer, designs a database cluster to solve the storage problem of massive sensing data, builds a big data platform to provide a solution for data analysis and mining, and completes a cloud data management and analysis transformation scheme for the traditional sensor network system with sensor data as the center.The transformation scheme takes data as the core, and the cloud transformation is carried out in the sensing layer and network layer of the sensor network, i.e., the scheme design for data acquisition scheme, data storage, and processing. The first is the sensing layer, using more complete agricultural sensor knowledge and technology, for indoor pet breeding and flower planting proposed distributed and integrated two sensor data collection and transmission design scheme, aiming to achieve indoor pet breeding and planting monitoring and management; second is the data storage; sensor data has the characteristics of a massive, single type, and high redundancy, and analysis using nonrelational database MongoDB is used to complete the massive data storage, design the database architecture, complete the collection design, server deployment, and slice cluster construction, and write the database operation object DAO to realize the WEB application connection; finally, the big data platform, use Ambari to build the big data platform based on Hadoop ecosystem, and realize the integration of MongoDB. It is determined that it has the characteristics of flexible deployment, large-scale, low-cost, high stability, and mobile support, which makes up for the shortcomings of traditional wired methods to a large extent. The last is the big data platform, using Ambari to build a big data platform based on the Hadoop ecosystem, and implement MongoDB and Hadoop integration to pave the way for finding suitable algorithms for analysis and mining of massive sensing data, as shown in Figure1.Figure 1
Architecture of wireless sensor network.MongoDB has the advantages of feature-rich, loose data structure, powerful query language, high efficiency of storing and accessing massive data, document-oriented, fast, scalable, and easy to implement. The database design takes the agricultural sensor network system as a case study for data requirement analysis and function planning. Firstly, the data collection design of the database, using the entity class name as the table name, is divided into two categories of data collections, namely, recording user information, operation log information, and other nonsensor data and sensor data, while the sensor data collection using a split table design to improve performance; secondly, the database slice cluster design, the architecture contains the slice shard for storing the actual data blocks, storage of the entire slice cluster configuration server for storing the metadata, front-end routing, and shard to prevent a single point of failure of the host, a structure consisting of a primary server, a backup server, and an arbitration server used to achieve high availability of the cluster.(1)CE=⋃i∈NAi2⋃j∈MAj2.The sensing nodes are deployed at the vertices, and each sensing node can communicate with multiple nearby sensing nodes, which facilitates the expansion of the network and makes the network robust, connected, and scalable. When crops are growing, the farm environment is constantly changing and will cause path loss in radio signal propagation [17]. Ventilation control is mainly aimed at the greenhouse environment, controlling the switch of the fan to achieve the effect of the greenhouse ventilation; the light control is also aimed at the greenhouse environment, controlling the opening, and closing of the roller shutter to achieve the effect of controlling the light. Therefore, when deploying the network nodes, the antenna height should also be considered to prevent the node height from being lower than the height of the crops, resulting in a smaller communication range of the nodes and poorer link quality, which affects the proper functioning of the entire network. Given this, a suitable height needs to be found to ensure that at this height, the communication between sensor nodes is not affected.
(2)limNDNA=1K,ETk,d=k×Eelec−k×εfs×d2,k×Eelec−k×εfs×d4.Considering the popularity of the Internet and the cheap broadband resources, urban home residences have sufficient, cheap, and full-time broadband resources, and the size of family residences is limited, so the wired method of broadband access design of the design program first uses the chip RS-485 to complete the design of the serial module, and the serial design is generally used for long-distance data transmission. It has unique technical advantages in the field of single body, multiparameter, fine-grained farmland environment, and crop growth information perception: first, the network is deployed on a large scale, and the same parameter is monitored by multiple nodes, which greatly improves the data acquisition. The overall accuracy of the system can reduce the requirements for the accuracy of a certain node. At the same time, the deployment of many nodes increases the fault tolerance of the system network. The serial port design is generally used for long-distance data transmission to the upper computer, and more industrial use, so from the perspective of family residential use, the network cable access will be more convenient, and the wired broadband access method uses the low-power high-performance Ethernet interface chip series W5500 from WIZnet to access the network. The W5500 features a fully integrated hardware protocol stack inside the chip.Integrated sensor data acquisition and transmission design integrate sensors, regulation, and control equipment, microprocessors, network access modules, etc.; subnodes and summary points are integrated on the same board, unified by the power supply, simple deployment, easy to operate and use methods, high stability of the use environment, long service life, suitable for the box to keep pets, and a small range of plant cultivation and another small space environment [18].The sensor network of the sense mainly includes environmental data collection, equipment control, node communication, and through the network access module to achieve data upload and download functions. In this chapter, for the promising pet economy, indoor planting is used as a prerequisite to analyze the potential demand, environmental considerations, and selection of suitable sensors and regulation devices, and two sensor data acquisition and transmission schemes are designed: distributed sensor acquisition and transmission scheme and integrated sensory layer design; the first one is mainly for indoor flower and plant growing and pet rearing in a larger area, and the second one is for minigarden with pets kept in terrariums which is applicable; then, chip selection and module design are carried out, and schematic diagram is drawn according to the scheme as shown in Figure2.Figure 2
Circuit schematic.Through the overall planning, the deployment of the distributed implementation, the greenhouses in the agricultural park can reach the level of advanced IoT technology in China. The overall goal of this system is to establish a leisure agriculture system to provide powerful means and information support for farm management, land customization, and crop growth. In the planting area of the high-temperature greenhouse, fruits and vegetables are lush and green, and mobile information control terminals and sensors are visible in the greenhouse. The control terminal can be directly connected with growers and users’ mobile phones, and the temperature and humidity in the greenhouse can be viewed on the mobile phone, and the control can be adjusted at any time to reach the most suitable environment for the crops.(3)ERk=k×Eelec,ELEACH=ELN−EN,ELN=N×ETk,d−ERk×n1,EN=ETk,d×ERk×n1.According to the application environment of farmland and the characteristics of manual deployment, the number of nodes in the area is determined by dividing the area in a layered manner, and the number of nodes in the area is determined by the distance from the convergence node, which makes the load of the network balanced and avoids excessive energy consumption of cluster head nodes near the convergence node, further extending the lifetime of the network; at the same time, each area generates one cluster head node, thus avoiding random differences of cluster head nodes.(4)EMC=ELN−EN,ELN=N×ETk,d+ERk×n1,EN=ETk,d−ERk×n1.The sensing nodes are deployed in a regular structure, i.e., the nodes are at equal distances from neighboring nodes. The child nodes transmit data to the parent node, and when the parent node fails, it can transmit through other nodes, which can be seen as a node with multiple parents, increasing the routing capability of the node. The cluster head node transmits data to the convergence node using the shortest path as the transmission path. It avoids the cluster head node to be too far from the aggregation node and consumes more energy. For the establishment of cluster head nodes, residual energy is considered so that nodes with small residual energy become leaf nodes and nodes with large residual energy have a greater chance of becoming cluster head nodes.


### 3.2. Design of Wireless Sensing Networks for Recreational Agriculture

Traditional agricultural production methods are more suitable for small-scale family operations, but it is difficult to adapt to large-scale, intensive operation of farms or agricultural parks, and a single human. Labor management mode has been difficult to cope with modern large-scale agricultural production methods, time-consuming and labor-intensive and can not form scale benefits; it is difficult to meet the modern multifunctional leisure agriculture production requirements [19]. Optimize the wireless sensor network to balance the energy consumption of the nodes in the network and extend the life of the network. After studying and analyzing the current development trend of leisure agriculture and the existing leisure agriculture forms, combined with the Internet of Things technology and wireless sensor network-related theories, design a leisure agriculture system based on the Internet of Things, and use software engineering methods to build its mode analysis. The intelligent tourism agriculture system uses various sensors arranged in the park to monitor the temperature and humidity, carbon dioxide concentration, and other environmental factors affecting the growth of crops in each area in real-time, while regularly storing these data, and users can see the monitoring data of the designated area in real-time through the software system on-site or remotely using various terminals. At the same time, the user can set the environmental threshold value of each environmental factor required for the growth of a crop, and the system will promptly remind the administrator to send control signals through the intelligent controller according to the difference between the current monitoring data and the set threshold range and dynamically adjust the switch of the water pump, sunshade, fan, and other facilities, to scientifically and effectively adjust the environment of the park, to create the best environment suitable for crop growth. This can truly realize the automation, intelligence, and refinement management of agricultural production.At the same time, as the era of rapid development of information and network, information exchange and facility management through various micro terminals at any time and anywhere has become an inevitable requirement of the times, and various smart devices such as mobile phones and tablets have become the master of information. The manager of Xuanhua Township Intelligent Tourism Agricultural Park also needs a more convenient way to view and control various crop growth environment parameters, equipment operation status, and basic crop information in the park, so the system application level should also realize the configuration function of the basic information of the park. At the same time, do a good job of all kinds of terminal equipment docking, for access to the network of mobile phones, computers, etc., to be able to log in at any time and view all kinds of data information and intelligent control of facilities. Users can use mobile phones or computers to query data and provide intuitive and accurate data analysis, without leaving home to achieve remote monitoring and control, and a wider range of monitoring, cheaper implementation costs, and higher degree of automation, to achieve rationalization, scientific, saving, efficient, and accurate agricultural intelligent management, as shown in Figure3.Figure 3
System software deployment diagram of IoT system.We use the network to collect the data collected by the sensors to the air and soil in the agricultural garden to upload to the communication server, and through these uploaded data to do the analysis, the manager to the sprinklers, fan equipment, roller shutter equipment, and other remote controls [20]. To ensure the security and reliability of the hardware devices, we need to design a stable communication protocol. To ensure the integrity of the whole system, it is necessary not only to sense the farmland environment but also to perform simple operations on the farmland environment to increase the interest in leisure agriculture. The control module is mainly for spraying control, ventilation control, and light control of the farmland environment; spraying control is mainly to control the switch of the solenoid valve to achieve the purpose of irrigation of the farmland; ventilation control is mainly for the greenhouse environment, controlling the switch of the fan to achieve the role of ventilation of the greenhouse; light control is also for the greenhouse environment, controlling the opening and closing of the roller shutter to achieve the role of controlling the light.Based on the above purpose, after studying and analyzing the leisure mode of urban residents at the present stage and the development model of modern leisure agriculture, we adopt a new leisure model that combines virtual and real together and manage the real farm online in real-time through the Internet, considering the current some ecological farms and other forms of leisure agriculture. Design a leisure agriculture system based on the Internet as a media, computer-related technology and theory, modern agricultural planting technology, and system engineering methods to build and realize a visualized, multifunctional online virtual and actual planting combined with a remote farm for urban residents with leisure and tourism agriculture as the goal. The overall goal of this system is currently to establish a leisure agriculture system that provides powerful means and information support for farm management, land customization, crop growth, etc. The system should provide a unified platform to support the flexible expansion of the application system [21]. The cluster head node receives the messages from the other cluster head nodes, calculates its transmission distance, records it, and determines the path with the smallest transmission distance. In the process of data transmission, data fusion is no longer carried out. The system is universally oriented to users, so it needs to have a friendly user interface and be easy to operate. Realize the hierarchical presentation of the system and support interactive operations. In the foreground, the land information and crop growth information can be displayed to users, and users can manage online in real-time through the Internet.When a machine can not load the current system data storage needs or does not have a fast-growing system read and write throughput load, automatic slicing technology can be used to split the large data collection according to the slice key and store on multiple machines, so that the database system can store and process more data to meet the storage needs of high concurrency and massive data, set the slice key to allocating documents according to the sensor data characteristics to equalize the access pressure of the database, the sensor data storage architecture is shown in Figure4, the selection method of slice key is mainly range-based slice and hash-based slice, the design scheme of this paper selects range-based slice to divide the data to allocate documents among the slice servers, that is, the data set is divided into different ranges according to the slice key, and the database of this paper is divided according to a sensor to divide the sensor. The set is divided into ranges based on sensor IDs.Figure 4
Time-consuming comparison of item-by-item operations.The design of the hardware system for realizing the intelligent acquisition platform for precision agricultural information is presented, focusing on the design related to terminal nodes and gateways, as well as the selection of relevant sensors and modules and other models, and finally giving back out the circuit design. The software development for realizing the intelligent acquisition platform of precision agricultural information is introduced including the communication programming of terminal nodes and gateways and the development of the platform using B/S architecture, the design of database tables, the design of back-end servers and front-end pages, and finally, the demonstration of the intelligent acquisition platform of precision agricultural information, and the stability and engineering of the system are verified through error analysis. This means the consumption of huge amounts of funds, and hardware resources have limited the core sensor data mining and development of the wireless sensor network to a certain extent. The rapid development of cloud computing technology has injected new vitality into the sensor network, greatly improved the ability of WSN in data processing and storage, and will bring a qualitative leap in the development of WSN.In the application environment of farmland, the data collected by the sensing nodes in the cluster are temperature, humidity, soil temperature and humidity, carbon dioxide, light level, etc. There are many sensors arranged in the farmland, and the relative distance between these sensors is not far, and their observations are correlated in time and space, which may lead to the data redundancy phenomenon. Therefore, the data correlation between neighboring nodes can be fully utilized to reduce the energy consumption of node transmission within the cluster. For example, when collecting temperature information, the gap between the temperature information received by the cluster head nodes may not be obvious, so the cluster head nodes can leave only the temperature information and the nodes’ information when fusing the data. Data transmission between cluster head nodes. If each cluster head node transmits the data directly to the aggregation node, the cluster head nodes that are far away will consume too much energy. Therefore, the shortest path is used as the transmission path for the transmission process. The cluster head node receives the message from the rest of the cluster head nodes, calculates its transmission distance, and records it to determine the path with the least transmission distance. The fusion of data is then not performed during the data transmission.


## 3.1. Design of a Cloud-Based Wireless Sensing Network System for Agriculture

The core of wireless sensor network is sensing data, the wireless sensor network is widely used this year accompanied by a huge amount of sensor data storage and management problems, big data storage and mining need to rely on high-speed processors and large-capacity hard disk, and along with many hardware resources required is the high cost of network construction and continuous resource maintenance and site costs, which means a huge loss of funds. Hardware resources to a certain extent limit the wireless sensor network for the core sensing data mining and their development [16]. The rapid development of cloud computing technology has injected new vitality into sensor networks, which greatly improves the capability of WSNs in data processing and storage, and will bring a qualitative leap to the development of WSNs. The user can view the monitoring data of the designated area in real time on the spot or remotely using various terminals through the software system. At the same time, the user can set the environmental thresholds of various environmental factors required for the growth of a certain crop, and the system will set the threshold range based on the current monitoring data difference between. The design of this thesis is based on the traditional agricultural wireless sensor network system, proposes a new field application scheme and design for data collection at the sensing layer, designs a database cluster to solve the storage problem of massive sensing data, builds a big data platform to provide a solution for data analysis and mining, and completes a cloud data management and analysis transformation scheme for the traditional sensor network system with sensor data as the center.The transformation scheme takes data as the core, and the cloud transformation is carried out in the sensing layer and network layer of the sensor network, i.e., the scheme design for data acquisition scheme, data storage, and processing. The first is the sensing layer, using more complete agricultural sensor knowledge and technology, for indoor pet breeding and flower planting proposed distributed and integrated two sensor data collection and transmission design scheme, aiming to achieve indoor pet breeding and planting monitoring and management; second is the data storage; sensor data has the characteristics of a massive, single type, and high redundancy, and analysis using nonrelational database MongoDB is used to complete the massive data storage, design the database architecture, complete the collection design, server deployment, and slice cluster construction, and write the database operation object DAO to realize the WEB application connection; finally, the big data platform, use Ambari to build the big data platform based on Hadoop ecosystem, and realize the integration of MongoDB. It is determined that it has the characteristics of flexible deployment, large-scale, low-cost, high stability, and mobile support, which makes up for the shortcomings of traditional wired methods to a large extent. The last is the big data platform, using Ambari to build a big data platform based on the Hadoop ecosystem, and implement MongoDB and Hadoop integration to pave the way for finding suitable algorithms for analysis and mining of massive sensing data, as shown in Figure1.Figure 1
Architecture of wireless sensor network.MongoDB has the advantages of feature-rich, loose data structure, powerful query language, high efficiency of storing and accessing massive data, document-oriented, fast, scalable, and easy to implement. The database design takes the agricultural sensor network system as a case study for data requirement analysis and function planning. Firstly, the data collection design of the database, using the entity class name as the table name, is divided into two categories of data collections, namely, recording user information, operation log information, and other nonsensor data and sensor data, while the sensor data collection using a split table design to improve performance; secondly, the database slice cluster design, the architecture contains the slice shard for storing the actual data blocks, storage of the entire slice cluster configuration server for storing the metadata, front-end routing, and shard to prevent a single point of failure of the host, a structure consisting of a primary server, a backup server, and an arbitration server used to achieve high availability of the cluster.(1)CE=⋃i∈NAi2⋃j∈MAj2.The sensing nodes are deployed at the vertices, and each sensing node can communicate with multiple nearby sensing nodes, which facilitates the expansion of the network and makes the network robust, connected, and scalable. When crops are growing, the farm environment is constantly changing and will cause path loss in radio signal propagation [17]. Ventilation control is mainly aimed at the greenhouse environment, controlling the switch of the fan to achieve the effect of the greenhouse ventilation; the light control is also aimed at the greenhouse environment, controlling the opening, and closing of the roller shutter to achieve the effect of controlling the light. Therefore, when deploying the network nodes, the antenna height should also be considered to prevent the node height from being lower than the height of the crops, resulting in a smaller communication range of the nodes and poorer link quality, which affects the proper functioning of the entire network. Given this, a suitable height needs to be found to ensure that at this height, the communication between sensor nodes is not affected.
(2)limNDNA=1K,ETk,d=k×Eelec−k×εfs×d2,k×Eelec−k×εfs×d4.Considering the popularity of the Internet and the cheap broadband resources, urban home residences have sufficient, cheap, and full-time broadband resources, and the size of family residences is limited, so the wired method of broadband access design of the design program first uses the chip RS-485 to complete the design of the serial module, and the serial design is generally used for long-distance data transmission. It has unique technical advantages in the field of single body, multiparameter, fine-grained farmland environment, and crop growth information perception: first, the network is deployed on a large scale, and the same parameter is monitored by multiple nodes, which greatly improves the data acquisition. The overall accuracy of the system can reduce the requirements for the accuracy of a certain node. At the same time, the deployment of many nodes increases the fault tolerance of the system network. The serial port design is generally used for long-distance data transmission to the upper computer, and more industrial use, so from the perspective of family residential use, the network cable access will be more convenient, and the wired broadband access method uses the low-power high-performance Ethernet interface chip series W5500 from WIZnet to access the network. The W5500 features a fully integrated hardware protocol stack inside the chip.Integrated sensor data acquisition and transmission design integrate sensors, regulation, and control equipment, microprocessors, network access modules, etc.; subnodes and summary points are integrated on the same board, unified by the power supply, simple deployment, easy to operate and use methods, high stability of the use environment, long service life, suitable for the box to keep pets, and a small range of plant cultivation and another small space environment [18].The sensor network of the sense mainly includes environmental data collection, equipment control, node communication, and through the network access module to achieve data upload and download functions. In this chapter, for the promising pet economy, indoor planting is used as a prerequisite to analyze the potential demand, environmental considerations, and selection of suitable sensors and regulation devices, and two sensor data acquisition and transmission schemes are designed: distributed sensor acquisition and transmission scheme and integrated sensory layer design; the first one is mainly for indoor flower and plant growing and pet rearing in a larger area, and the second one is for minigarden with pets kept in terrariums which is applicable; then, chip selection and module design are carried out, and schematic diagram is drawn according to the scheme as shown in Figure2.Figure 2
Circuit schematic.Through the overall planning, the deployment of the distributed implementation, the greenhouses in the agricultural park can reach the level of advanced IoT technology in China. The overall goal of this system is to establish a leisure agriculture system to provide powerful means and information support for farm management, land customization, and crop growth. In the planting area of the high-temperature greenhouse, fruits and vegetables are lush and green, and mobile information control terminals and sensors are visible in the greenhouse. The control terminal can be directly connected with growers and users’ mobile phones, and the temperature and humidity in the greenhouse can be viewed on the mobile phone, and the control can be adjusted at any time to reach the most suitable environment for the crops.(3)ERk=k×Eelec,ELEACH=ELN−EN,ELN=N×ETk,d−ERk×n1,EN=ETk,d×ERk×n1.According to the application environment of farmland and the characteristics of manual deployment, the number of nodes in the area is determined by dividing the area in a layered manner, and the number of nodes in the area is determined by the distance from the convergence node, which makes the load of the network balanced and avoids excessive energy consumption of cluster head nodes near the convergence node, further extending the lifetime of the network; at the same time, each area generates one cluster head node, thus avoiding random differences of cluster head nodes.(4)EMC=ELN−EN,ELN=N×ETk,d+ERk×n1,EN=ETk,d−ERk×n1.The sensing nodes are deployed in a regular structure, i.e., the nodes are at equal distances from neighboring nodes. The child nodes transmit data to the parent node, and when the parent node fails, it can transmit through other nodes, which can be seen as a node with multiple parents, increasing the routing capability of the node. The cluster head node transmits data to the convergence node using the shortest path as the transmission path. It avoids the cluster head node to be too far from the aggregation node and consumes more energy. For the establishment of cluster head nodes, residual energy is considered so that nodes with small residual energy become leaf nodes and nodes with large residual energy have a greater chance of becoming cluster head nodes.


## 3.2. Design of Wireless Sensing Networks for Recreational Agriculture

Traditional agricultural production methods are more suitable for small-scale family operations, but it is difficult to adapt to large-scale, intensive operation of farms or agricultural parks, and a single human. Labor management mode has been difficult to cope with modern large-scale agricultural production methods, time-consuming and labor-intensive and can not form scale benefits; it is difficult to meet the modern multifunctional leisure agriculture production requirements [19]. Optimize the wireless sensor network to balance the energy consumption of the nodes in the network and extend the life of the network. After studying and analyzing the current development trend of leisure agriculture and the existing leisure agriculture forms, combined with the Internet of Things technology and wireless sensor network-related theories, design a leisure agriculture system based on the Internet of Things, and use software engineering methods to build its mode analysis. The intelligent tourism agriculture system uses various sensors arranged in the park to monitor the temperature and humidity, carbon dioxide concentration, and other environmental factors affecting the growth of crops in each area in real-time, while regularly storing these data, and users can see the monitoring data of the designated area in real-time through the software system on-site or remotely using various terminals. At the same time, the user can set the environmental threshold value of each environmental factor required for the growth of a crop, and the system will promptly remind the administrator to send control signals through the intelligent controller according to the difference between the current monitoring data and the set threshold range and dynamically adjust the switch of the water pump, sunshade, fan, and other facilities, to scientifically and effectively adjust the environment of the park, to create the best environment suitable for crop growth. This can truly realize the automation, intelligence, and refinement management of agricultural production.At the same time, as the era of rapid development of information and network, information exchange and facility management through various micro terminals at any time and anywhere has become an inevitable requirement of the times, and various smart devices such as mobile phones and tablets have become the master of information. The manager of Xuanhua Township Intelligent Tourism Agricultural Park also needs a more convenient way to view and control various crop growth environment parameters, equipment operation status, and basic crop information in the park, so the system application level should also realize the configuration function of the basic information of the park. At the same time, do a good job of all kinds of terminal equipment docking, for access to the network of mobile phones, computers, etc., to be able to log in at any time and view all kinds of data information and intelligent control of facilities. Users can use mobile phones or computers to query data and provide intuitive and accurate data analysis, without leaving home to achieve remote monitoring and control, and a wider range of monitoring, cheaper implementation costs, and higher degree of automation, to achieve rationalization, scientific, saving, efficient, and accurate agricultural intelligent management, as shown in Figure3.Figure 3
System software deployment diagram of IoT system.We use the network to collect the data collected by the sensors to the air and soil in the agricultural garden to upload to the communication server, and through these uploaded data to do the analysis, the manager to the sprinklers, fan equipment, roller shutter equipment, and other remote controls [20]. To ensure the security and reliability of the hardware devices, we need to design a stable communication protocol. To ensure the integrity of the whole system, it is necessary not only to sense the farmland environment but also to perform simple operations on the farmland environment to increase the interest in leisure agriculture. The control module is mainly for spraying control, ventilation control, and light control of the farmland environment; spraying control is mainly to control the switch of the solenoid valve to achieve the purpose of irrigation of the farmland; ventilation control is mainly for the greenhouse environment, controlling the switch of the fan to achieve the role of ventilation of the greenhouse; light control is also for the greenhouse environment, controlling the opening and closing of the roller shutter to achieve the role of controlling the light.Based on the above purpose, after studying and analyzing the leisure mode of urban residents at the present stage and the development model of modern leisure agriculture, we adopt a new leisure model that combines virtual and real together and manage the real farm online in real-time through the Internet, considering the current some ecological farms and other forms of leisure agriculture. Design a leisure agriculture system based on the Internet as a media, computer-related technology and theory, modern agricultural planting technology, and system engineering methods to build and realize a visualized, multifunctional online virtual and actual planting combined with a remote farm for urban residents with leisure and tourism agriculture as the goal. The overall goal of this system is currently to establish a leisure agriculture system that provides powerful means and information support for farm management, land customization, crop growth, etc. The system should provide a unified platform to support the flexible expansion of the application system [21]. The cluster head node receives the messages from the other cluster head nodes, calculates its transmission distance, records it, and determines the path with the smallest transmission distance. In the process of data transmission, data fusion is no longer carried out. The system is universally oriented to users, so it needs to have a friendly user interface and be easy to operate. Realize the hierarchical presentation of the system and support interactive operations. In the foreground, the land information and crop growth information can be displayed to users, and users can manage online in real-time through the Internet.When a machine can not load the current system data storage needs or does not have a fast-growing system read and write throughput load, automatic slicing technology can be used to split the large data collection according to the slice key and store on multiple machines, so that the database system can store and process more data to meet the storage needs of high concurrency and massive data, set the slice key to allocating documents according to the sensor data characteristics to equalize the access pressure of the database, the sensor data storage architecture is shown in Figure4, the selection method of slice key is mainly range-based slice and hash-based slice, the design scheme of this paper selects range-based slice to divide the data to allocate documents among the slice servers, that is, the data set is divided into different ranges according to the slice key, and the database of this paper is divided according to a sensor to divide the sensor. The set is divided into ranges based on sensor IDs.Figure 4
Time-consuming comparison of item-by-item operations.The design of the hardware system for realizing the intelligent acquisition platform for precision agricultural information is presented, focusing on the design related to terminal nodes and gateways, as well as the selection of relevant sensors and modules and other models, and finally giving back out the circuit design. The software development for realizing the intelligent acquisition platform of precision agricultural information is introduced including the communication programming of terminal nodes and gateways and the development of the platform using B/S architecture, the design of database tables, the design of back-end servers and front-end pages, and finally, the demonstration of the intelligent acquisition platform of precision agricultural information, and the stability and engineering of the system are verified through error analysis. This means the consumption of huge amounts of funds, and hardware resources have limited the core sensor data mining and development of the wireless sensor network to a certain extent. The rapid development of cloud computing technology has injected new vitality into the sensor network, greatly improved the ability of WSN in data processing and storage, and will bring a qualitative leap in the development of WSN.In the application environment of farmland, the data collected by the sensing nodes in the cluster are temperature, humidity, soil temperature and humidity, carbon dioxide, light level, etc. There are many sensors arranged in the farmland, and the relative distance between these sensors is not far, and their observations are correlated in time and space, which may lead to the data redundancy phenomenon. Therefore, the data correlation between neighboring nodes can be fully utilized to reduce the energy consumption of node transmission within the cluster. For example, when collecting temperature information, the gap between the temperature information received by the cluster head nodes may not be obvious, so the cluster head nodes can leave only the temperature information and the nodes’ information when fusing the data. Data transmission between cluster head nodes. If each cluster head node transmits the data directly to the aggregation node, the cluster head nodes that are far away will consume too much energy. Therefore, the shortest path is used as the transmission path for the transmission process. The cluster head node receives the message from the rest of the cluster head nodes, calculates its transmission distance, and records it to determine the path with the least transmission distance. The fusion of data is then not performed during the data transmission.


## 4. Analysis of Results

### 4.1. Results of a Wireless Sensing Network System for Agriculture in the Cloud

The main function of the data statistical analysis module is to store all kinds of environmental parameters collected at the site of the park regularly, forming environmental monitoring historical data, through the analysis of different dimensions of historical data, according to different dates, weeks, months, and other times in a certain shed, and presenting statistics in front of the user according to the way of continuous graphs. The software interface is displayed as shown in Figure5, through which it is seen that the horizontal coordinate of the analysis graph is timed with 24 hours, starting from zero until 8 pm, with every four hours as a basic unit. The horizontal coordinates are the values of different environmental parameters, using different color curves to distinguish different factors.Figure 5
Data statistics analysis interface.NET provides DataGridView data view control, which supports users to format the output of bound data and modify and edit the corresponding data promptly according to their needs. First, design the data collection of the database. Use the entity class name as the table name, and divide it into two types of data collections, namely, record user information, operation record information, and other nonsensor data and sensor data. Improve performance; second is the database shard cluster design. The architecture includes shard shards for storing actual data blocks, configuration servers for storing metadata of the entire shard cluster, and front-end routing. The shard shards are designed to prevent a single point of failure of the host. The user information management is mainly responsible for the information configuration of the park management staff, including the user add, delete, and change functions and the management of the user login password, because it involves user information, the screenshots of this function are not listed here, and the function mainly interacts with the UserInfo data table in the system database. W5500 performance parameters was shown in Table1.Table 1
W5500 performance parameters.
Protocol supportFull hardware TCP/IP protocol stackCommunication hardwareSupport TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE protocolHost interface8 independent hardware socketsOperating temperatureSPI high-speed serial peripheral interfaceOperating systemUp to 80 MHzOperating voltage40°CSend and receive bufferLinuxCrop information management focuses on the management and maintenance of crop information, including the name of the crop and the temperature, humidity, and CO2 concentration range that the crop can withstand. By maintaining this information, it can assist the system in environmental monitoring and facility control as well as shed management. Crop information management mainly interacts with the plants’ data table in the system database, and the result of the operation can be directly reflected in the interface of intelligent facility management and greenhouse environment monitoring. One of the crop environment thresholds is set as a reference value for greenhouse environment monitoring, and when a factor exceeds or falls below the threshold, the system will make a special mark to remind the user to adjust the environment condition by facility switch. Crop information management mainly interacts with the plants’ data table in the system database, and the results of the operation can be reflected visually in the interfaces of facility intelligence management and greenhouse environment monitoring, as shown in Figure 6.Figure 6
Platform to obtain temperature and humidity.As an application example of intelligent tourism agriculture in Xuanhua Town, Gaotai County, the MasterPage function was used in the design process to add the weather forecast function of Zhangye City, Gansu Province, to each page of the system. This function is mainly done by referring to the WebService service, which can display the weather condition of Zhangye City in Gansu Province for the last three days and provide the user with the basic reference forecast about the weather, to arrange the relevant farming affairs in time. The interface can be seen on the bottom left of the system home page.At the same time, as a modern agricultural management system, some links to websites about IOT agriculture, modern agricultural technology, and agricultural product sales have been added to the page. Through the publicity of these links, farmers can grasp some knowledge about modern agricultural production in time, which helps to improve the comprehensive management level and scientific planting quality of farmers.


### 4.2. Experimental Results

A trigger is a special kind of stored procedure that is like a referential integrity constraint in a data table, with the main function of monitoring user modifications, updates, and deletions of data. When a specified operation is performed on a specific table, the trigger’s predefined function is enabled. Triggers can call stored procedures. Proper use of triggers can have a positive impact on performance. When designing and using triggers, it is beneficial to frequently know the triggers associated with an object with a command that lists all objects, tables, views, etc., that the trigger affects. While defining several types of database objects, special attention should be given to stored procedures, indexes, and triggers, especially stored procedures, which can improve the performance of the database if designed well, and to improve the performance of the entire IoT system, we can use multiple triggers in the system, as shown in Table2.Table 2
Server-side software development environment and runtime environment table.
Name server typeTypeDatabase serverValuesHardware environment configurationFloatHP DL388Windows3Run the operating systemFloatserver20084Deployment software typeFloatCommercial4Deployment software nameFloatSQL server 20086Development environment development languageFloatDatabase server7Proper and effective node deployment can not only significantly reduce the network set-up time and quickly cover the target area but also extend the network lifetime and adapt to changing topologies through coordinated control. The correct and accurate data can only be collected if the sensors are correctly installed in the agricultural garden. Different types of sensors are installed in different ways. For example, sensors for air temperature and humidity and sensors for light intensity are suitable to be installed about 30 cm-50 cm above the ground. Sensors for soil temperature and humidity are suitable for installation in soil 5-10 cm from the ground. The video surveillance business is one of the typical business applications of IoT. The development of monitoring front-end mainly shows the trend of digital (network), high-definition, and intelligent. When we deploy the camera, we must consider the location of the installation, and only the perspective selection is appropriate, to use the least lens, to collect the best and widest video data of the agricultural park. When we deploy the network camera, the height of the camera is very important to choose; the deployment of too high, then the video collected to the farmland will be less clear and cannot reflect the actual growth of plants, but if the deployment is too low, the crops grow taller and will block the camera lens; the camera framing effect will be very unsatisfactory. When a fixed gun camera is deployed, our lens needs to be focused on the object being photographed.The video surveillance business is one of the typical business applications of the Internet of Things. The development of monitoring front-end mainly shows the trend of digital (network), high-definition, and intelligent. When we deploy the camera, we must consider the location of the installation, only the perspective selection is appropriate, to use the least lens, to collect the best and most extensive video data of the agricultural park. When we deploy the network camera, the height of the camera is very important to choose; the deployment of too high, then the video collected to the farmland will be less clear and cannot reflect the actual growth of plants, but if the deployment is too low, the crops grow taller and will block the camera lens; the camera framing effect will be very unsatisfactory. When a fixed gun camera is deployed, our lens needs to be focused on the object being photographed. The unit is powered by a power source, is simple to deploy, is easy to operate and use, has high stability in the use environment, and has a long service life. It is suitable for pets kept in the box and small-scale planting in small-space environments.The video job software contains five functional modules: database access, camera access, screenshot job, video composition, and video job. The user defines the screenshot job or video job through the web interface provided by the server, and the job information is stored in the database. The database access module is mainly responsible for accessing the database and getting the screenshot job information or video job information; the screenshot job module is to take screenshots according to the screenshot job information in the database; the video composition module is to merge the screenshot files of the screenshot job module into video files; the video compositing module merges the screenshot files from the screenshot module into video files; the video module performs video operations based on the video operation information in the database and in combination with the camera access module, as shown in Figure7.Figure 7
Batch operation time consumption comparison.We analyze the characteristics of sensor data, choose a more suitable MongoDB, briefly introduce MongoDB technology, write a database structure design plan according to the data requirements of the sensor network system and program it, and modify the DAO class in the original website code to ensure the business layer to achieve the operation of the database, and then use the autosharding technology of MongoDB. After that, we use MongoDB’s autosharding technology to build a database sharding cluster system containing 5 servers on the cloud host to complete the horizontal expansion of the database and realize an elastic capacity database that can change according to the data demand and, finally, select MySQL and MongoDB to complete the performance test comparison. The experimental results prove that MongoDB not only has excellent storage performance but also has nearly double the rate of concurrent batch operations under large data volume compared to MySQL.


## 4.1. Results of a Wireless Sensing Network System for Agriculture in the Cloud

The main function of the data statistical analysis module is to store all kinds of environmental parameters collected at the site of the park regularly, forming environmental monitoring historical data, through the analysis of different dimensions of historical data, according to different dates, weeks, months, and other times in a certain shed, and presenting statistics in front of the user according to the way of continuous graphs. The software interface is displayed as shown in Figure5, through which it is seen that the horizontal coordinate of the analysis graph is timed with 24 hours, starting from zero until 8 pm, with every four hours as a basic unit. The horizontal coordinates are the values of different environmental parameters, using different color curves to distinguish different factors.Figure 5
Data statistics analysis interface.NET provides DataGridView data view control, which supports users to format the output of bound data and modify and edit the corresponding data promptly according to their needs. First, design the data collection of the database. Use the entity class name as the table name, and divide it into two types of data collections, namely, record user information, operation record information, and other nonsensor data and sensor data. Improve performance; second is the database shard cluster design. The architecture includes shard shards for storing actual data blocks, configuration servers for storing metadata of the entire shard cluster, and front-end routing. The shard shards are designed to prevent a single point of failure of the host. The user information management is mainly responsible for the information configuration of the park management staff, including the user add, delete, and change functions and the management of the user login password, because it involves user information, the screenshots of this function are not listed here, and the function mainly interacts with the UserInfo data table in the system database. W5500 performance parameters was shown in Table1.Table 1
W5500 performance parameters.
Protocol supportFull hardware TCP/IP protocol stackCommunication hardwareSupport TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE protocolHost interface8 independent hardware socketsOperating temperatureSPI high-speed serial peripheral interfaceOperating systemUp to 80 MHzOperating voltage40°CSend and receive bufferLinuxCrop information management focuses on the management and maintenance of crop information, including the name of the crop and the temperature, humidity, and CO2 concentration range that the crop can withstand. By maintaining this information, it can assist the system in environmental monitoring and facility control as well as shed management. Crop information management mainly interacts with the plants’ data table in the system database, and the result of the operation can be directly reflected in the interface of intelligent facility management and greenhouse environment monitoring. One of the crop environment thresholds is set as a reference value for greenhouse environment monitoring, and when a factor exceeds or falls below the threshold, the system will make a special mark to remind the user to adjust the environment condition by facility switch. Crop information management mainly interacts with the plants’ data table in the system database, and the results of the operation can be reflected visually in the interfaces of facility intelligence management and greenhouse environment monitoring, as shown in Figure 6.Figure 6
Platform to obtain temperature and humidity.As an application example of intelligent tourism agriculture in Xuanhua Town, Gaotai County, the MasterPage function was used in the design process to add the weather forecast function of Zhangye City, Gansu Province, to each page of the system. This function is mainly done by referring to the WebService service, which can display the weather condition of Zhangye City in Gansu Province for the last three days and provide the user with the basic reference forecast about the weather, to arrange the relevant farming affairs in time. The interface can be seen on the bottom left of the system home page.At the same time, as a modern agricultural management system, some links to websites about IOT agriculture, modern agricultural technology, and agricultural product sales have been added to the page. Through the publicity of these links, farmers can grasp some knowledge about modern agricultural production in time, which helps to improve the comprehensive management level and scientific planting quality of farmers.


## 4.2. Experimental Results

A trigger is a special kind of stored procedure that is like a referential integrity constraint in a data table, with the main function of monitoring user modifications, updates, and deletions of data. When a specified operation is performed on a specific table, the trigger’s predefined function is enabled. Triggers can call stored procedures. Proper use of triggers can have a positive impact on performance. When designing and using triggers, it is beneficial to frequently know the triggers associated with an object with a command that lists all objects, tables, views, etc., that the trigger affects. While defining several types of database objects, special attention should be given to stored procedures, indexes, and triggers, especially stored procedures, which can improve the performance of the database if designed well, and to improve the performance of the entire IoT system, we can use multiple triggers in the system, as shown in Table2.Table 2
Server-side software development environment and runtime environment table.
Name server typeTypeDatabase serverValuesHardware environment configurationFloatHP DL388Windows3Run the operating systemFloatserver20084Deployment software typeFloatCommercial4Deployment software nameFloatSQL server 20086Development environment development languageFloatDatabase server7Proper and effective node deployment can not only significantly reduce the network set-up time and quickly cover the target area but also extend the network lifetime and adapt to changing topologies through coordinated control. The correct and accurate data can only be collected if the sensors are correctly installed in the agricultural garden. Different types of sensors are installed in different ways. For example, sensors for air temperature and humidity and sensors for light intensity are suitable to be installed about 30 cm-50 cm above the ground. Sensors for soil temperature and humidity are suitable for installation in soil 5-10 cm from the ground. The video surveillance business is one of the typical business applications of IoT. The development of monitoring front-end mainly shows the trend of digital (network), high-definition, and intelligent. When we deploy the camera, we must consider the location of the installation, and only the perspective selection is appropriate, to use the least lens, to collect the best and widest video data of the agricultural park. When we deploy the network camera, the height of the camera is very important to choose; the deployment of too high, then the video collected to the farmland will be less clear and cannot reflect the actual growth of plants, but if the deployment is too low, the crops grow taller and will block the camera lens; the camera framing effect will be very unsatisfactory. When a fixed gun camera is deployed, our lens needs to be focused on the object being photographed.The video surveillance business is one of the typical business applications of the Internet of Things. The development of monitoring front-end mainly shows the trend of digital (network), high-definition, and intelligent. When we deploy the camera, we must consider the location of the installation, only the perspective selection is appropriate, to use the least lens, to collect the best and most extensive video data of the agricultural park. When we deploy the network camera, the height of the camera is very important to choose; the deployment of too high, then the video collected to the farmland will be less clear and cannot reflect the actual growth of plants, but if the deployment is too low, the crops grow taller and will block the camera lens; the camera framing effect will be very unsatisfactory. When a fixed gun camera is deployed, our lens needs to be focused on the object being photographed. The unit is powered by a power source, is simple to deploy, is easy to operate and use, has high stability in the use environment, and has a long service life. It is suitable for pets kept in the box and small-scale planting in small-space environments.The video job software contains five functional modules: database access, camera access, screenshot job, video composition, and video job. The user defines the screenshot job or video job through the web interface provided by the server, and the job information is stored in the database. The database access module is mainly responsible for accessing the database and getting the screenshot job information or video job information; the screenshot job module is to take screenshots according to the screenshot job information in the database; the video composition module is to merge the screenshot files of the screenshot job module into video files; the video compositing module merges the screenshot files from the screenshot module into video files; the video module performs video operations based on the video operation information in the database and in combination with the camera access module, as shown in Figure7.Figure 7
Batch operation time consumption comparison.We analyze the characteristics of sensor data, choose a more suitable MongoDB, briefly introduce MongoDB technology, write a database structure design plan according to the data requirements of the sensor network system and program it, and modify the DAO class in the original website code to ensure the business layer to achieve the operation of the database, and then use the autosharding technology of MongoDB. After that, we use MongoDB’s autosharding technology to build a database sharding cluster system containing 5 servers on the cloud host to complete the horizontal expansion of the database and realize an elastic capacity database that can change according to the data demand and, finally, select MySQL and MongoDB to complete the performance test comparison. The experimental results prove that MongoDB not only has excellent storage performance but also has nearly double the rate of concurrent batch operations under large data volume compared to MySQL.


## 5. Conclusion

In this paper, we analyze the leisure mode of modern city residents and the development of leisure agriculture, systematically study and analyze the application of wireless sensor networks in agriculture based on the theory of the Internet of Things technology and wireless sensor networks, and propose the scheme and ideas of applying wireless sensor networks in agriculture to broaden the ideas of wireless sensor networks in agriculture. The video synthesis module merges the screenshot files of the screenshot operation module into a video file; the recording operation module performs recording operations based on the recording operation information in the database and combined with the camera access module. The design model of a typical agricultural sensor network is used to analyze the sensor data, and the distributed database cluster is designed to achieve large-scale and real-time data storage functions, including designing collections, documents, and fields for sensor data and nonsensor data, implementing bulk write, read, and delete operations, building an automatically scalable database cluster framework using autosharding technology, and writing a database operation object DAO to ensure that the database can be used in agriculture. Write database operation object DAO to ensure WEB application functions, etc., to achieve the elastic storage of massive data in the cloud, and compare MySQL, to compare database performance, and improve the fault tolerance, reliability, and read and write speed of the database. A leisure agriculture system based on the Internet of Things is designed and implemented, which organically combines leisure agriculture with modern computer technology, provides real-time online management of real farms through the Internet, and conducts research and exploration on how to create a modern agricultural business model. In the design of the core functions of this system, object-oriented thinking is used, and the abstract factory pattern is introduced in the user self-customization module, and it is analyzed and extended, and the extended abstract factory can cope with the changes of new requirements of the system and improve the scalability of the system.



---

*Source: 3021771-2021-11-13.xml*