1. Introduction
Moisture content is an important index that reflects the freshness, preservation state, and internal quality of agricultural products [
1], and it is a key measurement and control parameter in the processes of purchasing, processing, storing, and transporting. High moisture content leads to grain mildew, shortened storage time, and effects on the food taste [
2]. Grain moisture content is a crucial factor for the management of harvesting and postharvest operations and is a basis for pricing in the grain trade [
3].
The grain moisture content generally is measured by direct-contact methods or indirect-noncontact methods [
4]. The direct-contact methods usually employ desiccation or a chemical method to measure the moisture content [
5], such as the oven-drying method and the Karl Fisher titration method, which have the advantages of simple steps and high accuracy of the detection result. However, the processes of sample preparation and the long operation of inspection equipment would be occurred, which is not suitable for the real-time or field measurements there [
6]. By detecting the variable parameters related to the water content of materials, indirect-noncontact methods, such as the neutron gauge [
7], resistance detection [
8], the capacitance method [
9], near-infrared spectroscopy [
10], and the microwave-drying method [
11], serve to determine the moisture content in grains. Indirect-contact methods generally have a high measurement speed but usually have their own disadvantages, respectively. For near-infrared spectroscopy, the absorption spectrum varies with the moisture content of the material, and the infrared penetration depth is on the micron level, which means the detection area will be quite small on the surface of samples; however, for agricultural products, the measurement area should be as large as possible, thus results in limited application of the near-infrared method. The capacitance method regards the detected objects as a dielectric material and measures the dielectric constant of the measured objects [
12]; however, the results of this method are greatly affected by the environment’s temperature, and the device needs to be recalibrated after a long period of use. The capacitance method demonstrates poor performance for materials with high moisture content and is not a perfect solution for on-line measurement because the capacitive sensor takes a long time to introduce samples between the electrodes [
13].
The principle of the microwave method is similar to that of the capacitance method, and it has the advantages of non-destructive detection, high speed, and real-time monitoring [
14]. For moisture measurement based on microwaves, the dominant detecting method can be mainly divided into microwave reflection and microwave transmission [
15]. One of the advantages of microwave reflection detection is that the integration of signal transmission and reception can simplify the installation; however, the advantage can also turn into a disadvantage, as it causes a low resolution and smaller reflected signals from individual antennae, which need special auxiliary hardware to amplify the signals and improve precision [
16]. Applications of microwave transmission on the moisture measurements of peanuts, corn, and soybeans [
17,
18,
19] have been achieved, but the detection equipment based on horn antenna were large and the experiments were inconvenience when carrying on-site. With the development of microstrip antenna sensors in recent years, it is possible to use microstrip antenna sensors instead of a horn antenna to realize microwave signal receiving and transmitting [
20] and to design a set of portable real-time detection devices for grain moisture content.
The water molecule in the detected material is a strong dipole, which plays a dominant role in the impact on the dielectric properties compared to the dry matter. Therefore, the moisture content in the detected material can be measured by analyzing the dielectric properties, but the detecting equipment is expensive and complicated. This study converts to directly measure the parameters related to the dielectric properties, such as microwave attenuation and phase shift, to detect the moisture content of the material and to make the detecting equipment portable.
In general, very limited optimization work has been carried out regarding the realization of the on-line measurement of the moisture content of agricultural and food products. In this context, the aims of the present study are: (1) to develop a low-cost portable device for the real-time measurement of paddy rice with a moisture content range of generally 13–30%; (2) to determine the optimal measurement parameters according to experimental objects (microwave characteristics, phase shift, and temperature compensation); and (3) to develop an effective moisture content prediction model by comparing different regression algorithms. This work is expected to provide an important reference for the real-time in situ measurement of other agricultural products and to be of great significance for the development of intelligent agricultural equipment.
2. The Design of the Portable Moisture Content Detecting Device
2.1. The Principle of Microwave Transmission Detection
As a non-contact detecting method, microwave transmission detection has the advantages of a fast detection speed, high applicability, and strong practicability. The detection principle of the microwave transmission method is as follows:
The relationships between attenuation and phase shift and the dielectric properties are shown in
Figure 1. The attenuation and phase shift of the microwave signal can be obtained as follows:
where P
inc is the incident signal power, dBm; P
tra is the transmitted signal power, dBm; P
ref is the reflected signal power, dBm; φ
inc is the phase of the incident signal, rad; φ
tra is the phase of the transmitted signal, rad; and N is an integer determined by the thickness of the test sample.
2.2. The Portable Detection Device
2.2.1. The Structure and the Principle
A schematic diagram of the detection device is shown in
Figure 2. The device is divided into three sub-modules: (a) the microwave signal transmission-generation module, MSTGM; (b) the real-time measurement module (RTMM) with two microstrip microwave sensors (transmitting and receiving); (c) and the signal receiving–processing module, SRPM. The MSTGM sends a microwave signal at the specified frequency, which goes into the power distributor by the splitter. Two of the same microwave signals are generated after the power splitter. One microwave signal, processed by the low-noise amplifier 2 is translated to the microstrip transmitting antenna in RTMM as the incident signal. The incident signal perpendicularly irradiates the grain samples, a part of which is reflected by the sample surface to form a reflected signal. Due to the reverse cut-off function caused by the isolator, the reflected signal is extremely reduced, and the signal generator is protected. The other part of the microwave incident signal turns into the transmission signal after penetrating the grain samples. The transmission signal, which is received by the microstrip receiving antenna, is transmitted to the radio-frequency port of the in-phase and quadrature mixer (IQ mixer) as the input radio-frequency (RF) input signals. The other signal from the power splitter is amplified by the low-noise amplifier 1 and then enters the local oscillator (LO) of the IQ mixer as the input reference signal.
The microstrip transmitting antenna and microstrip receiving antenna were in close contact with the tested sample during measurement, and the distance between the two antennas changed as the sample cell distance changed. The microwave attenuation data, phase-shift data, and environment temperature data were transmitted to the upper computer via a serial communication protocol. Then, different regression models set in the upper computer train and process the data. The model with the best performance index was integrated into the microcontroller, and the predicted grain moisture content was displayed on the liquid crystal display (LCD) screen in real time.
2.2.2. The Measurement of Attenuation and Phase Shift
The attenuation and phase shift of the microwave signal were derived from the two output signals of the IQ mixer. As shown in
Figure 2a, the IQ mixer had a total of four ports: two input ports (RF and LO), and two output ports (I and Q). The microwave signal that did not penetrate the sample to the input port LO was treated as a reference signal; the microwave transmission signal that did penetrate the sample to the input port RF was considered a radio-frequency signal. The IQ mixer generated the identity signal of the radio-frequency signal and the reference signal in the output port I. An orthogonal signal was generated by mixing the radio-frequency signal from the output port Q and the reference signal that has undergone a 90-degree phase-shift transformation. The attenuation and phase shift of the microwave were calculated from the reference signal LO, and the radio-frequency signal RF was calculated from the output signal at the port I end and the output signal at the port Q [
21].
The output signals from port I and port Q were direct currents in this study, and the signal processing procedure was same as the work in our preview work [
22].
2.3. The Hardware Part of the Device
2.3.1. Circuit Module
The circuit module is shown in
Figure 3. The whole device was divided into two layers:
Figure 3a shows the superstructure, which was the high-frequency microwave circuit module.
Figure 3b shows the lower structure, which was the low-frequency circuit and power module.
Figure 3c shows the 3D simulation of the overall structure. The two parts were supported by four copper columns with fixed bolts at each corner. The height distance between the two parts was slightly greater than that of the highest circuit components. This design scheme made the overall structure compact and stable.
In
Figure 3a,c, the high-frequency microwave circuit module consisted of an isolator, a power divider, two low-noise amplifiers, and an IQ mixer. The main functions of this part were the transmission of the high-frequency microwave signal, isolation of the unwanted reflected wave signals received from the microstrip transmitting antenna, amplification of the microwave signal, and conversion of the transmission signal received by the microstrip receiving antenna into a low-frequency signal. In
Figure 3b,c, the low-frequency circuit and power module in the lower structure consisted of an AD converter, an STM32 module, a power terminal block, and a switching power supply. The main functions of this part were the power supply of the whole device, reception/conversion/processing of low-frequency signals, and conversion of low-frequency signals into attenuation and phase-shift data. This structure effectively separated high- and low-frequency signals from each other and prevented interference, while greatly saving installation space and making the overall device smaller.
The microwave signal generator was DSINSTRUMENTS SG6000L (Suzhou Ruibeis Electronic Technology Co., Ltd., Suzhou, China), whose output frequency ranged from 25 Mhz to 6000 Mhz, and the phase noise is less than −72 dbc. The signal generator’s maximum output power level was over +10 dBm. The size of this part was 7.0 cm × 3.2 cm × 5.5 cm, which is easy to integrate and carry. Marki’s IQ-0205 model was selected as the IQ mixer. The IQ mixer operated in the frequency range of 2000–5000 Mhz and had a maximum conversion loss of 8 dB. Designed with a small size, IQ-0205 is quite convenient for portable device design.
2.3.2. Real-Time Measurement Module
As shown in
Figure 4, the microstrip transmitting antenna and the microstrip receiving antenna were the same sizes in the real-time measurement module.
Figure 4b shows one sample of a sample cell, and there were six sample containers of the same material, same height, same width, but different lengths, in this experiment, and they were all made by 3D printing.
Figure 4c shows that the real-time measurement module consists of two microstrip antennae, a sample cell, a fixed base, two guide rails, and a four-T antenna fixed frame. Both the fixed base and the T-shaped fixed antenna stand are made by 3D printing.
The two-microstrip antenna sensor GAUA3000M-40M-A (Beijing Gwave Technology Co., Ltd., Beijing, China) operate at 3 Ghz and has a bandwidth of 20 Mhz and a gain of 7 dBi with A coaxial SMA interface. Compared with the common horn antenna, the microstrip antenna has a narrow working bandwidth with a small volume advantage. The size of the microstrip antenna sensor is 80 mm × 80 mm × 1.5 mm, which is very suitable for integration in small-scale equipment.
2.3.3. Integral Structure of the Portable Moisture Detecting Device
As shown in
Figure 5, the circuit module and the real-time measurement module are installed in the same cuboid white plastic box. The two modules communicate with each other through the coaxial line. The size of the entire shell is 42 cm × 32 cm × 16 cm. The device is appropriate, lightweight, and easy to carry, thus offering the possibility to measure the moisture content of grains in situ.
2.4. The Software Parts
An STM32F103RBT6 chip (Sichuan Kangwei Technology Co., Ltd., Sichuan, China) was installed as the microcontroller for signal receiving and processing and to realize the functions of the signal AD conversion, attenuation, and phase-shift data calculation, grain moisture content calculation, LCD control, temperature sensor control, and serial communication. The attenuation and phase-shift data were converted into code calculation by Formulas (1)–(6), and the moisture content was calculated by the best regression model selected by the upper system. The AD7606 module (Sichuan Kangwei Technology Co., Ltd., Sichuan, China) was applied to the AD conversion. An SPI communication protocol, a 16-bit analog-to-digital converter (ADC), and an eight-channel synchronous sampling were adopted to obtain a more stable signal compared to the ADC of the STM32, and the frequency of the obtained signal could reach up to 200 kSPS. The real-time ambient temperature data were collected by the DS18B20 (Sichuan Kangwei Technology Co., Ltd., Sichuan, China), which has a small volume and light weight, by separately calculating the integer and decimal digits of the parameters. The organic light-emitting diode (OLED) with the resolution of 128 × 64 was chose as the device screen. The result was displayed on the OLED screen.
The whole program adopted a modular design and was divided into different program modules according to the different functions. The defined peripheral header files only needed to import to the main program, and the whole set worked immediately once the main program was started. If the relevant functions needed modification, the corresponding header files were changed (or replaced) directly, which was quite convenient. The whole program was written in C language, and the code was compiled by the Keil software (Version 5, ARM Germany GmbH, Grasbrunn, Germany). The program flow chart is shown in
Figure 6.
2.5. Sample Preparation
The fresh paddy rice (
Oryza sativa L.) samples were purchased from a local supermarket (Hangzhou, China), and the initial moisture content of the samples was 13.66%. Before the experiment, all paddy rice was filtered with mesh to remove particles and other matters, and the rice with minimal damage and uniform shape were selected as the final experimental samples. An amount of 500.00 g of the paddy rice sample was weighed for each group, and eight groups were selected in this study. According to the initial moisture content of paddy rice, deionized water (0, 10.88, 29.69, 43.02, 49.94, 64.31, 79.46, and 95.45 g) was added to the eight groups. Then, the samples were sealed in plastic bags and stored in a dry, cool, unventilated environment for 2–3 days. During storage, the paddy rice was fully agitated to absorb as much water as possible for the sample. A standard oven-drying method [
23] was applied to detect the moisture content of processed samples (5 g paddy rice was used here), and the results were 13.66, 15.65, 18.20, 20.17, 21.22, 23.21, 25.45, and 27.02% for each group of paddy rice. The eight groups with different moisture contents are shown in
Figure 7. To verify the results, two groups of additional samples were prepared with random moisture contents (15.01 and 21.90%); the procedure was the same as for the eight groups of paddy rice above.
2.6. Measurement Procedure and Data Acquisition
The effects of temperature and sample thickness on the signals were considered. The tests under the same temperature with different thicknesses were carried out, as well as the tests under the same thickness with different temperatures. The samples were filled with sample cells in the way of free fall. Before the moisture detection experiment, the conductivity of an empty sample container was tested three times, and the average value was taken as the reference data, which was used to obtain the real attenuation and phase-shift data. The results of the three measurements were averaged. The measured distance between the transmitting antenna and the receiving antenna depended on the thickness of the sample container, and the two antennae were closely connected with the sample container.
The thicknesses of the samples were 8–13 cm, respectively. The sample containers with different thicknesses are shown in
Figure 8. All sample containers were made by 3D printing (WESTI Science Park Incubator Co., Ltd., Xi’an, China) with nylon (polyamide material) (WESTI Science Park Incubator Co., Ltd., Xi’an China). During measurement of the samples with different thicknesses, the ambient temperature was 21 °C. During the measurement of the samples with the same thickness, the ambient set temperatures were 15 °C, 20 °C, 25 °C, and 30 °C, respectively. For each measurement, three replicate trials were taken, and the detecting time was set to 5 s. After each measurement, the true values of the samples and the no-load values with on samples and were detected at different temperatures. All the obtained data were translated and transmitted through serial communication, and stored at the upper computer.
4. Conclusions
In this study, a novel portable real-time detection device for grain moisture measurement based on microwave microstrip antenna sensors is developed, which can operate in situ with high accuracy. The main conclusions are as follows:
- 1.
A real-time detection device for paddy rice moisture content was designed, and a microwave measurement module was built to carry out non-destructive measurements. The STM32F103RBT6 chip was designed as the signal receiving and processing module to realize the functions of AD conversion, microwave attenuation and phase-shift calculation, temperature acquisition and display, and screen control and serial port communication. The final moisture content was displayed in real time on the LCD screen.
- 2.
The attenuation, phase-shift, and temperature data were obtained. The characteristic value of the best combined form was determined using a random forest, after comparison with the performances of decision tree model, k-nearest neighbor model, and support vector machine model. The temperature compensation was added to optimize the model. Finally, the model parameters with the best performance index in the above four algorithms were selected and returned to the single-chip microcomputer to display the measured value of the grain moisture content in real time.
- 3.
Nine groups of grains with different moisture contents were measured by the detection device. The maximum and minimum average absolute errors of the measurement results were 0.55% and 0.17%, respectively. The maximum standard deviation was 0.41%, and the minimum was 0.08%. The accuracy and stability of the measurement results were within the acceptable range.
In this study, the portable moisture detection device designed for grain moisture content is small, light, highly expansive, and accurate. This work is expected to provide an important reference for the development of real-time measurement of other agricultural products, and to be of great significance for the development of intelligent agricultural equipment and industrial applications. In our future studies, the adaptability of the microwave moisture measurement system for moisture measurement of agricultural products with complex surfaces and shapes, such as tea leaf, soybean, and crop straw, will be investigated.