Automation of irrigation by electronic tensiometry based on the arduino hardware platform

This study developed and evaluated an electronic irrigation system controlled by soil water matric potential. The controller uses tensiometers and pressure transducers as a reading mechanism, integrated with an Arduino microcontroller board that drives the solenoid valves and a 1/3 hp single-phase motor. Four electronic tensiometers were installed in plastic containers filled with 6 kg of Red-Yellow Latosol (RYL) with a clayey texture, and another four in plastic containers filled with 7 kg of Regolitic Neosol (RN) with a sandy texture. Irrigation automation components were activated autonomously at the critical potentials of -20, -25, -30, and -35 kPa for RYL, and -10, -15, -20, and -25 kPa for RN, with a 20% variation tolerance. The entire system is able to monitor and control irrigation based on soil water matric potential. Components were deactivated when the soil water potential reached the field capacity of each soil type. Irrigation automation performance was considered satisfactory, as it kept critical potentials within the pre-established thresholds in both soil types. Automation control was set for matric potentials between -10 kPa and -35 kPa in RYL, and between -5 kPa and -25 kPa in RN.


INTRODUCTION
Irrigation based on soil water availability obtained by soil water tension is a practical solution for the rational use of water in irrigated agriculture. The soil water tension, also called "matric potential", indirectly allows estimating soil moisture and thus determining water availability to agricultural crops (Dobriyal et al., 2012). The use of a device that allows monitoring the matric potential and converting it into an electrical signal enables the development of an irrigation automation system that relates directly to the water consumption of plants (Bianchi et al., 2017). Irrigation planning as a function of soil moisture monitoring is a technique that can increase yield and water-use efficiency in several crops (Romero et al., 2012).
Tensiometers are instruments that measure the capillary or moisture potential on the basis of the suction force exerted on water by soil (Schmugge et al., 1980). As soil moisture decreases, water from the tensiometer is transferred to the soil through a porous capsule, thus creating a negative pressure inside the tensiometer, which can be detected by mechanical devices, vacuum meters, or digital devices such as pressure transducers (Thalheimer, 2013;Freire et al., 2018). The use of tensiometers that can monitor the matric potential from a distance brings some operational benefits, such as reducing in-place measurements, as these can affect the contact of the capsule with the soil due to handling of the tensiometer. Furthermore, adopting these equipment significantly reduces the time required to obtain soil moisture in a cultivation system (Arruda et al., 2017).
The high cost of data loggers, multiplexers, and sensors, the lack of technical information, difficulties in the installation and maintenance of equipment, and the absence of electronic data communication and storage systems are still limiting factors for the use of a number of sensors that enable greater frequency and coverage of the measurement of critical potentials and soil moisture. Another critical factor that contributes to the low adoption of soil moisture monitoring in agriculture is the need for in-place calibration of the sensors used. Depending on the physical properties of the soil and the type of sensor, responses in the variation of soil potential and moisture can differ. Payero et al. (2017) observed that the Watermark 200ss granular matrix sensor used to monitor soil water potential led to different trigger points used to initiate irrigation in soils with sandy and clayey-sandy texture. This was due to the decrease of soil moisture, which varies depending on soil texture, requiring equipment calibration.
Recently, advances in the field of open source hardware components, such as the Arduino electronic prototyping platform, have opened up new possibilities for the development of measurement solutions that can relate to data transmission and storage systems. These innovations enable greater spatio-temporal coverage of soil moisture at a significantly lower cost than conventional industrial devices (Bitella et al., 2014).
There is currently a wide variety of sensors and auxiliary components, such as memory chips and communication devices, which are available in an easy-to-understand interface and can be used by people with limited electronics background and knowledge. The Arduino microcontroller runs an open-source program that is created and updated by the user and can operate various electronic components in an electrical circuit. The user can modify the programming and change its function without the need for physical changes to the circuit. Examples of circuits developed in Arduino for applications in agriculture and monitoring of environmental variables can be found in Masseroni et al. (2016), Karami et al. (2018), and Targa et al. (2019).
The present study developed and evaluated electronic tensiometers and an automation system for use in irrigation of two soil types, using low-cost electronic components and recording of matric potential data on the Arduino open source hardware platform.

Physical-hydraulic characterization of the Red-Yellow Latosol (RYL) and Regolitic Neosol (RN)
The study was developed in two stages. The first stage consisted of the development of the system and calibration of pressure transducers at the Laboratory of Water Analysis at the Faculty of Agronomy and Veterinary Medicine of the University of Brasília, FAV/UnB. The second stage comprised the evaluation of the automation system in a protected environment at the Biological Experimental Station of UnB. The protected environment consisted of a greenhouse (30 x 13 m) with an evaporative air-cooling system.
Disturbed RYL samples collected from the 0-20 cm layer in an area cultivated with maize (15°56'56.32" S; 47°55'46.16" W) and NR samples from the 0-20 cm layer of a natural Cerrado area (15°58'48.27" S; 47°56'57.54" W) were used. Both samples were sieved at 2.0 mm and air-dried. After drying, five simple samples of each soil type were collected, homogenized, packed in plastic bags, and sent to the laboratory of soil physics for physical and granulometric analysis (Table 1). Eight 11 L plastic containers were used, four filled with 6 kg of RYL and four filled with 7 kg of RN, both filling a volume of 0.073 m³. After reaching an irrigation depth sufficient to drain water from the containers and soil accommodation, undisturbed samples were taken to develop the characteristic curve of soil water retention by the Richards pressure chamber method. The water retention equations of RYL and RN were adjusted by the model proposed by Van Genuchten (1980), using the Mualem constraint and RETC software (van Genuchten et al., 1991), as well as soil moisture at field capacity (ϴfc) at -10 kPa for RYL and -5 kPa for RN, and permanent wilting point (ϴpwp) at -1500 kPa for both soils (Table 2). ϴ: volumetric moisture (cm³ cm -3 ); h: matric potential (kPa); ϴfc: soil moisture at field capacity on a volume basis (cm 3 cm -3 ); ϴpwp: soil moisture at permanent wilting point on a volume basis (cm 3 cm -3 ); R²: coefficient of determination; **Significant at 0.05.

Monitoring of the matric potential of RYL and RN and data storage
The automation structure was subdivided into two main systems, one consisting of monitoring and storing matric potential data and the other consisting of drip irrigation. For monitoring the soil matric potential and storing the readings, a system based on an Arduino Mega 2560 microcontroller board was created, connected to external electronic modules and pressure transducers.
The Arduino board is equipped with Atmel AVR microcontrollers and has serial communication with analog and digital interface for connection to external hardware. The microcontroller is programmed with open source software from the Arduino project website (http://www.arduino.cc). This software is written in Java, and, in addition to providing the environment for the development of programming codes, it is used to compile and upload programs for the microcontroller. All codes are written in a language similar to C/C ++ with some simplifications and modifications.
The type of sensor used in the electronic tensiometer was the piezoresistive differential pressure transducer MPX5700DP (Freescale Semiconductor ® ), with temperature compensation and amplification circuit, which provides a differential linear voltage output from 0 to 700 kPa. The pressure transducer has as sensitive elements monolithic silicon piezoresistors, which generate an output voltage that varies according to the pressure applied. According to the manufacturer's technical specification, sensor sensitivity corresponds to 6.4 mV/kPa, requiring a 5 V power supply, and providing a maximum output voltage of 4.7 V and an offset of 0.2 V for the pressure range of 0 to 700 kPa. Pressure transducers with different specifications and resolutions have been used in scientific applications over the years (Greswell et al., 2009;Babatunde et al., 2016), and recently in tensiometers as a mechanism for reading the soil watermatric potential (Thalheimer, 2013;Arruda et al., 2017).
To verify the sensitivity of the MPX5700DP transducer to differential pressures relative to the atmospheric pressure inside the tensiometer due to matric suction, a calibration procedure was conducted in the laboratory of water analysis. For this purpose, a differential mercury Umanometer was used, connected to a tensiometer that was filled with water and sealed at its lower end (without the use of a porous capsule) and connected at the upper end to a pressure transducer and a 100 mL syringe, used for the application of successive suction pressures. Thus, each displacement of the mercury column corresponded to a pressure reading on the transducer. The difference relative to the atmospheric pressure observed in the mercury column was calculated by Equation 1.

∆ =
(1) Where, ΔP = pressure read by the Hg manometer (kPa); H = height of the mercury column (m); g = gravitational acceleration (9.81 m s -2 ); ρ = density of mercury (13.6 g cm -3 ). The method of least squares regression was used to fit the functional relationship between the suction pressure values obtained by the mercury manometer and the pressure transducer. The F test of regression analysis of variance was used to test the hypotheses for validation of the regression coefficients.

Construction of the electronic tensiometer
The electronic tensiometer consisted of a modification of a conventional ½" white PVC (polyvinyl chloride) tensiometer model, with adaptation for connecting the pressure transducer at its upper end (Figure 1). To evaluate the effect of noise in the readings of the pressure transducer, originated from electric current oscillations in its output signal (common to this type of sensor according to Reodique and Schultz, 2005), a moving average filter was applied with order = 10. In this filter, a set of readings from the transducer output signal is converted into a pre-established sample of size M (M = 10). The first value of the moving average is obtained by the average of the first sample; the second value of the average from the exclusion of the first number in the series, including the next reading under a sample of the same size M; and so on, according to Equation 2.
Where, y[i] = moving average; M = sample order (or size); x = output signal. Readings of the electronic tensiometers were obtained every 120 s and the data were recorded in a .txt file on an SD Card module. Each recording was associated with the respective timestamps from the integration of an RTC (Real Time Clock) module.

Electronic circuit and automation components
The hardware of the irrigation automation control system consisted of an integration between an electronic tensiometer, an Arduino board, an RTC module, an SD Card module, relay modules, ½" solenoid valves, and a 1/3 hp single-phase motor. A 7.5 V source was used to supply electrical power to the Arduino board, and the 5 V output of the Arduino board was used as source power for pressure transducers and relay modules. All sources were connected to a line filter connected to the conventional power grid (220 V) (Figure 2).
Each relay module has 4 channels. Thus, two relay modules were used to drive eight solenoid valves, and a 1-channel relay was used to drive the 1/3 hp single-phase motor. For the connection of pressure transducers, eight analog ports of the Arduino board were used. The number of valves is limited by the number of channels in the relay module, and the number of transducers that can be used simultaneously depends on the number of analog ports of the Arduino board used. The Arduino Mega board enables 16 simultaneous connections.

Components and functioning of the drip irrigation system
The turbulent flow drip irrigation system consisted of online emitters installed in 16 mm external diameter tubes, with a flow rate of 4.0 L h -1 at a service pressure of 10 m.w.c., controlled by a pressure regulator. Each container has one emitter positioned 10 cm from the tensiometers. The following equipment were used: a 125 micron disc filter, pressure taps installed after the solenoid valves, a glycerin-filled Bourdon pressure gauge with an accuracy of 0.1 k.g.f. cm -2 , ball valves, hydraulic connections, and a 1000 L reservoir.
For programming irrigation automation, a code was developed containing a main loop and subroutines to perform the following procedures: i) measuring the matric potential provided at each reading and recording its respective timestamps; ii) storing the readings in a .txt file at predefined time intervals; iii) comparing the read values of matric potential with critical values defined by the user so that the system would activate the motor pump and open and close solenoid valves. In general, the programming consisted of applying the calibrated transfer function of the transducer, which converts the values of the analog/digital conversion into pressure units (kPa). The code also allows changing the temporal resolution of reading 7 Automation of irrigation by electronic tensiometry based … Rev. Ambient. Água vol. 15 n. 4, e2567 -Taubaté 2020 acquisition, the critical potentials, and the time required for irrigation.

RESULTS AND DISCUSSION
The coefficient of determination (R 2 ) of the pressure transducer calibration was 0.99, and the tests of the parameters of the regression equation showed levels of significance of p < 0.001 ( Figure 3A). Freire et al. (2018), evaluated the Bourdon vacuum meter and a digital tensiometer in comparison to the Hg manometer, the authors found that both devices overestimate the readings of the Hg manometer, and that the difference between readings increases as soil moisture decreases. The same was observed by Beraldo et al. (2012) when comparing the Hg manometer with a digital puncture tensiometer installed at a depth of 20 cm in an Oxisol. These authors found R² values between 0.88 and 0.99, close to those obtained in this study (0.99). For a matric potential of -12 kPa for RYL and -13 kPa for RN, sequential measurements of the matric potential were performed, without applying the moving average, for approximately 140 s, with a resolution of 10 s ( Figure 3B -Section 1). Readings ranged from -8.2 to -14.1 kPa in RYL, and from -8.8 to -17.7 kPa in RN, resulting in amplitudes of -5.9 and -8.9 kPa, respectively. The oscillations observed in this interval are due to variations in the electrical current in the transducer output signal. The occurrence of these variations in amplitudes of this magnitude can lead to incorrect activation of the irrigation system, as the difference between critical activation potentials is -5 kPa for both RYL and RN.
From the application of the moving average, there is an effective reduction of noise after 145 s ( Figure 3B -Section 2), thus establishing a variation within a range of -1.1 kPa for RYL and -1.4 kPa for RN. In this way, matric potentials more reliably represent the soil matric potential. In addition, the risk of incorrect activation of irrigation automation is eliminated. Regarding the efficiency of the adoption of the moving average in smoothing sensor readings, Zhuang et al. (2007) highlight that a good application of this method depends on the sampling rate of the readings obtained by the sensor, which should be sufficient to form a larger number of samples. However, this can be a limiting factor in sensors that have a high electrical consumption. In turn, the sensors used on the Arduino platform have the advantage of requiring low energy consumption, and can be powered by batteries and low-voltage photovoltaic systems (Bitella et al., 2014). The observed variation of the soil matric potential inside containers for the thresholds RYL/E1 and RN/E1 demonstrates the reduction of potentials due to evaporation and drainage of soil water, and its increase after the irrigations performed (Figure 4). Horizontal lines highlight the critical activation values and the potential value at field capacity for each soil type. There were fluctuations in the readings of the tensiometers until the moment of irrigation activation, and the moving average was efficient in reducing them. Notwithstanding, environmental and soil effects can cause small variations in electronic tensiometer readings over time. Fluctuations can be the result of diurnal changes in ambient temperature that can exert a contraction or expansion effect on the volume of air inside the tensiometer, and, consequently, alter the signal emitted by the sensitive mechanism of the pressure transducer (Thalheimer, 2013). Another issue that may be associated with this behavior is the dynamics of soil water redistribution, which, associated with evaporation and drainage, occurs differently between each soil type and between each container, and which may interfere with the matric potential close to the porous capsule of the tensiometer (Almeida et al., 2017).  During the 14-day evaluation period for irrigation automation, the values read by electronic tensiometers showed different responses in each soil type, which resulted in different irrigation cycles for RYL and RN. The number of irrigations in each control (Table 3) shows that as the critical potential of activation is reduced, the irrigation time increases and the frequency of irrigation decreases, thus resulting in the application of a smaller irrigation volume. Regarding the different thresholds in RYL, the RYL/E2 showed the largest deviation in relation to the activation potential (-1.2 kPa); for NR, the largest deviation was observed in RN/E2 (-0.6 kPa). Despite being generally below 1 kPa, the deviations shown are the result of the interruption of readings by the automation programming. During the monitoring of the potential, irrigation is activated in the tensiometer of the container that first reaches its critical value, at this moment, the monitoring of all the tensiometers is interrupted and starts again after completion of irrigation. This interruption may, at some point, cause the critical potential in the next control tensiometer to slightly exceed its activation threshold. The minimum and maximum times required for irrigation in RYL were 3.1 and 5.3 min for the matric potentials of -20 and -35 kPa, respectively. For RN, the minimum and maximum irrigation times were 2 and 3.2 min for the matric potentials of -10 and -25 kPa, respectively. Regarding the maintenance of matric potentials within the established critical thresholds, the CV of the matric potentials of RYL ranged from 1.5 to 4.7% at irrigation activation, and from 9.9 to 23.1% at the end of irrigation (Table 3). For RN, the CV of the potentials ranged from 0.6 to 3.9% at irrigation activation, and from 12.4 to 15.4% at the end of irrigation. The automation programming was carried out so that at the end of each irrigation event the potential was close to field capacity in each soil type, being -10 kPa for RYL and -5 kPa for RN. However, at the end of some events, this potential was above the value used in the programming. This behavior is expected because after the end of each irrigation, the wetting front continues to move downwards increasing the soil moisture and the matric potential until a balanced condition is established in the porous capsule region (Freire et al., 2018).
From these results, irrigation control via matric potential can be considered satisfactory, since the coefficients of variation of the potentials, both at the time of activation and at the end of irrigation, were close to 20% in all thresholds for both RYL and RN. This behavior of the automation system was observed throughout an evaluation period of 14 days, with a total of 19 activations for RYL and 31 activations for RN. According to Almeida et al. (2017), an irrigation controller is considered adequate when critical values are kept within a tolerance of up to 20% in relation to the adopted threshold, and this variation must occur in at least 90% of the operating time of the system.
Despite not being able to act on the entire range of available soil water, tensiometers are extremely efficient in monitoring moisture in the wet range. Theoretically, tensiometers can measure up to 100 kPa without breaking their hydraulic column. In sandy soils, this value represents about 70% of the available water. Nonetheless, in clayey soils, only 40% of the available water can be monitored (Braga and Calgaro, 2010). Even so, in general, higher critical potentials (close to field capacity: -10 to -30 kPa) are used in agricultural crops more sensitive to water stress, while lower potentials (-40 to -60 kPa) are adopted in more tolerant crops (Bianchi et al., 2017). Considering the available water as the soil moisture interval between the permanent wilting point (-1500 kPa) and the field capacity (-10 kPa for RYL and -5 kPa for RN), the automation system in RYL acted in the monitoring of 21, 27, 32, and 36% of the water available in the case of the thresholds of -20, -25, -30, and -35 kPa, respectively; in NR, monitoring corresponded to 46, 62, 76, and 77% of the water available in the case of the thresholds of -10, -15, -20, and -25 kPa, respectively.
Tensiometers must be installed considering the best possible contact between the porous capsule and the soil. This is possible in a moisture condition that facilitates the introduction of the tensiometer at the desired depth. Tensiometers generally need to be refilled with water for the continuity of the readings; at that moment, it is crucial that the handling of the equipment does not affect the contact of the porous capsule with the soil. When the water level inside the tensiometer is close to ground level, it is recommended to refill it up to the level of the pressure transducer adapter. This is even more important in RN, where, in a low moisture condition, any improper handling of the equipment can impair the contact of the capsule with the ground and, consequently, the matric potential readings.
Regarding the construction of tensiometers, greater attention should be paid to making the devices, with special care being taken to seal the connections between the porous capsule and the pressure transducer with the tube. Furthermore, the integrity of electronic components must be evaluated, so that there are no short circuits that can damage the entire automation system. It is noteworthy that the electronic components used in the Arduino platform are simple to manufacture and, if not properly installed and protected from the weather conditions, their life span may be reduced. Operation of the electronic tensiometer in the field can be verified by monitoring the input (Vcc) and output (Signal) voltages of the pressure transducer, which can be performed with the aid of a multimeter adjusted to the maximum voltage of 20 V.
Ground, Vcc, and Signal pins of the transducer are easily identified in the manufacturer's datasheet. Another component that demands attention during system operation is the RTC module, which requires a 3 V CR2032 lithium battery for functioning. The need to change it regularly should be checked so that there are no errors in data file timestamps for matric potential monitoring.
The automation system is simple to build and its programming can be easily adjusted according to the needs of the user. These characteristics are important in its application by small producers, since it is possible to adopt a low-cost irrigation automation system that acts according to the soil water dynamics, thus leading to rational use of water in the irrigation, which can be replicated in temperature-controlled greenhouses.

CONCLUSIONS
The pressure transducer was efficient as a reading mechanism in electronic tensiometers for monitoring the matric potential in the wet soil range between -20 and -35 kPa in RYL and between -10 and -25 kPa in RN.
The automation system worked accurately in the control of irrigation in RYL and RN in a controlled environment, responding effectively to the programming executed by the Arduino microcontroller board.
Using the moving average method to smooth the pressure transducer output signal is efficient in correcting irregular readings that can interfere with irrigation automation.