Abstract
In the farmland Internet of Things, to achieve precise control of production, it is necessary to obtain more data support, which requires the deployment of many sensors, and this will inevitably bring about high investment and high-cost problems. This paper mainly studies the optimization of sensor placement in the agricultural field. Through compressed sensing and algorithm optimization, the number of sensors used is reduced and the cost is reduced on the premise of ensuring the effect. At present, there are many mature sensor layout optimization methods, but these methods will have incomplete parameters due to experimental conditions and environmental factors. They are more suitable for structural health monitoring and lack research in agricultural applications. Considering that the sensor layout optimization can be converted into the characteristics of image compression selection and the compression effect of the compressed sensing theory is better, therefore, this paper proposes a sensor layout optimization method based on compressed sensing. Due to the structural characteristics of the existing measurement matrix in the compressed sensing theory, the specific position distribution of the optimized sensor layout cannot be obtained directly. This paper improves the existing sparse random measurement matrix to determine the number of sensors required for a given region and the function of the specific location of each sensor. The experimental results show that soil moisture can be measured with a small error of 0.91 by using 1/3 of the original sensor number. The result of data reconstruction using 1/6 of the original sensor is average, and the average error is up to 1.68, which is suitable for the environment with small data fluctuation.
1. Introduction
Precise irrigation and irrigation automation are the inexorable trends of the development of modern agriculture. The accurate measurement of soil moisture content is the basis of precision irrigation and irrigation automation [1]. There are mainly 3 methods for soil moisture measurement, namely, manual soil sampling and drying, remote radar sensing, and acquisition by sensors. Manual soil sampling and drying are accurate but require the manual collection of soil samples at multiple locations. High in cost and weak in timeliness [2], this method is difficult to adapt to modern agricultural production. Remote radar sensing is the use of microwave radar on the satellite to measure the water on the soil surface. However, the measurement result is too coarse-grained [3] to guide fine agriculture production. Soil moisture sensors can quickly and accurately measure the same point in the soil and are widely used in precision irrigation.
When soil humidity sensors are applied to measure the soil moisture content, the more soil humidity sensors are buried in a profile, the more precisely the soil moisture measurement will be [4]. However, as the number of sensors increases, so does the cost of production systems, and there is a contradiction between cost and data accuracy. To save the agricultural irrigation system cost and improve the efficiency of the state estimators, the paper proposes a method for soil humidity sensor layout based on compressed sensing, aiming at reducing the number of sensors as much as possible on the premise of accuracy.
Compressed sensing, also known as compressive sampling or sparse sampling, is a technique for finding sparse solutions of underdetermined linear systems. According to this theory, if the signal is sparse, it can be reconstructed and recovered from sampling points much lower than the sampling theorem requires [5]. Compressed sensing is used in electronic engineering, especially signal processing, to obtain and reconstruct sparse or compressible signals. This method takes advantage of the sparsity of the signal. Compared with the Nyquist theory, this method can recover the entire desired signal from fewer measured values. Simply put, the process of data compression is completed during the sampling process. In the process of signal sampling, compressed sensing uses a few sampling points to achieve the same effect as full sampling. In the compressed sensing theory, the original signal can be accurately reconstructed under the condition of few measuring points. Based on this feature, an optimization method based on compressed sensing of soil humidity sensor layout is proposed in the paper. Firstly, the sensors are densely placed in farmland soil by which original soil humidity data is obtained, and then Fourier Transform is applied for sparse representation of the data; secondly, the sparse presentation data is operated through the improved sparse random measurement matrix and an observed value is obtained; finally, through the reconstruction algorithm, the reconstructed signals are obtained. Through comparison of the three kinds of sensor layout optimization strategies, it is found that 1/3 of the original number of sensors can measure the soil moisture with a minor error.
This paper theoretically ameliorates the existing sparse random measuring matrix, proposing a soil humidity sensor layout optimization method based on compressed sensing. The implemented functions are to quantify the required sensors in a given area and place them at specific locations. Effects are achieved that with fewer sensors, the whole farmland soil temperature distribution is measured, which reduces the costs effectively while increasing the efficiency of information processing of the system.
2. Related Work
In farmland IoT, strengthening the research on soil quality protection and management and realizing the intelligent management of farmland protection are the key to guarantee the safety of agricultural products [6]. In the field of farmland irrigation IoT, many scholars have been solving the problems on the hardware level. For example, Feng, to lower the irrigation water cost, achieved water saving by intelligent irrigation and raising irrigation water efficiency through embedded control technology [7]. Liu, on the possible time out and cross-restriction problems, proposed the farmland data collection mechanism to guarantee the reliable transmission of data [8]. Liu and Yang proposed a network management project of network topology management, location management, energy management, and fault management, referring to the features of node power and limited processing energy in sensor networks, to realize the remote management of the sensor monitoring network and the effective detection of the farmland environment for the users [9]. Singh and Saikia proposed an irrigation control system based on Arduino. The system collects and receives data through Arduino and uploads it to a designated interactive website, on which the real-time soil status factor and the standard value of different factors required by crops are shown [10]. All these research studies ensure the instantaneity, accuracy, and reliability of the soil humidity data on the hardware level. It alleviates the noise folding phenomenon of compressed sensing [11], making compressed sensing a more effective choice in the optimization of agricultural sensors.
Sensor layout optimization plays an important role in different fields. In structural dynamics, a good sensor layout could recognize accurately the model parameter of a structure and ascertain the damage degree of the structure [12]. In direct kinematics, the location of the sensors will influence the calculation complexity, the accuracy of position sensing, and the reliability of the system [13]. In a network warning system, the position of sensors affects the effectiveness of warnings [14]. In thermology, placing a temperature sensor in an optimal position helps to accurately and in real time predict thermally induced deformation at a particular location [15].
Sensor layout optimization based on the model analysis method is a methodology by which the layout strategy is obtained through optimum analysis based on establishing a finite element model and setting an optimization target. The sensor layout optimization method based on the model analysis method was first proposed by Kammer as the effective influence method [16]; that is, a sensor placement program is to be obtained by maximizing the spatial independence and signal intensity of the target finite element model. Then, Heo et al. proposed kinetic energy to place the sensors [17]. Based on the EI method and KE method, Wu et al. proposed the effective independence driving-point residue method, improving the spatial independence and element strain energy of the above two methods [18]. Mukherjee et al. applied a reweighing method replacing repeated function simulation to estimate the expected influence value and proposed a mode analyzing method for sensor placement for nonlinear uncertain systems [19]. Modeling error was caused inevitably in the course of establishing a finite element model with the abovementioned sensor layout optimization method, and modeling tends to be trapped into the local optimum.
To avoid modeling error, Krause et al. proposed a sensor node placement method driven by data [20]. Guestrin et al. proposed to place the sensor based on rules of mutual information [21]. Xu and Choi used noise measurement and a mobile self-adaption anisotropy space-time Gaussian process, which enables nonparametric prediction toward a given space-time phenomenon [22]. The abovementioned methods presume that the space random process is Gaussian distribution; however, soil humidity in farmland does not completely follow Gaussian distribution, and thus, it does not work very well.
Compressed sensing is a technology that could be used to obtain and reconstruct sparse signals and does not depend on the Gaussian distribution of data. Put forward in 2006 by Donoho [23], now, compressed sensing has been extensively used in fields like wireless communication. Compressed sensing is extensively applied in sensor node information collection [24–26], but few studies have been made in the sensor. In this paper, soil water distribution is treated as a two-dimensional image. The compressed sensory theory has a good effect and has been proved by a large amount of theoretical proofs in the field of image compression. Therefore, this method has general conditions.
3. Method
3.1. Compressed Sensing Theory
Compressed sensing of the signal mainly includes three steps [23]: the first step is sparse representation, which converts the original signal into a sparse signal on another dimension; the second step is to reduce the dimension of the observation matrix to minimize the information loss of the original signal; and the third step is to design a reconstruction algorithm to recover the -dimensional original signal from the -dimensional sampled signal (). Figure 1 shows the compressed sensing framework.

3.1.1. Sparse Representation
Based on the signal sparse decomposition theory, -dimensional discrete real value signal could be denoted as a linear combination of a group of uncorrelated bases .
In the formula, is the basis matrix . If there are only nonzero coefficients in , then is called the sparse signal in basis matrix . If the conversion coefficient of the signal decays to zero exponentially with the order sorted, the signal is compressible.
3.1.2. Measurement Matrix
Suppose signal , with length as , is reflected by a group of unit vectors and the measured value is obtained. This process could be shown as
We put formula (1) into formula (2) and obtain
In the formula, is the measurement matrix, while is the sensing matrix; both are matrix . The sampled signal obtained is the linear combination of the column of matrix . The linear combination coefficient is that in the corresponding original signal .
Since measurement matrix dimension , the process of solving formula (1) is pathological and it is impossible to obtain original signal directly from . However, as is sparse, the estimated signal could be obtained almost perfectly through the compressed sensing reconstruction algorithm by the known sensing matrix , and then the original signal could be approximated with .
To ensure that coefficients can be accurately recovered from measurements, that is, to ensure that the algorithm is convergent, the in formula (3) must satisfy the restricted equidistance (RIP) criterion [5]; that is, for the matrix of size and , if there is a constant , make all submatrices for any vector and , that is,
It is said to satisfy the -bound isometric property (-RIP).
3.1.3. Reconstruction Algorithm
When satisfies the limited equidistance property, the known perceptual matrix can be used to solve formula (3) through the norm.
Thus, the estimated signal is obtained. However, since the solution of Equation (5) is an NP-hard problem, literature shows that under certain conditions, the minimum norm of and the minimum norm of are equivalent, and the same solution can be obtained [23]. Then, Equation (5) can be transformed into an optimization problem of the minimum norm of .
The original signal is then approximated by . However, the algorithm for solving the minimum norm of is slow. Therefore, new reconstruction algorithms such as OMP [27], CoSaMP [28], and GOMP [29] have been proposed and achieved good results.
3.2. Algorithm Flow
The algorithm is divided into three steps. In the first step, the data obtained by the soil moisture sensor is not sparse, so the partial Fourier Transform (Permute Fast Fourier Transform (PFFT)) is adopted for sparse representation. The second step is to optimize the selection method of the sparse random observation matrix as the observation matrix suitable for this study to obtain the number and optimal location of sensors. Third, OMP, GOMP, and CoSaMP reconstruction algorithms were used to reconstruct the compressed data and compared with the original data, and it was found that OMP was more accurate in calculating the distribution of soil moisture data.
3.2.1. Introduction and Evaluation of the Original Observation Matrix
The sparse random observation matrix construction method [30] first generates an all-zero matrix, and in the matrix of each column vector, randomly selected positions; in the selected location assignment 1, values are generally and have little effect on the reconstruction results [31]. is the observed value, and the number of sensors is shown herein.
When , the expansion of the matrix multiplication is as follows: where is an matrix and is an matrix. The column vector selects four positions of 1 so that each row vector is likely to have many 1’s, and the row position of the elements in the different row vectors is different. The result may be related to all the elements in , that is, .
The idea of this paper is to select a part of the sensors to collect data in the original sensor layout. That is, in the matrix , select a part of the elements to form the matrix to meet . The above observation matrix cannot be satisfied, and it is necessary to optimize the observation matrix.
3.2.2. Observation Matrix Optimization
The sparse random observation matrix is changed twice. First, the randomly selected object is the row vector of the matrix . Second, only one position is selected in each row vector to assign it to 1. Make sure that the optimized observation matrix has only one element value per line.
The improved method for constructing a sparse random measurement matrix is as follows. Firstly, generate an identity matrix . Secondly, randomly select row vectors from the generated matrix to form a matrix of . Since the identity matrix is an orthogonal matrix, the partial identity matrix of size obtained after taking rows from it still has a strong noncorrelation and partial orthogonality. It satisfies the RIP theorem and ensures that the observation matrix will not combine two different sparse data mapped to the same collection.
When , after improving the measurement matrix, corresponds to the expanded form of matrix multiplication as follows:
, when and . If the element 1 in is in the rows and columns, the th sensor position after sampling corresponds to the position of the th sensor in .
Compared with the gridded dense sensors, sensors should be selected based on sensors for sampling; that is, for the observation matrix of , each row has an only one value of 1, and each column has at most one value of 1; that is, the sensor should be deployed at the element position with the row vector of 1.
4. Experiments
4.1. Data Acquisition
The soil humidity sensors numbered successively with are placed evenly at 10 cm below the soil surface of a farmland as shown in Figure 2. Experimental data is the soil moisture value measured by all sensors on June 1, 2015, solstice, and November 30, 2015.

Through data analysis, it is found that farmland soil moisture has strong spatial and temporal differences, so it is necessary to deploy more sensors to accurately monitor it.
Firstly, the soil moisture data of farmland have spatial differences. Figure 3 shows the soil moisture surface at 21:00 on May 31, 2015, obtained by the bilinear interpolation method. The maximum value of moisture at point is 32.91, and the minimum value at point is 25.52, with a difference of 22.5%.

Secondly, the soil moisture data of farmland varies with time. Figure 4 shows the soil moisture curves of 10 sensors at 100 time points during June 1, 2015, solstice, and June 30, 2015. For sensor number 10, the maximum humidity at point is 34.36, and the minimum humidity at point is 17.5, with a difference of 49.07%.

4.2. The Evaluation Indexes
To analyze the performance index of sensor layout optimization in different compressive sampling conditions, an indicator of absolute error is provided in this paper. The formula is as follows: where represents the original soil moisture data, represents the reconstructed soil moisture data, represents the number of the sensor in Figure 2, and represents the number of soil moisture data. The unit of is %, which indicates the relative moisture content value.
4.3. Selection of the Reconstruction Algorithm
In this experiment, the soil moisture distribution image composed of 64 sensor points is relatively simple; OMP, CoSaMP, GOMP, and other algorithms are suitable for a relatively simple image selected point compression. Therefore, OMP, GOMP, and CoSaMP algorithms are used for comparative analysis.
Compare the three kinds of reconstruction accuracy of the algorithm (OMP, GOMP, and CoSaMP). The data of soil moisture measured by all sensors in a set of dry soil (23:00 on May 28, 2015) and a set of irrigated soil (6:00 on July 15, 2015) were selected. The number of original sparse signals is , the observed values are , and the sparsity is . The observation matrix is an optimized sparse random measurement matrix. Each observed value was simulated 500 times to determine the probability of accurate recovery. OMP, GOMP, and CoSaMP algorithms were compared to determine the relationship between the recovered data and the observed value and the sparsity under a given sparsity. The experimental results are shown in Table 1.
For the two sets of data, under the same upper limit of residual error and the same observed value , the average relative error of the OMP algorithm is only 3%-9%, which is better than that of the GOMP algorithm (5%-11%) and CoSaMP algorithm (6%-12%). Therefore, among the three reconstruction algorithms, the OMP reconstruction algorithm has a better effect. In the following experiments, the OMP algorithm is used to reconstruct data.
4.4. Sparsity Selection
When original data is converted to a sparse vector through PFFT, the number of nonzero elements in the sparse vector is denoted as the sparsity degree . For the determined reconstruction algorithm and , the errors vary with the value of . With the soil humidity value at 21 o’clock on July 30, 2015, under the conditions , , and , respectively, we change the value of and take an iteration of 500 times for each sparsity to average the errors and observe the variation of errors with . The simulation results are shown in Figure 5.

(a) Error-sparsity curve when

(b) Error-sparsity curve when

(c) Error-sparsity curve when
When the observed value or and , the mean absolute error is the minimum, while when , sparsity should be 13, to minimize the mean absolute error. Therefore, in the following experiments, we all adopted the optimal sparsity.
4.5. Reconstruction of Soil Water Spatial Distribution
Soil humidity at 21 o’clock on July 30, 2015, is selected as experimental data. With the OMP reconstruction algorithm, under the circumstances of plus , plus , and plus , respectively, multiple iterations are used to get a minimum of errors to determine the location of corresponding sensors. The locations under the 3 circumstances are shown in Figure 6.

(a) Position of 10 sensors

(b) Position of 20 sensors

(c) Position of 40 sensors
Consider three cases, and the refactoring effect is shown in Figure 7. The abscissa represents 64 sensors, and the ordinate represents the soil moisture value. When , the predicted value almost coincides with the actual value. When , the conformance is also good, and the result is acceptable. However, when , the predicted value differs greatly from the actual value and cannot be used.

(a) Reconstruction effects of 10 sensors

(b) Reconstruction effects of 20 sensors

(c) Reconstruction effects of 40 sensors
In the three cases, the distribution of mean absolute errors at all sampling moments is shown in Table 2.
When , the mean absolute error of 80% of the sampling moments is concentrated below 1.5, the error of 12% of the sampling moments is between 1.5 and 2.5, and the error of 8% of the sampling moments is between 2.5 and 3.5. When , the mean absolute error of 85% of the sampling moments is below 1, the error of about 12% is between 1 and 1.5, and the error of only about 3% is above 1.5. When , the errors of all sampling moments are below 1.14. Therefore, considering the balance between sensor installation cost and reconstruction accuracy, it is recommended to deploy 20 sensor sampling points to obtain more accurate reconstruction results of soil water distribution.
5. Evaluation of the Effectiveness of Sensor Placement
It is limited to get the abovementioned sensor arrangement optimization at a moment. Therefore, the 250 time points from June 1, 2015, to November 30, 2015, are selected as the experimental data. The overall error distribution of the three strategies at different times is shown in Figure 8.

(a) 10 sensors

(b) 20 sensors

(c) 40 sensors
In Figure 8, the distributions in the three graphs are relatively concentrated, which proves that the strategies of optimization sensor placement in this experiment are effective and feasible. Most of the in Figure 8(a) are concentrated below 1.5, and the of about 30 points is between 1.5 and 2.5, and the of about 20 points is between 2.5 and 3.5; the error of Figure 8(b) is mostly below 1, and the error of a few points is above 1; the of Figure 8(c) is below 1.134. It can be seen that the of 10 sensors is maximum, and the placement of 20 sensors and 40 sensors is similar. Considering the cost of the sensor, 20 sensors can be arranged to achieve more accurate measurements.
In Figure 8(a), there are some errors between . Choose two of them for detailed analysis, and get Figure 9.

Figure 9 is the 220th time in Figure 8(a). The error is 3.2325. The effect is generally and only part of the data close to the original data. The placement of the 10 sensors is too difficult to obtain all the features mainly due to significant changes in soil characteristics. However, it can be found that the amplitude of the reconstruction curve is stable, and the optimization strategy of 10 sensors is not suitable for the environment with high accuracy or obvious soil characteristic change.
6. Discussion
In summary, the overall error of arranging 20 sensors is close to that of arranging 40 sensors. Considering the cost issue, using 20 sensors can get a more accurate acquisition of soil moisture. Due to the obvious changes in soil moisture characteristics, the placement of 10 sensors is too small, resulting in large errors. By observing the data recovery of 10 sensors at a certain moment, it is found that the error is large at the maximum and minimum values, but the overall curve fluctuates stably. Therefore, the method of using only 10 sensors is suitable for situations where the data change range is not large.
7. Conclusions
Aiming at the problems of unreasonable sensor placement and high cost in the agricultural IoT, this paper proposes an optimization strategy of sensor placement based on the compressed sensing theory. By analyzing the soil moisture data at a certain moment and the optimization of the observation matrix, three optimal strategies of sensor layout were obtained and then verified at more time points. Through experiments, it is found that 1/3 of the original sensor can be used to measure soil moisture with a lower error. The purpose of obtaining more accurate data with fewer sensors is realized. The overall error of 20 sensors is close to that of 40 sensors. Considering the cost, 20 sensors can be used to obtain soil moisture more accurately. Due to the obvious change of soil moisture characteristics, the 10 sensors were too few, resulting in a large error. When observing the data recovery situation at a certain moment, it was found that the error was large at the maximum and minimum values, but the overall fluctuation of the curve was stable, which was suitable for the situation with a small range of data changes.
When used, the moisture distribution of the mesh point can rely on manual multiple measurements, no need to install the sensor. After several measurements, the sensor deployment can be determined by this article, and only about 1/3 of the sensor can achieve a better effect, so the cost is relatively low.
The shortcomings of the experiment mainly include the following two aspects: (1) the sensor was numbered in one dimension, while the two-dimensional spatial correlation of soil moisture was ignored; and (2) soil moisture data at different moments were uniformly set to equal sparsity, resulting in large errors. These will be the focus of future research.
Data Availability
The soil moisture data used to support the findings of this study are available from the corresponding author upon request.
Conflicts of Interest
The authors declare that there is no conflict of interest regarding the publication of this paper.
Acknowledgments
First of all, I would like to extend my sincere gratitude to my supervisor, Xiang Li, for his instructive advice and useful suggestions on my thesis. I am deeply grateful for his help in the completion of this thesis. High tribute shall be paid to Shuaiqi Huang, whose profound knowledge of sensors triggers my love for the greenhouse and whose earnest attitude tells me how to do experiments. I am also deeply indebted to all the other tutors and teachers in translation studies for their direct and indirect help to me. Special thanks should go to my friends who have put considerable time and effort into their comments on the draft. Finally, I am indebted to my parents for their continuous support and encouragement. The study was partially supported by the Natural Science Foundation of China through grants (61601471).