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

Authors: Yunsong Jia; Xueyun Tian; Xin Chen; Xiang Li
Journal: Journal of Sensors
 (2021)

---

## 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.


---

## Body

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


#### 3.1.1. Sparse Representation

Based on the signal sparse decomposition theory,N-dimensional discrete real value signal x=x1,x2,⋯,xn could be denoted as a linear combination of a group of uncorrelated bases ψii=1,2,3,⋯,N.
(1)x=∑i=1Nψiαi=ψα.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.


#### 3.1.2. Measurement Matrix

Suppose signalx, with length as N, is reflected by a group of unit vectors Ф=Ф1,Ф2,⋯,ФN and the measured value y∈RMM≪N is obtained. This process could be shown as
(2)y=Φx.We put formula (1) into formula (2) and obtain
(3)y=Φx=Φψα=Θα.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 dimensionM≪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 α^ 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 x^=φα^.To ensure thatK 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∈RM×k for any vector s∈Rk and Θ, that is,
(4)1−δks22≤Θks22≤1+δks22.It is said to satisfy thek-bound isometric property (K-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 l0 norm.
(5)minαl0s.t.y=Θα^.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 l1 and the minimum norm of l0 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 l1.
(6)minαl1s.t.y=Θα^.The original signal is then approximated byx^=φα^. However, the algorithm for solving the minimum norm of l1 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 M×N all-zero matrix, and M≪N in the matrix Φ of each column vector, randomly selected d positions; in the selected location assignment 1, d values are generally d∈4,8,10,16 and have little effect on the reconstruction results [31]. M is the observed value, and the number of sensors is shown herein.Whend=4, the expansion of the matrix multiplication is as follows:
(7)Y=ΦX=y1y2y3⋮yM−1yM=110000⋯0001100⋯0001010⋯0⋮⋮⋮⋮⋮⋮⋱⋮000001⋯1000001⋯0x1x2x3x4x5⋮xN−1xN=x1+x2x2+x3x2+x4⋮x5+xnx5+⋯,where Y is an M×1matrix 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 matrixX, 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.


#### 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Φ∈onesN×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.Whend=4, after improving the measurement matrix, Y=ΦX corresponds to the expanded form of matrix multiplication as follows:
(8)Y=ΦX=y1y2y3⋮yM−1yM=010000⋯0000100⋯0001000⋯0⋮⋮⋮⋮⋮⋮⋱⋮000000⋯1000001⋯0x1x2x3x4x5⋮xN−1xN=x2x4x3⋮xNx6.Ym,1=Φm,n∗Xn,1, when Φm,n=1 and Ym,1=Xn,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.


## 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.Figure 1
The compressed sensing framework.


### 3.1.1. Sparse Representation

Based on the signal sparse decomposition theory,N-dimensional discrete real value signal x=x1,x2,⋯,xn could be denoted as a linear combination of a group of uncorrelated bases ψii=1,2,3,⋯,N.
(1)x=∑i=1Nψiαi=ψα.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.


### 3.1.2. Measurement Matrix

Suppose signalx, with length as N, is reflected by a group of unit vectors Ф=Ф1,Ф2,⋯,ФN and the measured value y∈RMM≪N is obtained. This process could be shown as
(2)y=Φx.We put formula (1) into formula (2) and obtain
(3)y=Φx=Φψα=Θα.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 dimensionM≪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 α^ 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 x^=φα^.To ensure thatK 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∈RM×k for any vector s∈Rk and Θ, that is,
(4)1−δks22≤Θks22≤1+δks22.It is said to satisfy thek-bound isometric property (K-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 l0 norm.
(5)minαl0s.t.y=Θα^.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 l1 and the minimum norm of l0 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 l1.
(6)minαl1s.t.y=Θα^.The original signal is then approximated byx^=φα^. However, the algorithm for solving the minimum norm of l1 is slow. Therefore, new reconstruction algorithms such as OMP [27], CoSaMP [28], and GOMP [29] have been proposed and achieved good results.


## 3.1.1. Sparse Representation

Based on the signal sparse decomposition theory,N-dimensional discrete real value signal x=x1,x2,⋯,xn could be denoted as a linear combination of a group of uncorrelated bases ψii=1,2,3,⋯,N.
(1)x=∑i=1Nψiαi=ψα.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.


## 3.1.2. Measurement Matrix

Suppose signalx, with length as N, is reflected by a group of unit vectors Ф=Ф1,Ф2,⋯,ФN and the measured value y∈RMM≪N is obtained. This process could be shown as
(2)y=Φx.We put formula (1) into formula (2) and obtain
(3)y=Φx=Φψα=Θα.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 dimensionM≪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 α^ 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 x^=φα^.To ensure thatK 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∈RM×k for any vector s∈Rk and Θ, that is,
(4)1−δks22≤Θks22≤1+δks22.It is said to satisfy thek-bound isometric property (K-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 l0 norm.
(5)minαl0s.t.y=Θα^.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 l1 and the minimum norm of l0 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 l1.
(6)minαl1s.t.y=Θα^.The original signal is then approximated byx^=φα^. However, the algorithm for solving the minimum norm of l1 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 M×N all-zero matrix, and M≪N in the matrix Φ of each column vector, randomly selected d positions; in the selected location assignment 1, d values are generally d∈4,8,10,16 and have little effect on the reconstruction results [31]. M is the observed value, and the number of sensors is shown herein.Whend=4, the expansion of the matrix multiplication is as follows:
(7)Y=ΦX=y1y2y3⋮yM−1yM=110000⋯0001100⋯0001010⋯0⋮⋮⋮⋮⋮⋮⋱⋮000001⋯1000001⋯0x1x2x3x4x5⋮xN−1xN=x1+x2x2+x3x2+x4⋮x5+xnx5+⋯,where Y is an M×1matrix 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 matrixX, 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.


### 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Φ∈onesN×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.Whend=4, after improving the measurement matrix, Y=ΦX corresponds to the expanded form of matrix multiplication as follows:
(8)Y=ΦX=y1y2y3⋮yM−1yM=010000⋯0000100⋯0001000⋯0⋮⋮⋮⋮⋮⋮⋱⋮000000⋯1000001⋯0x1x2x3x4x5⋮xN−1xN=x2x4x3⋮xNx6.Ym,1=Φm,n∗Xn,1, when Φm,n=1 and Ym,1=Xn,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.


## 3.2.1. Introduction and Evaluation of the Original Observation Matrix

The sparse random observation matrix construction method [30] first generates an M×N all-zero matrix, and M≪N in the matrix Φ of each column vector, randomly selected d positions; in the selected location assignment 1, d values are generally d∈4,8,10,16 and have little effect on the reconstruction results [31]. M is the observed value, and the number of sensors is shown herein.Whend=4, the expansion of the matrix multiplication is as follows:
(7)Y=ΦX=y1y2y3⋮yM−1yM=110000⋯0001100⋯0001010⋯0⋮⋮⋮⋮⋮⋮⋱⋮000001⋯1000001⋯0x1x2x3x4x5⋮xN−1xN=x1+x2x2+x3x2+x4⋮x5+xnx5+⋯,where Y is an M×1matrix 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 matrixX, 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.


## 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Φ∈onesN×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.Whend=4, after improving the measurement matrix, Y=ΦX corresponds to the expanded form of matrix multiplication as follows:
(8)Y=ΦX=y1y2y3⋮yM−1yM=010000⋯0000100⋯0001000⋯0⋮⋮⋮⋮⋮⋮⋱⋮000000⋯1000001⋯0x1x2x3x4x5⋮xN−1xN=x2x4x3⋮xNx6.Ym,1=Φm,n∗Xn,1, when Φm,n=1 and Ym,1=Xn,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.


## 4. Experiments

### 4.1. Data Acquisition

The soil humidity sensors numbered successively with1,2,⋯,64 are placed evenly at 10 cm below the soil surface of a 40m×40m 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.Figure 2
Original sensor distribution.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. Figure3 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 8,4 is 32.91, and the minimum value at point 7,8 is 25.52, with a difference of 22.5%.Figure 3
Soil moisture surface.Secondly, the soil moisture data of farmland varies with time. Figure4 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%.Figure 4
Humidity distribution at each sensor point.


### 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:(9)meanabsoluteerror:a=∑i=1nxi−x^in,averagerelativeerror:r=∑i=1nxi−x^i/xin,where xi 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.


### 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 isN=64, the observed values are 0<M<64, and the sparsity is K∈3,7,9,13. 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.Table 1
Comparison of different reconstruction algorithms.
Soil typeReconstruction algorithmObserved valueMAverage relative errorDry soilOMP413%GOMP415%CoSaMP416%Moist soil after irrigationOMP399%GOMP3911%CoSaMP3912%For the two sets of data, under the same upper limit of residual error and the same observed valueM, 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 degreeK. For the determined reconstruction algorithm and M, the errors vary with the value of K. With the soil humidity value at 21 o’clock on July 30, 2015, under the conditions M1=10, M2=20, and M3=40, respectively, we change the value of K and take an iteration of 500 times for each sparsity to average the errors and observe the variation of errors with K. The simulation results are shown in Figure 5.Figure 5
Error-sparsity variation curve.
(a)
Error-sparsity curve whenM=10(b)
Error-sparsity curve whenM=20(c)
Error-sparsity curve whenM=40When the observed valueM=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.


### 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 ofM1=10 plus K1=3, M2=20 plus K2=3, and M3=40 plus K3=13, 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.Figure 6
Error-sparsity variation curve.
(a)
Position of 10 sensors(b)
Position of 20 sensors(c)
Position of 40 sensorsConsider three cases, and the refactoring effect is shown in Figure7. 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.Figure 7
Error-sparsity variation curve.
(a)
Reconstruction effects of 10 sensors(b)
Reconstruction effects of 20 sensors(c)
Reconstruction effects of 40 sensorsIn the three cases, the distribution of mean absolute errors at all sampling moments is shown in Table2.Table 2
Comparison of reconstruction effects of differentM values.
MMean absolute errorLeast absolute errorMaximum absolute error101.680.413.71200.910.372.12400.470.181.14WhenM=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.


## 4.1. Data Acquisition

The soil humidity sensors numbered successively with1,2,⋯,64 are placed evenly at 10 cm below the soil surface of a 40m×40m 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.Figure 2
Original sensor distribution.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. Figure3 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 8,4 is 32.91, and the minimum value at point 7,8 is 25.52, with a difference of 22.5%.Figure 3
Soil moisture surface.Secondly, the soil moisture data of farmland varies with time. Figure4 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%.Figure 4
Humidity distribution at each sensor point.


## 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:(9)meanabsoluteerror:a=∑i=1nxi−x^in,averagerelativeerror:r=∑i=1nxi−x^i/xin,where xi 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.


## 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 isN=64, the observed values are 0<M<64, and the sparsity is K∈3,7,9,13. 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.Table 1
Comparison of different reconstruction algorithms.
Soil typeReconstruction algorithmObserved valueMAverage relative errorDry soilOMP413%GOMP415%CoSaMP416%Moist soil after irrigationOMP399%GOMP3911%CoSaMP3912%For the two sets of data, under the same upper limit of residual error and the same observed valueM, 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 degreeK. For the determined reconstruction algorithm and M, the errors vary with the value of K. With the soil humidity value at 21 o’clock on July 30, 2015, under the conditions M1=10, M2=20, and M3=40, respectively, we change the value of K and take an iteration of 500 times for each sparsity to average the errors and observe the variation of errors with K. The simulation results are shown in Figure 5.Figure 5
Error-sparsity variation curve.
(a)
Error-sparsity curve whenM=10(b)
Error-sparsity curve whenM=20(c)
Error-sparsity curve whenM=40When the observed valueM=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.


## 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 ofM1=10 plus K1=3, M2=20 plus K2=3, and M3=40 plus K3=13, 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.Figure 6
Error-sparsity variation curve.
(a)
Position of 10 sensors(b)
Position of 20 sensors(c)
Position of 40 sensorsConsider three cases, and the refactoring effect is shown in Figure7. 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.Figure 7
Error-sparsity variation curve.
(a)
Reconstruction effects of 10 sensors(b)
Reconstruction effects of 20 sensors(c)
Reconstruction effects of 40 sensorsIn the three cases, the distribution of mean absolute errors at all sampling moments is shown in Table2.Table 2
Comparison of reconstruction effects of differentM values.
MMean absolute errorLeast absolute errorMaximum absolute error101.680.413.71200.910.372.12400.470.181.14WhenM=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.


## 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 Figure8.Figure 8
Error distribution at different moments.
(a)
10 sensors(b)
20 sensors(c)
40 sensorsIn Figure8, the rx,y 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 rx,y in Figure 8(a) are concentrated below 1.5, and the rx,y of about 30 points is between 1.5 and 2.5, and the rx,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 rx,y of Figure 8(c) is below 1.134. It can be seen that the rx,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 Figure8(a), there are some errors between 3,3.5. Choose two of them for detailed analysis, and get Figure 9.Figure 9
Recovery of abnormal points.Figure9 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.



---

*Source: 9901990-2021-09-03.xml*