An Optimization Method for the Layout of Soil Humidity Sensors Based on Compressed Sensing

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.


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.

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][25][26], but few studies have been made in the 2 Journal of Sensors 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.

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 N -dimensional original signal from the m-dimensional sampled signal (m < n). Figure 1 shows the compressed sensing framework.

Sparse Representation.
Based on the signal sparse decomposition theory, N-dimensional discrete real value signal x = ðx 1 , x 2 , ⋯, x n Þ could be denoted as a linear combination of a group of uncorrelated bases ψ i ði = 1, 2, 3, ⋯, NÞ.
In the formula, ψ = ½ψ 1 , ψ 2 ,⋯,ψ N is the basis matrix N × N. If there are only K nonzero coefficients in α, then x is called the K sparse signal in basis matrix ψ. If the conversion coefficient of the signal decays to zero exponentially with the order sorted, the signal is compressible.

Measurement Matrix.
Suppose signal x, with length as N, is reflected by a group of unit vectors Ф = ½Ф 1 , Ф 2 ,⋯,Ф N and the measured value y ∈ R M ðM ≪ NÞ 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 M × N. The sampled signal y 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 M ≪ N, the process of solving formula (1) is pathological and it is impossible to obtain original signal x directly from y. However, as α is sparse, the estimated signal b α could be obtained almost perfectly through the compressed sensing reconstruction algorithm by the known sensing matrix Θ, and then the original signal could be approximated withx = φb α.
To ensure that K coefficients can be accurately recovered from M 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 M × N and M ≪ N, if there is a constant δ k ∈ ð0, 1Þ, make all submatrices Θ k ∈ R M×k for any vector s ∈ R jkj and Θ, that is, It is said to satisfy the k-bound isometric property (K-RIP).

Reconstruction Algorithm.
When Θ satisfies the limited equidistance property, the known perceptual matrix Θ can be used to solve formula (3) through the l 0 norm.
Thus, the estimated signal b α is obtained. However, since the solution of Equation (5) is an NP-hard problem, literature shows that under certain conditions, the minimum norm of l 1 and the minimum norm of l 0 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 l 1 . min α k k l 1 s:t:y = Θb α: The original signal is then approximated byx = φb α. However, the algorithm for solving the minimum norm of l 1 is slow. Therefore, new reconstruction algorithms such as OMP [27], CoSaMP [28], and GOMP [29] have been proposed and achieved good results.

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.  [31]. M is the observed value, and the number of sensors is shown herein.
When d = 4, the expansion of the matrix multiplication is as follows: where Y is an M × 1 matrix and X is an N × 1 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 Y may be related to all the elements in X, that is, Y ∉ X.
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 X, select a part of the elements to form the Y matrix to meet Y ∈ X. The above observation matrix cannot be satisfied, and it is necessary to optimize the observation matrix.

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 Φ ∈ ones N×N . Secondly, randomly select M row vectors from the generated matrix to form a matrix of M × N. Since the identity matrix is an orthogonal matrix, the partial identity matrix of M × N size obtained after taking M 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 d = 4, after improving the measurement matrix, Y = ΦX corresponds to the expanded form of matrix multiplication as follows:

Journal of Sensors
Y½m, 1 = Φ½m, n * X½n, 1, when Φ½m, n = 1 and Y½m, 1 = X½n, 1. If the element 1 in Φ is in the m rows and n columns, the mth sensor position after sampling corresponds to the position of the nth sensor in X.
Compared with the gridded dense sensors, M sensors should be selected based on N sensors for sampling; that is, for the observation matrix Φ of M × N, each row has an only one value of 1, and each column has at most one value of 1; that is, the M sensor should be deployed at the element position with the M row vector of 1. 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.

Experiments
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 interpola-tion method. The maximum value of moisture at point ð8, 4Þ is 32.91, and the minimum value at point ð7, 8Þ 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 ð10, 83Þ is 34.36, and the minimum humidity at point ð10, 1Þ is 17.5, with a difference of 49.07%.

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 x i represents the original soil moisture data,x i represents the reconstructed soil moisture data, i represents the number of the sensor in Figure 2, and n represents the number of soil moisture data. The unit of a is %, which indicates the relative moisture content value.  5 Journal of Sensors sparsity is K ∈ f3, 7, 9, 13g. 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 M and the sparsity K 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 M, 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.   Figure 5. When the observed value M = 10 or M = 20 and K = 3, the mean absolute error is the minimum, while when M = 40, sparsity K should be 13, to minimize the mean absolute error. Therefore, in the following experiments, we all adopted the optimal sparsity.  Figure 6.
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 M = 40, the predicted value almost coincides with the actual value. When M = 20, the conformance is also good, and the result is acceptable. However, when M = 10, the predicted value differs greatly from the actual value and cannot be used.
In the three cases, the distribution of mean absolute errors at all sampling moments is shown in Table 2.   When M = 10, 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 M = 20, 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 M = 40, 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.

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.
In Figure 8, the r x,y distributions in the three graphs are relatively concentrated, which proves that the strategies of optimization sensor placement in this experiment are   Figure 8(a) are concentrated below 1.5, and the r x,y of about 30 points is between 1.5 and 2.5, and the r x,y 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 r x,y of Figure 8(c) is below 1.134. It can be seen that the r x,y 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 ½3, 3:5. 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.

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.

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.