Rapid advances in sensor technology are enabling aggressive use of informatics in agriculture. This paper focuses on applying the newly developed soil electrical impedance spectrum sensor combined with artificial intelligence to predict soil fertility. The described method determines the type and amount of fertilizer to be used. The proposed sensor system is portable and fast enough for real-time measurements in the field using a slow-moving tractor. It is affordable, battery-powered and allows wireless data transmission to the farmer’s soil database. Such a database allows the farmer to create a reliable fertilizer plan. The crop is of better quality because fertilizer is applied only where it is needed on the plot. The use of fertilizer is optimized, costs are reduced, and the environment is preserved. Many papers report more or less credible results on this problem, but they lack verification of real conditions in the field.
Keywords: Soil analysis; Real-time fertilization plan; Electrical impedance spectrum of the soil; Soil classificatory
Abbreviations: Application Specific Integrated Circuit (ASIC); Deionized (DI); Agriculture Institute of Slovenia (KIS); Principle of Component Analysis (PCA)
The diversity of soil conditions in terms of its moisture, composition, texture, and temperature makes soil analysis very difficult. The deterministic methods, such as chemical analysis, cannot be used in the field because it requires a chemical laboratory. It is time consuming, expensive and unreliable as it only relates to a particular soil sample. Dozens of soil samples must be collected and analyzed per acre. In the recent article , the authors described their vision about the future development of digital agriculture. They listed several possible sensors that would monitor the agricultural plot and collect a soil and crop status database below and above the surface. The analysis of this data would pave the way for the optimization of agricultural activities. Many methods have been described [2-4], but none are accurate enough or acceptable for real-time applications. We want to collect soil fertility results in a few seconds while driving the tractor over the field. In this section, we will briefly review some of the most promising soil characterization technologies. Optical methods were investigated using spectral analysis in both the visible and visible-infrared spectra, analyzing either reflectance or transmittance results. Our investigation of these methods did not meet our expectations. We tried an interesting approach to study
the residual of tiny dried droplets of soil extraction fluid and found
promising results. This approach is shown in Figure 1. Figure 2 shows the optical spectra of such a soil solution. Some other impressive results can be obtained under laboratory conditions, but field application is not feasible. Raman spectroscopy or mass spectroscopy analysis is too expensive and too slow for on the fly analysis. The non-contact methods using microwaves and terahertz waves are too expensive and not convincingly reliable. Unfortunately, these methods have not met the expected criteria. We need a better approach that is marketable and accepted by farmers. In our study, we decided to develop a sensor system that meets the following criteria for acceptance:
a.accuracy, reliability, and repeatability,
b.fast, on the spot, portable, battery-powered,
c.easy to use, robust and user-friendly,
d.low cost, and
e.ready for wireless communication.
The closest technology to meet the listed requirements seemed to measure and analyze the soil’s electrical impedance
spectrum. The soil electrical impedance spectrum method  is
the most promising, but it requires significant extensions to meet
the listed acceptance criteria. In the following sections we will
describe these extensions.
In the field, the soil sample has unknown composition, texture,
and moisture. These values significantly affect the soil spectrum
and affect soil classification and fertilizer prediction accuracy. In
laboratory experiments, these conditions are known and held
constant. However, to classify an unknown soil sample, some
additional soil parameters must be recorded. These are the relative
soil viscosity, the temperature, the value PH and the DC resistivity.
These values are used to pre-select a reference database for the
classification algorithm. The resulting classification algorithm is
then significantly improved. These improvements mean that the
soil database of known chemical parameters must be expanded to
include the listed parameters. Figure 3 shows the flow-chart of the
classification algorithm procedure. Figure 4 shows a simplified
schematic of the soil impedance spectrometer Application Specific
Integrated Circuit (ASIC). It consists of a mixed-signal design of
the front-end electronics, a programmable clock generator to
excite the soil sample, and the signal processing unit to calculate
the impedance’s real and imaginary parts. Figure 5 shows
the simplified interface diagram between the ASIC of the soil
impedance spectrometer and the processing unit, like a personal
computer or similar. Soil samples are collected from 0-30 cm soil
surface and then prepared in the laboratory for characterization
and classification. The soil samples were air-dried and sieved 2
mm. They were then mixed with the required amount of Deionized
(DI) water to obtain a soil mass with the required viscosity. The
amount of DI water is different for each soil and is estimated
automatically. A certified laboratory performed a chemical
analysis of all soil samples in the Agriculture Institute of Slovenia
(KIS) . The comprehensive characterization of each soil sample
contains information on all common soil constituents, and only
the analyzed nutrients are listed in Table I. Reading and storing
the imaginary and real parts of signals corresponding to a soil
sample or reference circle is performed using Matlab software.
The Matlab script is created to read the controller Analog to
Digital Converter (ADC) data and store it in a personal computer
or database for further processing.
Data preprocessing is performed to calibrate the obtained
imaginary and real parts of soil impedance with the imaginary
and real parts of the reference circuit impedance. This procedure
is necessary to ensure accurate data acquisition. The reference
circuit signals for the final sensor design are measured only once
and used to correct other signals acquired with this sensor. We
use the corrected signals corresponding to the soil samples to
calculate the impedance magnitude and impedance phase. A
training set for machine learning is formed from the research
dataset measurements corresponding to soil with known chemical
properties of phosphorus, potassium and magnesium. The
research dataset consists of impedance strengths and impedance
phases corresponding to a soil sample. The chemical analysis
of soil sample properties performed at KIS includes nutrient
values for phosphorus, potassium and magnesium. Tables 2&3
and Figure 6 show the principles of soil sample code formation.
Following the fertilizer planning recommendations, the A-E
classification was used for each soil component (e.g., phosphorus,
potassium, and magnesium). These classification components are
then combined to form a XXX code for classifying and predicting
the soil properties under test.
The training process includes the feature selection procedure
 and classification using the so-called “classifier”. Many
classifiers have been proposed in the literature that performs
classification with different degrees of accuracy. A comparative
analysis was performed to select the classifier with the best
results (i.e., the best match between the predicted nutrient
content and the actual nutrient content determined at the KIS).
The classification accuracy was validated using the leave-one-out
method . Only soil samples with known chemical properties
were used in this validation (i.e., training set). Three subsamples
represent each soil sample to allow more accurate analysis.
First, a soil subsample corresponding to the measurement from
the research dataset was used as a test sample, while the others
were used for machine learning (i.e., training set). Then, the
obtained prediction is compared with the actual soil properties
(i.e., KIS code). This procedure is performed for all data from
the research dataset. The results obtained for three subsamples
of the same soil are averaged and used to calculate the overall
classification accuracy. In other words, the percentage of predicted
characteristics that match the certified laboratory characteristics
is used to characterize classification accuracy. Taking three or more
measurements of the same soil sample is typical in agricultural
informatics to obtain a more accurate and representative result.
The procedure for calculating the classification accuracy is shown
in Figure 7, where the process is illustrated graphically. During the
feature extraction procedure, the signal frequencies with the most
relevant information for classification are selected separately for
impedance magnitudes and impedance phases. Several feature
selection methods are described in the literature. The Principle
of Component Analysis (PCA) is selected here as one of the most
common and useful . An example of the classification accuracy
obtained when the feature selection procedure was used and
when the feature selection was not used can be seen in Table IV.
It shows a significant performance improvement of the classifiers
with feature selection even in the problematic soil sample without
using the pre-selection feature introduced in the proposed novel
classifier. Figure 8 shows the estimated weights for impedance
variables according to the research dataset. The threshold
value Th=0.2 is used to reduce features with a small impact on
classification accuracy. Thus, 13 features were extracted. Table
V shows the frequencies and their indexes obtained during
feature selection. The obtained frequencies are then used for
both machine learning and test signal properties prediction. Tree
Bagger  was selected as the most promising classifier. Tree
Bagger chooses a random subset of predictors for each decision
partition as in the random forest algorithm. The outputs of the
classifier are model parameters that are unique to each research
dataset. These parameters are estimated once and then used to
predict the chemical properties of the soil under study. Table VI
shows the classifiers selected for comparative analysis in this
Table 4 shows the results of the prediction accuracy of the soil
sample codes for the research dataset consisting of 21 soil samples
collected from different locations in Slovenia with different textures
and chemical properties. The feature selection procedure for this
dataset estimated five frequencies with weighting parameters
greater than Th=0.2. We can see different classification accuracies
between the results, with Tree Bagger and Fitcecoc showing the
best performance. The least accurate result was obtained using the
k- Nearest Neighbor method (i.e., Fitknn). These results are quite
acceptable as they have an accuracy of almost 90%. Knowing that
the soil sample does not have representative nutrient contents,
we can rely on the reasonable assumption that the fertilization
schedule is calculated at many points in the studied field since
the soil classification is extremely fast. Consequently, the field is
mapped in terms of nutrients with a grid sufficient to determine
a reliable average fertilizer rate and the proper mix to improve
fertility near optimum.
The goal of the presented study was to develop an optimized
classification algorithm and a portable classifier that can predict
the content of nutrients in the soil in a short time. Mapping
the soil’s nutrient content on a particular plot is no longer an
expensive and time-consuming affair with this device. The
fertilization schedule can be automated with a Global Positioning
System (GPS) controlled metering device on the farm tractor.
The described soil prediction was tested on five different farms
on three plots. The analysis was carried out twice a year under
different weather conditions and soil moisture. The test sites were
selected to represent the diversity of the Slovenian landscape.
The first selected farm was located in the NW (North-West) of
Slovenia. The soil there is not very fertile, but it was managed for
growing seasonal vegetables with a well thought out crop rotation.
The second farm is located in SE (South-East) of Slovenia. The soil
there is poor and neglected, very muddy and difficult to analyze.
The location of the third farm is on the eastern border of Slovenia.
The crop there is grown in large plastic tents with automatic
irrigation and ventilation. The fourth farm is located in the eastern
part of Slovenia. The analysis was carried out on three different
vineyards. The soils were clay type and challenging to analyze.
The additional feature of the algorithm helped to overcome this
and provided the correct prediction. A very similar problem was
found in a vineyard in the central-eastern part of Slovenia. Again,
the new prediction algorithm proved to be correct.
This paper describes an improved method for determining
the electrical impedance spectrum of soil that provides a reliable,
robust, and cost-effective tool for characterizing the soil fertility
of an agricultural field and for developing an optimal fertilization
plan. This project’s result is a portable device for analyzing the
soil’s electrical impedance spectrum and characterizing it based
on the spectrum data. The system is battery powered. It also
allows for direct wireless data transmission. The results were
verified in several farms with different soil types. An acceptable
probability of correct soil class prediction was achieved. Since the
prediction algorithm is based on the principle of self-learning,
the probability of correct prediction increases with the growth of
the learning data set. We believe that the sophisticated methods
described in  are not required to achieve such results.
The Slovenian Research Agency (ARRS) and the Ministry
of Agriculture, Forestry and Food (MKGP) partially funded the
project. The author thanks Olga Chambers, Ph.D., for her assistance
with the measurements.