scieee AI-readable full text Open interactive document viewer

Development and testing of hygrometers with Arduino low-cost electronic components

Batllori Guardiola, Núria

Abstract

Soil moisture and its availability to encourage plant growth is a key factor in agricultural productivity. There are automated irrigation systems to make the agricultural labour easier and give the crops the daily water needed. But these irrigation systems work without regard to the needs of the soil. There exist low-cost sensors that determine what the soil moisture is which can help farmers to make more accurate irrigation and get better soil yield and water resources. The project test three low-cost Arduino sensors (resistive basic sensor code B071LH5Z9D, coated resistive IC Station B076DDWDJK, and capacitive SongHe B07SYBSHGX), to understand their behavior and introduce improvements to have more accurate readings. To perform the experiments, three types of soils (loamy, sand, clay) were used. First, the calibration curve of each sensor was performed for each soil. It was found that the Resistive sensor has a different curve depending on the type of soil. However, for the Resistive coated sensor and the Capacitive sensor, the calibration curves did not vary greatly depending on the type of soil. The only difference between these two sensors was that the Capacitive is capable of reading a wider range of VWC (0% -30%) than the Resistive coated (0% -15%). Beyond the calibration curves, other experiments were performed on continuous readings of VWC under ambient conditions in order to see which external factors influence the sensor readings. It was found that Resistive sensors are linear influenced by soil temperature (R2 > 0.874). This is why the Resistive sensor was tested by another experiment to see the effect of temperature: For each soil, 3 samples were prepared of the 15%, 20% and 25% VWC (total 9 samples for each type of soil) and then, a sample of each VWC was put in different environments (refrigerator, another in the sun and the last at room temperature). By this way, it was possible to perform an accurate VWC readings using 3 different temperatures. The result of this experiment demonstrates the close relationship between the temperature of the floor, the VWC and the reading of the sensor allowing thus to correct the readings in function of the temperature and obtain more precise results. Resisitve sensor is easily corroded that is why a second type of Resistive sensor was used with an anticorrosion coat. Although the temperature effect for the Resistive sensors can be corrected, the accuracy is still higher for the Capacitive one. The same tests as for the Resistive sensors were done using the Capacitive sensor and it was found out that it is not so influenced by the temperature, which can be dispensed with. That is why, once its calibration curve was obtained, this last sensor is the one used to design an automated irrigation system with Arduino. To sum up, resistive sensors could be used punctually, that is, they are not useful for continuous monitoring of soil moisture, whereas, capacitive sensors serve for prolonged soil moisutre controls through time. However, capacitive sensors are influenced by more structural soil factors, ie soil compaction and the depth at which the sensor is located. The proposed low-cost automatic irrigation system can cost between 42 and 124 euros, depending on where the necessary items are purchased.

Full text

POLITECNICO DI TORINO Master’s Degree in Industrial Engineering Master’s Degree Thesis Development and testing of hygrometers with Arduino low-cost electronic components Supervisors Ph.D. Alessandro CASASSO Dra. Costanza GAMBERINI Candidate Núria BATLLORI GUARDIOLA September 2020 Summary Soil moisture and its availability to encourage plant growth is a key factor in agricultural productivity. There are automated irrigation systems to make the agricultural labour easier and give the crops the daily water needed. But these irrigation systems work without regard to the needs of the soil. There exist low-cost sensors that determine what the soil moisture is which can help farmers to make more accurate irrigation and get better soil yield and water resources. The project test three low-cost Arduino sensors (resistive basic sensor code B071LH5Z9D, coated resistive IC Station B076DDWDJK, and capacitive SongHe B07SYBSHGX), to understand their behavior and introduce improvements to have more accurate readings. To perform the experiments, three types of soils (loamy, sand, clay) were used. First, the calibration curve of each sensor was performed for each soil. It was found that the Resistive sensor has a different curve depending on the type of soil. However, for the Resistive coated sensor and the Capacitive sensor, the calibration curves did not vary greatly depending on the type of soil. The only difference between these two sensors was that the Capacitive is capable of reading a wider range of VWC (0% -30%) than the Resistive coated (0% -15%). Beyond the calibration curves, other experiments were performed on continuous readings of VWC under ambient conditions in order to see which external factors influence the sensor readings. It was found that Resistive sensors are linear influenced by soil temperature ( R2> 0 . 874). This is why the Resistive sensor was tested by another experiment to see the effect of temperature: For each soil, 3 samples were prepared of the 15%, 20% and 25% VWC (total 9 samples for each type of soil) and then, a sample of each VWC was put in different environments (refrigerator, another in the sun and the last at room temperature). By this way, it was possible to perform an accurate VWC readings using 3 different temperatures. The result of this experiment demonstrates the close relationship between the temperature of the floor, the VWC and the reading of the sensor allowing thus to correct the readings in function of the temperature and obtain more precise results. Resisitve sensor is easily corroded that is why a second type of Resistive sensor was used with an anticorrosion coat. Although the temperature effect for the Resistive sensors can be corrected, the accuracy is still higher for the Capacitive one. The same tests as ii for the Resistive sensors were done using the Capacitive sensor and it was found out that it is not so influenced by the temperature, which can be dispensed with. That is why, once its calibration curve was obtained, this last sensor is the one used to design an automated irrigation system with Arduino. To sum up, resistive sensors could be used punctually, that is, they are not useful for continuous monitoring of soil moisture, whereas, capacitive sensors serve for prolonged soil moisutre controls through time. However, capacitive sensors are influenced by more structural soil factors, ie soil compaction and the depth at which the sensor is located. The proposed low-cost automatic irrigation system can cost between 42 and 124 euros, depending on where the necessary items are purchased. iii Acknowledgements First of all, I want to thank my tutors, Alessandro and Constanza, for their help with the work, the recommendations, advice and especially for the patience they have had to tutor this thesis in some strange circumstances of online Erasmus. I am grateful for Ivan advises and help with electronic issues. And finally, I want to thank my parents and Pau for their unconditional support in my last student stage. iv Table of Contents List of Tables viii List of Figures x Acronyms xiv 0 Foreword 1 1 Calibration of sensors 3 1.1 Soil water content: concepts and techniques . . . . . . . . . . . . . 3 1.1.1 Basicconcepts.......................... 3 1.1.2 Measurement techniques . . . . . . . . . . . . . . . . . . . . 5 1.1.3 Calibraton of sensors . . . . . . . . . . . . . . . . . . . . . . 6 1.2 Resistivesensor............................. 7 1.2.1 Facts on the Resistive sensor (code B071LH529D) . . . . . . 7 1.2.2 Test 0: Sensor stabilization time . . . . . . . . . . . . . . . . 7 1.2.3 Test 1: Calibration with different soils and known VWC values 9 1.2.4 Test 2: Continuous VWC measurements . . . . . . . . . . . 10 1.2.5 Test 3: Dependence of minimum signal value on temperature 11 1.2.6 Soil temperature sensor . . . . . . . . . . . . . . . . . . . . . 13 1.2.7 Test 4: Soil-specific calibration curves based on VWC and temperature . . . . . . . . . . . . . . . . . . . . . 19 1.2.8 Main ideas obtained from resistive sensor tests . . . . . . . . 22 1.3 Coated resistive sensor . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.3.1 Facts on the Coated Resistive Sensor (code B076DDWDJK)......................... 24 1.3.2 Test 5: Calibration with different soils and known VWC . . 26 1.3.3 Test 6: Dependence of minimum signal value and known VWCvalues........................... 28 1.3.4 Main ideas obtained from Coated Resistive Sensor . . . . . . 30 1.4 Capacitive Soil Moisture Sensor . . . . . . . . . . . . . . . . . . . . 30 vi 1.4.1 Facts on the capacitive sensor (code B07SYBSHGX) . . . . 30 1.4.2 Test 7: Calibration with different soils and known VWC values 31 1.4.3 Test 8: Dependence of minimum signal value on temperature 33 1.4.4 Test 9: Continuous VWC measurments . . . . . . . . . . . . 35 1.4.5 Main ideas obtained from Capacitive sensor . . . . . . . . . 37 1.5 Discussion................................ 38 2 Automated Irrigation System 41 2.1 Designofthesystem .......................... 41 2.1.1 Wiring.............................. 45 2.2 Details on the components . . . . . . . . . . . . . . . . . . . . . . . 48 ArduinoUNO.......................... 48 DHT11 Digital Temperature and Humidity Sensor . . . . . . 49 Micro SD Card Shield . . . . . . . . . . . . . . . . . . . . . 49 Liquid Crystal Display 16x2 . . . . . . . . . . . . . . . . . . 50 RTCDS3231 .......................... 51 RelayModule.......................... 52 Capacitive Soil Moisture v1.2 sensor . . . . . . . . . . . . . 52 Solar panel charger 5V . . . . . . . . . . . . . . . . . . . . . 52 Solenoidvalve12V ....................... 53 2.3 Costevaluation ............................. 54 3 Conclusions 56 A Figures from Resistive soil moisture sensor (Code B071LH529D) 58 B Arduino code 62 vii List of Tables 1.1 Density of each tyepe of soil . . . . . . . . . . . . . . . . . . . . . . 4 1.2 Linear correlation of the Resistive sensor curve for each soil type . . 10 1.3 Linear correlation between Temperature from LM35 (T) and Sensor ResistiveOutput ............................ 14 1.4 Linear correlation between Temperature from DS18B20 (T) and Resistive Sensor Output . . . . . . . . . . . . . . . . . . . . . . . . 17 1.5 Linear correlation between Temperature DS18B20 corrected (T) and Resistive Sensor Output . . . . . . . . . . . . . . . . . . . . . . . . 18 1.6 Linear correlation of Temperature and Sensor readings for the loam sample.................................. 22 1.7 Linear correlation of Temperature and Sensor readings for the sand sample.................................. 23 1.8 Linear correlation of Temperature and Sensor readings for the clay sample.................................. 24 1.9 Linear correlation of the Resistive Coated sensor curve for each soil type ................................... 28 1.10 Linear correlation of the Capacitive sensor curve for each soil type. 33 1.11 Advantages, inconveniences and applications of each VWC sensor tested................................... 39 1.12 A comparison of each VWC sensor benefits. . . . . . . . . . . . . . 40 1.13 Comparison of the R2 of each regression line for each soil texture andsensor................................ 40 2.1 Components connection to Ardunio UNO. . . . . . . . . . . . . . . 47 2.2 Technical parameters of the Arduino UNO. . . . . . . . . . . . . . . 49 2.3 Technical parameters of the DHT11 Temperature and Relative air Humiditysensor............................. 49 2.4 Technical parameters of the SD Module. . . . . . . . . . . . . . . . 50 2.5 Technical parameters of the Liquid Crystal Display (16x2) . . . . . 51 2.6 Technical parameters of the Real Time Clock DS3231. . . . . . . . . 51 2.7 Technical parameters of the 2 Relays Module . . . . . . . . . . . . . 52 viii Chapter 0 Foreword Soil moisture and its availability to encourage plant growth is a key factor in agricultural productivity. Whether the humidity is too low or too high it can cause problems in crops, from a loss of yield or death of plants to root diseases and waste of water resources. Water is a delivery mechanism for any nutrients that are not tightly bound to the soil, therefore good water management also means good nutrient management. Precise control of both water and nutrient content, leads to healthier crops, higher yields and productivity can be significantly increased. Beyond productivity in farm, good water management can produce economic savings. Costs in agriculture are playing an increasingly important and decisive role. Competition in prices for imported products is reducing the profit margin of local producers. This fact combined with the more restrictive environmental regulations, the increase of labor costs and the more competition for water resources exerts a pressure on farmers to reduce the costs of their productive activity. That is why their aim is to obtain more efficient irrigation systems that allow a reduction in both labor costs and waste of water resources. There exists some easily automated systems as overhead irrigation systems like sprinkler-, and drip-irrigation, and subirrigation systems like flooded floor irrigation. However, the efficiency of such systems must be optimally exploited through a constant monitoring of soil moisture in order to provide the optimal quantity of water to plants. Some automated irrigation systems run by setting an irrigation schedule, like the ones that run a determined time and duration, not based on the soil needs. Water waste or underestimate irrigation needs are a very common weakness of this kind of irrigation automated systems. Due to all these problems, there exists some automatic irrigation controllers based on the soil needs [1]. The characterization of in-field soil moisture conditions through some real-time measurement is able to get rid of many uncertainties associated with more arbitrary methods of irrigation scheduling. However, many of these programs use expensive dataloggers and accompanying software. Relatively 1 Foreword new, low-cost open-source microcontrollers provide an alternative way to build sensor-based irrigation controllers for both agricultural and domestic applications [2]. Simple and reliable microcontrollers with broad functionality have been available since 2005, when Arduino (Ivrea, Italy) made the first of its models available. Arduino is widely used for automatic irrigation projects. Arduino hygrometers output can be easily correlated to the Volumetric Water Content (VWC) of a soil which is a useful measurement to get an idea of the soil moisture conditions. The behaviour of these kind of sensors is not as precise as the expensive ones and also some of them could be influenced by external factors as air temperature, air humidity, salinity or kind of soil. This project aims to study the behaviour of 3 different soil moisture sensors (Resistive sensor code B071LH5Z9D, Coated Resistive IC Station B076DDWDJK, and Capacitive SongHe B07SYBSHGX) pointing out their strengths and weakness, understanding how their output signal correlates to VWC and which kinds of corrections are necessary (e.g., depending on temperature). By this way, it is going to find out what the cheapest hygrometer is and which calibration curve better fits the real VWC. In order to get a precise VWC reading, it is recommended to do an specific calibration for each type of soil, but it increases the irrigation system cost. This study therefore aims at identifying sensors that behaves similarly even if different type of soils are used, getting a general calibration curve. Once the best hygrometer is selected and in order to complete the project, an autonomous irrigation system will be designed and tested in a small urban garden. The structure of this project is developed in two large blocks. The first block, described in Chapter 1, consists in the experimental investigation of the operation of soil moisture sensors. Within this chapter, it is studied how sensors respond to situations depending on soil moisture, soil type and environmental conditions. Correlations were identified between signal and VWC and, if necessary, soil temperature and soil type. There correlations are used to derive calibration equations and hence to transform the electrical signal of the soil humidity (and, if present, soil temperature) sensors into a VWC. The second block is described in Chapter 2 and consist in the design of an automatic irrigation system using the chosen sensor. The chapter is divided into three parts. First, the design of the irrigation system is described including the design of the hardware and the software parts. Secondly, components are described. Finally, the economic valuation of the system is made. The project ends with the general conclusions of the two blocks and proposals for further studies or projects. 2 Chapter 1 Calibration of sensors 1.1 Soil water content: concepts and techniques 1.1.1 Basic concepts The term calibration implies the establishment of a precise relationship between a new system of measurement and one which is long established and accepted as a standard method for measuring the same variable. This standard method is the Volumetric Water Content (VWC), defined as: V WC(%) = Wetsoil(m3)−drysoil(m3) Drysoil(m3) =Watervolume(ml) Drysoilvolume(ml) (1.1) Soil has the function of storing water from the time it is watered until the plants use it. Water is found in the spaces between soil particles and the force of gravity constantly acts on the ground water to move it down. There exists a force that prevents water from moving down and its known as the surface tension, which allows water to stick to the soil particles. The smaller the soil particles, the more surface area available and the more water the soil has the ability to retain. Therefore, the ability of water to move through the soil and be stored highly depends on the type of soil. Soils with sandy particles, which have coarse grains (diameter from 0.05 mm to 2 mm), retain a small amount of water and the rest drains quickly down. In contrast, clay soils, which have small grains (diameter <0.002 mm) [3], have a large available surface that retains water leaving only a small part of the water to drain down. Soils with a high water retention capacity can store large quantities with respect to their own volume. 3 Calibration of sensors In a soil with very small particles, the same surface tensile forces that allow a large water retention capacity, also make it difficult to extract it and use it by plants. The movement of water is difficult and plants need more energy to get it out. The force that plants exert is called tension. That is why, the ideal soil is a loamy soil with a variety of particle sizes and structure which is able to retain large amount of water and is also easy for plants to withdraw it. Depending on the type of soil, plants may have more or less water available. The limits of available water in terms of VWC depending on the soil type are the Field capacity ( θF C ) and Wilting Point ( θW P ). θF C is the VWC in a soil containing all of the water that can be held by surface tension (when all pores are filled with water) while the θW P is the minimal moisture the plant requires not to wilt. These values are a practical measure of soil water holding and the difference between them is defined as the Available Water (Figure 1.1) [4]. In this project, three soil types are used to test each soil moisture sensor. The first one was obtained from the garden (loamy soil), the second one, from the riverside (sandy soil) and, the last one, from the edge of the field (clayey). The density of each soil type are specified in Table 1.1. Density [kg/m3] Soil 1: Loam 927 Soil 2: Sand 1300 Soil 3: Clay 1282 Table 1.1: Density of each tyepe of soil Figure 1.1: Water content at θF C and at θW P , and available water. 4 Calibration of sensors 1.1.2 Measurement techniques There exists different techniques to measure the soil water content from satellitebased technology for continental scale to site-scale methods including destructive gravimetric method as electromagnetic, nuclear or tensiometric ones [5]. Large-scale methods are not being considered in this study. The in-situ techniques that measure at a single location in a plot, garden or field include four basic methods: Electrical resistance, Dielectric permitivity (TDR, FDR, TDT, Capacitance), thermal conductivity and thermalized neutrons. The most common of these techniques are the resistance and the dielectric ones. Resistance sensors measure the soil water content percentage by creating a voltage difference across two electrodes, allowing a small amount of current to flow between them and outputting a value of resistance or electrical conductivity. Water is a poor conductive material and sensor readings are influenced by other external factors such as temperature effects or the salt ion polarization [6]. Dielectric sensors are a general category of sensors that measure the chargestoring capacity of the soil. Charge-storing measures are better than electrical conductivity ones because it just polarize water molecules storing a small amount of charge without polarizing the salt ions. The dielectric constant is the ability to store electrical charge and it is different depending on the material [6]. Water is the element that composes soil which can change significantly the dielectric constant, therefore, it can be correlated to the VWC. Dielectric sensors fall into three general categories: Capacitance, TDR, TDT and FDR. ∗ Capacitance sensors use just the soil as a capacitor element by which reads its storing capacity. ∗ TDR sensors measure the travel time of a reflected wave of electrical energy though a line. This time is correlated to the dielectric constant of the soil. ∗ TDT is similar to TDR however it measures the transmission of a pulse along a looped, or closed circuit. It measures the time from the start to the end of the loop for the propagation of an electrical pulse. ∗ FDR sensors use the soil as a capacitor element, and measure the maximum resonant frequency in the electrical circuit relating it to the VWC. There exist other instruments to measure water conditions of the soil, like tensiometers which measure the matrix water potential. Currently, studies have been conducted on the efficiency and accuracy of soil moisture sensor. The wide variety of sensors, manufacturers and methods combined with the growing need to know the characteristics of the soil, have led to many 5 Calibration of sensors authors to evaluate the operation of sensors available on the market, especially the most sophisticated ones. Chávez et al., [7] (2011) experimented with the CS616 (FDR), TDT, and 5TE (FDR) sensors and experienced VWC errors with the increased bulk soil Electrical Conductivity. Measurements were then compared to VWC determined by gravimetric sampling. FDR sensors were influenced by fluctuations in soil temperature and had greater error than the TDT one. For all sensors the errors were larger in the soil with higher clay content. Singh et al., [8] (2020) assessed the response to different soils of the GS-1 (Meter Group) sensor based on FDR technology. They compared the sensor readings from an undisturbed soil and disturbed soil from two different zones (silt loam and silty clay loam) with VWC determined by gravimetric sampling. The best correlations was found with the undisturbed soil samples. They concluded that the sensor output is influenced by the soil type. The results of their study should not be generalized and aim for an universal calibration for future applications. Many researchers have focused on the calibration of low-cost sensors which are used in different sensing techniques, such as capacitance-based sensors in order to design an automatic soil moisture monitoring system [9]. Ganjegunte et al.,[10] (2012) calibrate and test Watermark 200SS (electrical resistance device), 5TE (FDR) and Irrometer (Tensiometer) and compare the calibration curve of each one obtained from factory indications with the VWC from gravimetric method. Accuracy of three sensors with just factory calibration was lower than the ideal level for obtaining accurate soil water data. Results of the study suggested that accuracy of sensors can be greatly improved by site-specific calibration. Other studies [11] consider the effects of the physical and chemical properties of soil on the performances of soil moisture sensors. All these studies cited agree on the necessity of soil-specific calibration. Yet achieving consistent conclusions has been difficult so far for these low cost sensors. 1.1.3 Calibraton of sensors For this project, three different soil moisture sensors are used, the Resistive Sensor (code B071LH5Z9D) which is the most basic one, the coated Resistive IC Station (code B076DDWDJK), and Capacitive SongHe (code B07SYBSHGX). The calibration curve of each one is performed using the same procedure described in this section. The idea is to compare the output signal of each sensor, which is a tension (0-5V) for resistive sensors expressed in a range (0-1023) with the VWC. There are several methods to measure VWC [5]. In this study, gravimetric techniques are used to obtain samples with a determined amount of water, based on other studies [12]. First of all, completely dry soil samples are needed so, in order to ensure its dryness, the soil sample is kept in the oven at 200 º C for 2 hours. Once the soil 6 Calibration of sensors sample is dry and its cooled, depending on the soil density a determined amount of water is added each time to the soil sample to reach a VWC=5% until the field capacity is exceeded. For each VWC, three output values from each sensor are considered and the average of these is calculated in order to obtain a more accurate study. Finally, the calculated VWC values are correlated with the sensor values to obtain the calibration loop, ideally a linear correlation. 1.2 Resistive sensor 1.2.1 Facts on the Resistive sensor (code B071LH529D) Resistive Soil Moisture Sensors (Figure 1.2) consist of two conductive probes, used as an electrodes, which pass current through the soil sample [13]. The device reads the resistance of soil by correlating the output voltage through the two electrodes. The higher the water content of the soil is, the better it will conduct the electricity because of the resistance decrease. If the soil is completely dry, the resistance is high and there will not be electricity current passing through the probes. The sensor consists of a probe, with two properly separated terminals, and a module that contains a very stable LM393 SMD (surface welded) comparator circuit, a power LED and a digital output activation LED. The latter has 2 connection pins towards the probe, 2 pins for power (VCC, GND) and 2 data pins: Digital (D0) and Analogical (A0). The input voltage is from 3.3v to 5V and the output voltage is 4.2V. Operating current is 35mA [Data-sheet]. Some authors experimented with this kind of sensors. Saleh [13] evaluate the performance of low-cost resistive soil moisture sensors. Soil moisture percentages were logged daily to obtain curves relating moisture percentages to voltages provided by the sensors. The results revealed that resistivity based sensors were affected by several sources of error (Electrolytic corrosion, Soil ion concentration, Temperature and installation error), which lead to severe problems regarding accuracy and usability. The Resistive Soil Moisture sensor costs around 1.4 € , depending on the website [Link]. 1.2.2 Test 0: Sensor stabilization time In general, in order to be able to get explanatory values of hygrometers, it is necessary to understand how the sensor behaves. Therefore, it is necessary to know which is the minimum signal the sensor delivers, which is obtained when the sensor is immersed into the water, and which is the time needed to got the value stabilized, which is the stabilization time. 7 Calibration of sensors Figure 1.2: FC28 Soil Moisture Resistive Sensors The output of Resistive sensor is the highest signal value (1023) in completely dry conditions, and a lower value when the environment around the sensor is totally wet. Figure 1.3 shows the the analogical output of Resistive sensor since the sensor was dry until the signal got stabilized under water. For this first test into the water, stabilization time was between 60 and 100 seconds and the water environment sensor signal was 168. Using these two extreme values (168-1023), the sensitivity range of the soil moisture sensors can be determined. Figure 1.3: Calibration Resistive sensor into water at 21ºC. The same test was done using two resistive sensors, a new one and a partially 8 Calibration of sensors corroded one. (Figure A.1) 1.2.3 Test 1: Calibration with different soils and known VWC values Each soil has different characteristics about retaining water. A calibration curve was made for each of the three types of soils (loam, sand and clay). In this way, the sensitive VWC range of the sensor for each type of soil was found and it was checked if the soil type influences the sensor readings. The procedure to draw the sensor’s calibration curve is described in 1.1.3 section. The results of the calibration curves for each type of soil are represented at Figure 1.4 and Figure 1.5. Figure 1.4: Comparison of the calibration curves for each soil Figure 1.5: Linear correlation with each type of soil For the loam soil sample, the calibration curve was performed indoor with 9 Calibration of sensors 150 grams of sample at 22 º C and 59% relative air humidity. Sensor acquired significant data between 0%-25% of VWC. Over this range, the sensor got saturated. Calibration curve could be simplified by a linear correlation taking values from 0%-25% of VWC resulting in good linear correlation (R2>0.99). For the sand soil sample, the calibration curve was performed indoor with 150 grams of sample at 25.8 º C. Sensor acquired significant data between 0%-50% of VWC. The linear correlation was done taking values from 0%-50% of VWC with a good R square value (R2>0.9). For the clay soil sample, the calibration curve was performed indoor with 150 grams of sample at 24.4 º C. Sensor acquired significant data between 0%-30% of VWC. Over this range, the sensor got saturated. The linear correlation from 0%-30% of VWC value results good too, with an R2>0.95. Finally, comparing the 3 calibration curves, it is possible to understand how the sensor behaves differently depending on the type of soil in which it is located (i.e. for the same VWC it reads a different signal for each soil). This means that it will not be possible to generalize a curve for all soil types and these kind of sensors. However, the curves of clay and loam have a certain similarity, probably due to the size of the particles. Table 1.2 shows the summary of each linear correlation and it’s statistical values. Soil Moisture (SM) range R2Linear equation Loam 0% - 25% 0.99 Sensor = -2787.2 ·VWC + 1035.2 Sand 0% - 50% 0.94 Sensor = -1363.7 ·VWC + 1077.9 Clay 0% - 30% 0.97 Sensor = -2681 ·VWC + 1090.4 Table 1.2: Linear correlation of the Resistive sensor curve for each soil type 1.2.4 Test 2: Continuous VWC measurements − Introduction: Sensors could be influenced by other external factors during continuous measurements. It is important to understand how these factors such as air temperature or relative air humidity affect sensor readings. The best way to check if this influence exists, is by performing continuous readings of VWC by measuring this external factors. − Objective: Check the influence of external factors by continuous VWC measurments. − Materials: Arduino UNO, Resistive sensor, DHT11 Temperarue and Relative air humidity (Figure 1.6 sensor and module to store data on the SD card. 10 Calibration of sensors − Results: The idea to heat the samples into the oven was useful to have a wider range of temperatures, from 6.25 º C fridge, to 60.69 º C oven. Data obtained show a good relationship between the readings of soil moisture and soil temperature (Figure 1.16, Figure 1.17). The vertical dashed lines in the figures indicate the moment at which the samples have changed from environment (refrigerator, oven). The sensor got strange results between 13 º C to 60 º C due to the great change of temperature in a short time (the time when the soil probes were taken out from the fridge and put inside the heat oven). These weird results were not taken into account for the linear correlation (Table 1.4). R2Linear equation Loam 0.89 Sensor = -4.8049T + 976.49 Sand 0.99 Sensor = -5.1552 T + 922.09 Table 1.4: Linear correlation between Temperature from DS18B20 (T) and Resistive Sensor Output Figure 1.16: Temperature sensor response (fridge - oven) using corroded resistive sensor and 15% VWC Loam soil sample. From these results, two main ideas to improve this experiment emerged. The first one is to repeat the experiment using different soil moisture values in order to check if the linear relation between temperature and sensor output has the same slope, which would mean that temperature future corrections are not influenced by soil moisture value (Section 1.2.6).The second one is to avoid big temperature changes, which do not happen in nature either. For this second idea the procedure followed is quite different: 17 Calibration of sensors Figure 1.17: Temperature sensor response (fridge - oven) using not corroded resistive sensor and 20% VWC sand soil sample. – Get data from the soil samples for 3h into the fridge until the temperature gets stabilized. Temperature range: 23.6 º C (room temperature) - 8.25 º C (fridge) –Take the samples out of the fridge: 8.25ºC - 20.62ºC. (1h 15min) – Put the samples into the oven 45 min heated to lower temperature than 120ºC. Temperature range: 12.5ºC - 44.94ºC. –Let the samples cool down from 44.94ºC - room temperature. Using these second procedure, temperature readings were more accurate (Figure 1.18 and Figure 1.19) and it was found a good linear correlation between soil temperature and the sensor readings. As is shown at Table 1.5, R2 values are grater than 0.97. R2Linear equation Loam 0.97 Sensor = -4.4519 T + 579.27 Sand 0.99 Sensor = - 6.6662 T + 951.5 Table 1.5: Linear correlation between Temperature DS18B20 corrected (T) and Resistive Sensor Output These tests demonstrated how temperature is an influential factor for resistive sensor and its VWC readings. Using continuous lectures, it is shown how soil temperature variations on VWC readings are independent of the VWC of soil samples, as there is the almost the same temperature dependence, but in this case, changes in soil temperature influence differently depending on the type of soil used. In other words, the slope of the temperature-sensor lines is the same for the same 18 Calibration of sensors Figure 1.18: Temperature sensor smooth changes response (fridge - oven) using corroded resistive sensor and 25% VWC Loam soil sample. Figure 1.19: Temperature sensor smooth changes response (fridge - oven) using not corroded resistive sensor and 20% VWC sand soil sample. soil type, regardless of the VWC, but is different if it is compared between the two soil types (Figure 1.20 and Figure 1.21). In order to demonstrate the soil temperature influence in a more precise and determined way, discontinuous temperature and VWC sensor output can provide better precision. 1.2.7 Test 4: Soil-specific calibration curves based on VWC and temperature − Introduction: As seen previously, the Resistive sensor is influenced by soil temperature. This influence is quite clear but in order to demonstrate it in a 19 Calibration of sensors Figure 1.20: Slope (Temperature-Sensor) comparison of the 15%VWC and 25%VWC continuous lectures for the Loam sample. Figure 1.21: Slope (Temperature-Sensor) comparison of the 20%VWC and 30%VWC continuous lectures for the Sand sample. more precise way an experiment was done with discontinuous readings and varying the soil moisture. In this way, it lets the possibility to specify, on the one hand, the influence that the sensor has with the soil temperature for each soil and, on the other hand, if the temperature has the same influence due to different soil moisture values. − Objective: Determine the relationship between temperature and humidity sensor reading from 3 discrete readings for each soil moisture getting data from the three types of soil (loam, a sand and a clay). − Materials: Arduino UNO, Resistive soil humidity sensor, DS18B20 soil temperature sensor and 9 soil samples of each soil. 20 Calibration of sensors − Procedure: For each kind of soil, three soil moisture samples of 15%, 20% and 25% VWC were prepared and each of which is distributed was 3 different containers (0.1 liter/container). Each one remained for 4 hours in 3 rooms with different temperatures: sun (40ºC), fridge (8ºC) and room temperature (24 º C). All samples were covered with a transparent film to prevent them from losing humidity. After 4 hours, it were ensured that containers had not lost weight and the respective measurements of soil temperature and soil moisture values were made. By this method, 9 points were be obtained for each type of soil and 3 points for each VWC value. Figure 1.22: Sand soil samples of 15%, 20% and 25% VWC warming up in the sun. −Data processing and results: Graphs obtained show what had been expected but it seemed that there was an error with the soil moisture measurements for sand (it affects the vertical axis interception, not the slope of the linear correlation). All the correlations were good as R2> 0,95 except the 15% VWC Sand correlation. Data obtained can be represented in a plane, i.e. linear correlation of two variables (VWC - Temperature, Sensor signal) can be derived using RStudio. The loam equation is 1.2 which has a good R2> 0 . 9. The statistics results are printed in Figure A.4. The same was done for the sand sample (Equation 1.3 R2< 0 . 9, Figure A.5) and for the clay sample (Equation 1.4 R2>0.99, Figure A.6). V WC%Loam = 63.916330 −0.35879 ·T−0.048124 ·Sensorsignal (1.2) 21 Calibration of sensors Figure 1.23: Loam sample points distribution for 3 temperatures and Resistive readings for 15% VWC, 20% VWC and 25% VWC. R2Linear equation 15% VWC 0.95 Sensor = -7.6951 ·T + 1004.4 20% VWC 0.99 Sensor = -8.5234 ·T + 958.06 25% VWC 0.95 Sensor = -5.9495 ·T + 773.31 Table 1.6: Linear correlation of Temperature and Sensor readings for the loam sample V WC%Sand = 37.944975 −0.146548 ·T−0.022537 ·Sensorsignal (1.3) V WC%Clay = 40.02599 −0.2006697 ·T−0.0259775 ·Sensorsignal (1.4) 1.2.8 Main ideas obtained from resistive sensor tests The soil moisture Resistive sensor is cheap (0.5-1.4 € ) and simple but the experiments performed proved its low accuracy. Corrosion is a major issue and it is due to the fact that, when the sensor is placed into the ground and the current starts circulating, the effect of electrolysis is produced and consequently the oxidation of the copper starts. This oxidation is one of the factors that reduces the accuracy of these types of sensors. It was seen how the reading of a new sensor and a partially corroded sensor varied. At the same conditions, both sensors have slightly 22 Calibration of sensors Figure 1.24: Sand sample points distribution for 3 temperatures and Resistive readings for 15% VWC, 20% VWC and 25% VWC. R2Linear equation 15% VWC 0.87 Sensor = -4.7991 ·T + 875.25 20% VWC 0.99 Sensor = -7.338 ·T + 917.26 25% VWC 0.96 Sensor = -6.3707 ·T + 568.88 Table 1.7: Linear correlation of Temperature and Sensor readings for the sand sample different behavior. The corroded sensor gives a higher signal value than the new one. The higher difference during the wet calibration is 50 which gives around 6 % of humidity reading error. Also the corroded one seems to have a quicker time response for changes (Figure A.1). Another problem seen is the influence of temperature on the readings of this sensor. If what is wanted is a cheap and, at the same time, accurate system to save water and time using an Resistive sensor, it is necessary to add a temperature probe to correct the readings, which makes the system more expensive. By correcting the readings, soil moisture values had acceptable error for clay (between 0.15% and 3.4%) and loam (between 0.4% and 11.5%), not for sand (between 0.5% and 21.7%) (Figures 1.26, 1.27 and 1.28). In addition, it was proved that Resistive sensor did not have the same behavior for each type of soil and it was not possible to provide a unique calibration function. This means that a soil-specific calibration is needed, which is a time-consuming. For soils with coarse grains, (e.g. sand) good soil compaction is necessary because of the poor contact of the soil with the sensor (Figure 1.24) . Continuous and discrete experiments with VWC and temperatures show similar 23 Calibration of sensors Figure 1.25: Clay sample points distribution for 3 temperatures and Resistive readings for 15% VWC, 20% VWC and 25% VWC. R2Linear equation 15% VWC 0.98 Sensor = -7.5292 ·T + 965.24 20% VWC 0.99 Sensor = -7.1169 ·T + 757.91 25% VWC 0.96 Sensor = -6.8886 ·T + 570.69 Table 1.8: Linear correlation of Temperature and Sensor readings for the clay sample results, therefore, it is possible to analyze using the continuous method which requires less preparation. These types of sensors are very useful for punctual readings without time prolongation, in which the effect of the corrosion is lower. Moreover they can be useful for wide reading intervals, not continuous ones. It is also important to stress that resistive sensors need a signal stabilization time, which it was seen to be between 60 and 100 seconds. 1.3 Coated resistive sensor 1.3.1 Facts on the Coated Resistive Sensor (code B076DDWDJK) One of the main problems observed with the Resistive sensor is the rapid corrosion, which adds reading errors and decreases the life of the sensor. There are sensors that 24 Calibration of sensors Figure 1.26: Scatter plot of loam sample: Real VWC values vs Calculated values from the two variable loam equation. Figure 1.27: Scatter plot of sand sample: Real VWC values vs Calculated values from the two variable sand equation. use the same functioning principle but have protection coating against corrosion. The sensor used in this section is the Coated Resistive sensor (B076DDWDJK) (Figure 1.29). This type of sensor will probably have the same characteristics as the basic Resistive Sensor. This section aims to check if these coated sensors offer improvements with respect to the Resistive Sensor. Therefore, it will be necessary to find out the calibration curves of the sensor for each type of soil and see if it is influenced by temperature to understand the influence of soil types on the readings. It consists of a prove with two properly separated and coated terminals and the comparator circuit with a power LED and digital output activation LED. As the first resistance sensor, it has 2 connection pins towards the prove, 2 pins for power (VCC, GND) and 2 data pins: Digital (D0) and Analogical (A0). The working 25 Calibration of sensors Figure 1.28: Scatter plot of clay sample: Real VWC values vs Calculated values from the two variable clay equation. Figure 1.29: Coated resistive sensor (B076DDWDJK) voltage is from 3.3V to 12V and the working current 20mA (30mA Output current) [Data-sheet]. The Coated Resistive Soil Moisture sensor costs around 10.3 € , depending on the website and delivery conditions. [Link] 1.3.2 Test 5: Calibration with different soils and known VWC As presented and developed for the resistive sensor, a calibration curve was made for each of the three types of soils (loam, sand and clay). The results of the calibration curves for each type of soil are represented at Figure 1.30, Figure 1.31 and Table 1.9). For the loam soil sample, the calibration curve was performed indoor with 120 grams of sample at 23,87 º C, using the same procedure as with the previous sensor. The sensor acquired significant data between 0%-15% VWC, 26 Calibration of sensors VWC range R2Linear equation Loam 0% - 30% 0.98 Sensor = -1105 ·VWC + 605.04 Sand 0% - 40% 0.96 Sensor = -699 ·VWC + 566.91 Clay 0% - 30% 0.98 Sensor = -912.62 ·VWC + 601.27 Table 1.10: Linear correlation of the Capacitive sensor curve for each soil type. curve is calculated using data from the three soils between 0 % and 30 % VWC. Although for the sand the range is wider, the generalization is more accurate using the range of clay and loam (Figure 1.38, Equation 1.6). Figure 1.38: Generalization Capacitive sensor curve SensorSignal =−934.44 ·V WC + 599.2(1.6) 1.4.3 Test 8: Dependence of minimum signal value on temperature − Introduction: As seen for Resistive sensors, water temperature is an influential factor for soil moisture readings and this could affect also the Capacitive sensor measurements. There may also be this influence for Capacitive sensors too. This is why, to obtain the maximum humidity signal that the sensor can read, the experiment is done at different temperatures, as previuosly done with the Resistive sensors. −Objective: –Find out the minimum value for the Capacitive sensor. –Find out the stabilization time 33 Calibration of sensors – Show if temperature is an influential factor for Capacitive sensor readings. − Materials: Arduino UNO, Capacitive soil moisture sensor V1.2, DS18B20 soil temperature sensor and module to store data on the SD card. − Procedure: Immerse the dry Capacitive sensor into the water at different temperatures (23,75ºC - 77ºC) and wait until the signal stabilizes. − Data treatment and results: Sensor got stabilized between 5 and 15 seconds (Figure 1.39). 9 different points (temperature-sensor signal) were obtained, which could be possible to correlate in order to check the temperature influence (Figure 1.40). Figure 1.39: Capacitive Sensor wet calibration with different temperatures. Figure 1.40: Linear Correlation of Capacitive sensor output at different water temperatures. 34 Calibration of sensors In conclusion, the Capacitive sensor is influenced by temperature much less than the two other resistive sensors. The range of temperatures the test was performed was very wide and would not occur in a soil under field conditions. With this wide range, the sensor signal only varied by 3.44%, so temperature is not an important factor. For each degree variation, the sensor adds 0.15 to the reading. In terms of stabilization time, the Capacitive sensor is faster (10 seconds average) than the Resistive one (80 seconds average 1.2.2. For future experiments, reference value for the maximum humidity will be the signal read by the water at room temperature (25 º C). It is important to take data placing the sensor at the same depth included in the recommended interval by manufacturer’s instructions (Figure 1.41) Figure 1.41: Recommended depth for Capacitive Soil Moisture sensor. because this sensor is high sensitive of changes of the soil depth. 1.4.4 Test 9: Continuous VWC measurments − Introduction: It was demonstrated that for Capacitive sensors the influence of water temperature is practically negligible, but other factors such as air relative humidity or air temperature may influence the reading of such sensors. In order to check this, it is necessary to see how the sensors really behave at field conditions. − Objective: Determine the influence of weather conditions (Air temperature, soil temperature and relative air humidity) on the Capacitive sensor readings. 35 Calibration of sensors − Materials: Arduino UNO, Capacitive soil moisture sensor V1.2, DS18B29 soil temperature sensor, DHT11 sensor and module to store data on the SD card. − Procedure: Data was taken every 240 seconds for almost 5 hours, from 13:00h to 17:44h. At the time of connecting the data acquisition, the flower pot was watered. The experiment was done the 2nd of June 2020. • Data treatment and results: Figure 1.42, Figure 1.43 and Figure 1.44 are the graphs obtained from the continuous VWC measurments. Using the obtained data the following linear correlations are made: Figure 1.42: Capacitive sensor behaviour and Air temperature during 6h. Figure 1.43: Capacitive sensor behaviour and Soil temperature during 6h. –Air temperature - Sensor reading: R2= 0.49 –Relative air humidity - Sensor reading: R2= 0.78 36 Calibration of sensors Figure 1.44: Capacitive sensor behaviour and Relative Air humidity during 6h. –Ground temperature - Sensor reading: R2= 0.66 − Results: The correlations obtained are not good enough to be able to ensure that these external factors are variables that directly influence the sensor. It may seem that they have some influence but it is not a direct influence on the sensor; it is an influence on the soil moisture conditions. The more air temperature, the more soil temperature and the less relative air humidity. During hot environmental periods soil moisture decreases due to the quicker evaporation. 1.4.5 Main ideas obtained from Capacitive sensor The Capacitive sensor is the fastest and most accurate sensor ever tested. Unlike other sensors, this sensor is sensitive to soil compaction and the depth at which it is located. This sensitivity to compaction has been observed while data were being taken to make the calibration curve. Values can vary up to 15%, between slightly compacted and a more compacted soil. In order to establish a criterion to take the values, the soil was compacted by striking 6 times with the sample container on the surface, obtaining a sample more similar to the one in field conditions. Another important factor is the depth at which the sensor is placed, which is the reason why the same depth has been used within the recommended range. If it is wanted to use this sensor to measure soil moisture in a lower layer of soil, it will be necessary to insulate this sensor so that it has contact with the desired soil. Despite being more expensive than the Resistive Sensor, it is cheaper than the Resistive Coated one. In addition, it will not be necessary to calibrate the sensor according to the type of soil, neither to use a temperature probe to correct the output values. Given these considerations, the Capacitive sensor is the most reliable. 37 Calibration of sensors The scatter plot comparing the real VWC values with VWC calculated ones using the Equation 1.6, shows how good the calibration curve is. Values are underestimated by 0.0044 (Figure 1.45). Figure 1.45: Scatter Plot of Capacitive sensor values. 1.5 Discussion Each sensor tested has both advantages and disadvantages and depending on these, it can be useful for specific applications (Table 1.11). According to [6], to have a good accuracy with the capacitive sensor a specific calibration for each type of soil texture is necessary. They also point out that "Some low quality brands exhibit low accuracy and poor performance. The largest threats to accuracy for capacitance sensors are air gaps caused by poor installation, followed by clay activity in the soil (i.e. the smectite clays), followed by salinity". After obtaining the calibration curves of this study, it can be concluded that that although there are small differences between soils using the Capacitive Soil Moisture sensor, these are not so relevant to need a specific calibration for each one. Table 1.12 presents an intuitive summary of each Soil Moisture sensor performance and benefits. As seen (Section 1.2.7), Resistive Sensor values could be corrected using a Soil Temperature sensor DS18B20, but values obtained from the Capacitive Soil Moiture v1.2 sensor are still more accurate (Table 1.13), even using the general calibration curve obtained (Equation 1.6). 38 Calibration of sensors Advantages Inconveninences Applications Resistive Resistive - Wide range of lectures - Corrosion degradation - Soil temperature influence - Low precision - High stabilization time - High dependence on soil texture For punctual readings which do not need accuracy Resistive Coated - Low dependence on soil texture - Corriosion resistant - Soil temperature influence - Low precision - Long stabilization time - Low VWC range readings (0-15%) For punctual readings which do not need accuracy For low VWC soils Capacitive v1.2 - Low stabilization time - Precise - Wide range of lectures - Low dependence on soil texture - Low soil temperature influence - Influenced by soil compactness - Influenced by the profundity it is placed. For continuous and accurate readings Table 1.11: Advantages, inconveniences and applications of each VWC sensor tested. 39 Calibration of sensors Resistive Soil Moisture sensor Resistive Coated Soil Moisture sensor Capacitive Soil Moisture Sensor v1.2 Price Lowest Moderate Low Accuracy Low Low High Durability Low High High Complexity Easy Easy Easy VWC Range 0%-25% (Loam) 0%-30% (Clay) 0%-50% (Sand) 0%-15% 0%-30% (Loam and Clay) 0%-40% (Sand) Stabilization time 80 seconds 80 seconds 10 seconds Table 1.12: A comparison of each VWC sensor benefits. Resistive corrected Capacitive General Capacitive Loam 0.91 0.98 0.95Sand 0.78 0.94 Clay 0.99 0.98 Table 1.13: Comparison of the R2 of each regression line for each soil texture and sensor 40 Chapter 2 Automated Irrigation System An automatic and autonomous irrigation system using low cost components is a common Arduino project for its simplicity and great results. The irrigation system proposed is specially thought to check the humidity sensor behaviour using a little vegetable garden. This Chapter is divided in three parts: the first one is about the design of the system, the second one includes the components description,and the last one evaluate the the cost of the system. 2.1 Design of the system The ideas behind the automatic irrigation system are described below. An Arduino micro-controller board is used to build an irrigation system that can control valves based on capacitance sensor readings. The system is powered by solar energy using a solar charger for devices (Section 2.2 Solar panel charger 5V). The use of rechargeable batteries powered by solar panels is useful in situations where power supply is a concern. Sleep-mode libraries can be used in order to reduce the power consumption too. The pump is not included in this design, taking into account that the pressure needed is obtained from the house water system. This scheme is the most simplest way to design an autonomous irrigation system. More sensors and devices can be added but are no needed for the purpose of this project. Arduino code is built with the instructions of the manufacturers of each component and the examples of the Arduino software libraries. The aim of the system is to respond to the needs of plants and save water by watering only when a lack of VWC is detected. Control is a bang-bang control with hysteresis (Figure 2.1). It is necessary to determine the range of acceptable VWC values. The soil on which 41 Automated Irrigation System the irrigation system is implemented is silt-loam soil and its theoretical range of Available Water is between 10 % VWC and 30 % VWC. Just using a range between 15 % and 25 % VWC will enough. From now on, the limits of this range will be appointed "minSM" and "maxSM" respectively. Figure 2.1: Example: Theoretical bang-bang control with hysteresis for the irrigation system. Soil moisture under normal conditions is a factor that varies slowly, so it is worth to save data at relatively long intervals. Also, it is necessary to check the moisture level more frequently. Therefore, two different time intervals are defined in the code. 1. Sensor read interval: interval in which the program reads the sensor signal (1min). 2. Write to SD card interval: interval in which data is saved to the SD card (5min). The way the two intervals can work independently of the loop i the millis(). This funtion is used instead of the delay() which would stop the program at the point of the loop where it is placed. The millis() function counts the time since the Arduino board was turned on. The code structure follows: 1//TIME INTERVALS 2#d efi ne VWC_LECTURE_INTERVAL 60000 3#d ef i ne SD_WRITE_INTERVAL 300000 4unsigned long time_1=0; // Variable to save SD writing time 5unsigned long time_2=0; // Variable to save SM l e c t u r e s time 42 Automated Irrigation System Microcontroller ATmega328 Operatinc Voltage 5V DC Input Voltage (recommended) 7-12V DC Input Voltage (limits) 6-20V DC Digital I/O Pins 14 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB (ATmega328) RAM 2 KB (ATmega328) EPROM 1 KB (ATmega328) Clock Speed 16 MHz Table 2.2: Technical parameters of the Arduino UNO. DHT11 Digital Temperature and Humidity Sensor DHT11 sensor (Figure 1.6) is a small device that allows humidity and temperature to be measured. The output signal is digital, so the connection will be made with the digital pins, and they also incorporate a small internal microcontroller to do the signal treatment. The operation is very simple, the DHT11 are composed of a capacitive sensor to measure humidity and a thermistor, both sensors are calibrated so no parameter should be adjusted. It is not an essential element, but it could useful understand how environmental factors effect the soil moisture. Measure range 20% - 90% RH / 0 - 50 ºC Humidity accuracy +- 5% Temperature accuracy +- 2ºC Power supply 3V - 5.5V / Nominal: 5V Current supply 0.5 mA - 2.5 mA Table 2.3: Technical parameters of the DHT11 Temperature and Relative air Humidity sensor Micro SD Card Shield In order to store the data and to be able to carry out a subsequent analysis and possible presentation of graphs, the data of the measurements of conditions are recorded on a micro SD card (Figure 2.6). Communication with Arduino is done using the SPI protocol. 49 Automated Irrigation System Supply Voltage 4.5 V - 5.5V (5V Typical) Input Voltage 0.2 mA - 200mA (80mA Typical) Interface electrical Potential 3.3V or 5V Support Card Type MicroSD Card (<=2G) Table 2.4: Technical parameters of the SD Module. Figure 2.6: Micro SD Card Shield Figure 2.7: Liquid Crystal Display 16x2 Liquid Crystal Display 16x2 Liquid Crystal Display (Figure 2.7) is used to show the real time data acquired. It is not an essential element, but it could useful. 50 Automated Irrigation System Supply Voltage for LCD 3 V Input Voltage 0 V - 7 V (3.3 V ) (Typical) Supply current 1.5 mA, 2.5mA (max) Backlight supply (R=25 ohm) 16 mA Operating temperature range 0ºC - 50ºC Storage temperature range (-10ºC) - 60ºC Table 2.5: Technical parameters of the Liquid Crystal Display (16x2) RTC DS3231 In order to have control over the date and times of start and end of the irrigation, as well as the date and time when certain relevant environmental conditions occur, the RTC DS3231 watch is incorporated 2.8. It allows to have always updated time, since it has a battery that save data even if it has no power. Communication with Arduino is done using the I2C protocol. Operating Voltage 3.3V - 5.5V Lock chip High-precision clock chip DS3231 Recargable battery LIR2032 Storage Capacity 32 K Clock accurandy 0-40º Table 2.6: Technical parameters of the Real Time Clock DS3231. Figure 2.8: Real Time Clock DS3231 51 Automated Irrigation System Relay Module The relays are used to control power going to the solenoid valves. This 2 relays module 2.9 consists of two LEDs, four resistors, two NPN transistors, two rectifier diodes and two relays capable of handling up to 10A 250V AC or 10A 30V DC. Control signal 3.3 V - 12V DC Maximum AC 10A - 250V Maximum DC 10A - 30V Contact type Both: NC - NO Table 2.7: Technical parameters of the 2 Relays Module Figure 2.9: 2 Relay module Capacitive Soil Moisture v1.2 sensor As presented and developed in Chapter (Figure 1), the humidity sensor chosen is the Capacitive Sensor (Section 1.4). Operating voltage 3.3V - 5.5V DC Output voltage 0V - 3.3V DC Operating current 3.3V or 5V Interface PH2.0-3P Table 2.8: Technical parameters of the Capacitive Soil Moisture v1.2 sensor. Solar panel charger 5V With the aim to have an energy autonomous irrigation system, a mobile solar charger is used that carries a built-in long-lasting battery 2.10 [Link]. The charger 52 Automated Irrigation System has a 5V / 2.1A input (maximum) and two outputs (5V / 2.1A (maximum), 5V / 1A). Both outputs are used, the first charge an extra power bank, which powers the Arduino, and the second is connected to the voltage regulator that feeds the solenoid valve. Figure 2.10: Solar Panel Charger 5V Battery capacity 26800 mAh / 91.76 Wh Weight 350 g Input 5V / 2.1A (Max) Output 5V / 2.1A (Max), 5V / 1A Table 2.9: Technical parameters of the Solar Charger Solenoid valve 12V It is used a small 12V DC solenoid valve with a nominal diameter of 1/2 "and 300mA 2.11. All DC consumption with an induction coil, such as the solenoid valve, needs a non-return diode so that once the solenoid valve is shut down, no currents are induced in the opposite direction which could damage the system. Nominal tension 12V Nominal current 12 V - 300mA Working mode Short intermittent cycle Fluid Water (0- 55 ºC) Water presure 0.02 - 0.8 MPa Table 2.10: Technical parameters of the Solenoid Valve. 53 Automated Irrigation System Figure 2.11: Solenoid valve 12V 2.3 Cost evaluation The irrigation system is designed to be economical. However, it has been added some basic components which are not strictly necessary and make the cost of the project drive up. The cheapest way would be the one which uses just the Arduino, the capacity sensor and the solenoid valved with relay module, but the user would not be able to get information about what is happening in his vegetable garden. That is why in this project are added other useful elements. Table 2.11 summarize the cost of each element used pointing out which ones are an essential elements for the cheapest irrigation method. Prices are indicative and can vary depending on the region. Even if the delivery time is much longer by buying the elements online at cheap websites, it is possible to get the whole system for a third of the usual price. 54 Automated Irrigation System Equipment Price Online super cheap price Hardware Arduino UNO R3 microcontroller * 24€5€ Capacitive Soil Moisture sensor v1.2 * 6€2€ RTC DS3231 7€1.5€ Liquid Crystal Display (16x2) 10€2€ DHT 11 sensor 2€1.6€ Relay Module * 10€1€ Solar charger and battery * 24.88€13.4€ Solenoid valve 12V DC * 14.79€7.85€ B10K Potentiometer 2€0.8€ 1n4007 Diode * 0.15€0.06€ 220 ohm resistance 0.18€0.05€ Micro SD Card Shield 3.5€1.4€ Wiring Male/Male, Male/Female, Female/Female jumper wires * 7€2€ 5V DC to 12V DC converter * 10€2.5€ Barrel Jack adapter 1.5€0.5€ TOTAL 122.67€41.66€ *Essential components Table 2.11: Equipment list and prices. 55 Chapter 3 Conclusions The study of low-cost hygrometers helps to understand how they work and how soil moisture is related to the output the different sensors. Three different sensors were studied, two resisitive and one capacitive, testing them with three different soil types. A total of 9 pots were made. The first resisistive sensor (B071LH529D), the most basic, has turned out to have several problems: − Corrosion: After making the first readings with a new resistive sensor, it was immediately affected by corrosion. Sensor has less accuracy in readings and a short service life − Influence with temperature: the resistivity of materials depends on the temperature in which they are. Because the output voltage of the sensor depends on the ground resistance, the output is affected by temperature. This fact was checked by relating readings of soil temperature and humidity. The relationship is more accurate ( R2 > 0.96) with small size particle soils (clay). The temperature error can be up to 30%. − Dependence of the ground type: The output voltage for each VWC strongly depends on the type of soil on which the reading is made. The second resistive sensor with an anticorrosive layer (B076DDWDJK) no longer have corrosion problems and have a lower influence of soil type. On the other hand, it continue being influenced by changes in soil temperature, have accuracy problems, and the VWC reading range is very limited (<15 % VWC). Finally, the capacitive sensor (B07SYBSHGX) is the most accurate, fast and looks low influenced by changes in soil temperature. That is why this sensor was chosen to develop an automatic irrigation system. 56 Conclusions The evolution of the Internet of Things (IoT) and data management mean that all sectors, from the most rural to the most industrialized, have new tools to improve performance and productivity. In Girona, Catalunya, a pilot irrigation plan is being drawn up for the city’s gardens based on soil moisture [Diari de Girona]. Using the data obtained, it will be possible to make new irrigation models that improve the management of consumption at any time and location, without the need to travel. It is important to know how these sensors behave in order to offer new and low-cost tools to local producers. Applying technological innovations in the field allows to increase productivity and save on water resources. As a continuation of this cheap hygrometers study, on the one hand, it would be interesting to check the influence of other aspects such as salinity or pH that could effect the output of this type of low-cost sensors. On the other hand, to have an improved automatic irrigation system, it could be considered to have direct access to real time data through wireless networks. Furthermore, it could be possible to connect the irrigation system to internet so that it would be able to get weather information and schedule irrigation based on rainfall periods. 57 Appendix A Figures from Resistive soil moisture sensor (Code B071LH529D) Figure A.1: Behavior of a new resistive sensor and a partially corroded resistive sensor when submerged them into the water and dry them. 58 Arduino code 127 // Fix time when code i s compilated 128 r tc . ad just ( DateTime (F(__DATE__) , F(__TIME__) ) ) ; 129 130 // rt c . adjust ( DateTime (2016 , 1 , 21 , 3 , 0 , 0) ) ; 131 } 132 133 // i r r i g a t i o n mode 134 i r r i g a t i o n=f a l s e ; 135 136 // Capacitance S o i l Moisture v1 .2 s ensor analog pin A0 137 in t Sensor = analogRead (A0) ; 138 in t Q = map( Sensor , AirValue , WaterValue , 0 , 100) ; 139 in t SM = ((−Sensor +599.2) /934.33) ∗100; 140 141 //DHT11 142 float h = dht . readHumidity () ; 143 float t = dht . readTemperature ( ) ; 144 145 //LCD 146 screen =1; 147 } 148 149 150 void loop () { 151 152 i f ( m i l l i s () > time_1 + SD_WRITE_INTERVAL) { 153 time_1 = m i l l i s ( ) ; 154 in t Sensor = analogRead (A0) ; 155 in t Q = map( Sensor , AirValue , WaterValue , 0 , 100) ; 156 in t SM = ((−Sensor +599.2) /934.33) ∗100; 157 in t h = dht . readHumidity ( ) ; 158 in t t = dht . readTemperature ( ) ; 159 160 // Task 1: Send data to SD 161 dataFile = SD. open ( "DATAV1. txt " , FILE_WRITE) ; 162 i f ( dataFile ) { 163 DateTime now = rt c . now () ; 164 d at aF il e . p r i n t l n (now . year ( ) , DEC) ; 165 dataFile . prin t ( ’ / ’ ) ; 166 dataFile . prin t (now . month ( ) , DEC) ; 167 dataFile . prin t ( ’ / ’ ) ; 168 dataFile . prin t (now . day ( ) , DEC) ; 169 dataFile . prin t ( " ; " ) ; 170 dataFile . prin t (now . hour () , DEC) ; 171 dataFile . prin t ( ’ : ’ ) ; 172 dataFile . prin t (now . minute ( ) , DEC) ; 173 dataFile . prin t ( ’ : ’ ) ; 174 dataFile . prin t (now . second ( ) , DEC) ; 175 dataFile . prin t ( " ; " ) ; 65 Arduino code 176 177 dataFile . prin t ( Sensor ) ; 178 dataFile . prin t ( " , " ) ; 179 dataFile . prin t (Q) ; 180 dataFile . prin t ( " , " ) ; 181 dataFile . prin t (SM) ; 182 dataFile . prin t ( " , " ) ; 183 dataFile . prin t (h) ; 184 dataFile . prin t ( " , " ) ; 185 d at aF il e . p r i n t l n ( t ) ; 186 dataFile . c l o s e ( ) ; // This needs to happen a f t e r writing your data out to the f i l e f i r s t . 187 // pr int to the s e r i a l port too : 188 S e r i a l . p r i n t l n ( " done . " ) ; 189 } 190 } 191 192 i f ( m i l l i s () > ( time_2 + SM_LECTURE_INTERVAL) ) { 193 time_2 = m i l l i s ( ) ; 194 in t Sensor = analogRead (A0) ; 195 in t Q = map( Sensor , AirValue , WaterValue , 0 , 100) ; 196 in t SM = ((−Sensor +599.2) /934.33) ∗100; 197 in t h = dht . readHumidity ( ) ; 198 in t t = dht . readTemperature ( ) ; 199 i f ( i r r i g a t i o n ) { // I r r i g a t i o n 200 di gi ta lWr it e ( Valve , LOW) ; 201 lcd . begin (16 , 2) ; 202 lcd . c l e a r ( ) ; 203 lcd . setCursor (0 , 0) ; 204 lcd . pri nt ( " IRRIGATION! " ) ; 205 lcd . setCursor ( 0 ,1) ; 206 lcd . pri nt ( "SM: " ) ; 207 lcd . pri nt (SM) ; 208 lcd . pri nt ( " %" ) ; 209 210 i f (SM>=maxSM) { 211 di gi ta lWr it e ( Valve ,HIGH) ; 212 i r r i g a t i o n=f a l s e ; 213 } 214 S e r i a l . p r i n t l n ( " I r r i g a t i o n period " ) ; 215 } 216 217 e l s e { 218 i f (SM>minSM & SM<maxSM) { // Conditions 219 di gi ta lWr it e ( Valve ,HIGH) ; 220 i r r i g a t i o n=f a l s e ; 221 i f ( screen==1){ 222 lcd . begin (16 , 2) ; 223 lcd . c l e a r ( ) ; 66 Arduino code 224 lcd . setCursor (0 , 0) ; 225 lcd . pri nt ( "SM " ) ; 226 lcd . pri nt (SM) ; 227 lcd . pri nt ( " %" ) ; 228 lcd . setCursor ( 0 ,1) ; 229 lcd . pri nt ( " Avail W: " ) ; 230 lcd . pri nt (Q) ; 231 lcd . pri nt ( "%" ) ; 232 screen =2; 233 234 S e r i a l . p r i n t l n ( " Screen 1 " ) ; 235 } 236 e l s e i f ( screen==2){ 237 lcd . c l e a r ( ) ; 238 lcd . setCursor (0 , 0) ; 239 lcd . pri nt ( "hum: " ) ; 240 lcd . pri nt (h) ; 241 lcd . pri nt ( " %" ) ; 242 lcd . setCursor ( 0 ,1) ; 243 lcd . pri nt ( "Temp: " ) ; 244 lcd . pri nt ( t ) ; 245 lcd . pri nt ( " C" ) ; 246 screen =1; 247 S e r i a l . p r i n t l n ( " Screen 2 " ) ; 248 } 249 } 250 251 e l s e i f (SM<=minSM) { 252 // di gi ta lW rit e ( Valve , LOW) ; 253 i r r i g a t i o n=true ; 254 lcd . begin (16 , 2) ; 255 lcd . c l e a r ( ) ; 256 lcd . setCursor (0 , 0) ; 257 lcd . pri nt ( " IRRIGATION! " ) ; 258 lcd . setCursor ( 0 ,1) ; 259 lcd . pri nt ( "SM " ) ; 260 lcd . pri nt (SM) ; 261 lcd . pri nt ( " %" ) ; 262 263 264 S e r i a l . p r i n t l n ( " I r r i g a t i o n " ) ; 265 } 266 267 e l s e { 268 di gi ta lWr it e ( Valve ,HIGH) ; 269 i r r i g a t i o n=f a l s e ; 270 lcd . begin (16 , 2) ; 271 lcd . c l e a r ( ) ; 272 lcd . setCursor (0 , 0) ; 67 Arduino code 273 lcd . pri nt ( " Over Field cap . " ) ; 274 lcd . setCursor ( 0 ,1) ; 275 lcd . pri nt ( "SM " ) ; 276 lcd . pri nt (SM) ; 277 lcd . pri nt ( " %" ) ; 278 279 S e r i a l . p r i n t l n ( " Over f i e l d capacity " ) ; 280 281 } 282 } 283 } 284 285 286 287 i f ( m i l l i s () > time_3 + SERIAL_INTERVAL) { 288 time_3 = m i l l i s ( ) ; 289 in t Sensor = analogRead (A0) ; 290 in t Q = map( Sensor , AirValue , WaterValue , 0 , 100) ; 291 in t SM = ((−Sensor +599.2) /934.33) ∗100; 292 in t h = dht . readHumidity ( ) ; 293 in t t = dht . readTemperature ( ) ; 294 295 // Task 3: S e r i a l p rin t 296 DateTime now = rt c . now () ; 297 S e r i a l . pr in t (now . year () , DEC) ; 298 S e r i a l . pr in t ( ’ / ’ ) ; 299 S e r i a l . pr in t (now . month ( ) , DEC) ; 300 S e r i a l . pr in t ( ’ / ’ ) ; 301 S e r i a l . pr in t (now . day ( ) , DEC) ; 302 S e r i a l . pr in t ( " " ) ; 303 S e r i a l . pr in t (now . hour () , DEC) ; 304 S e r i a l . pr in t ( ’ : ’ ) ; 305 S e r i a l . pr in t (now . minute ( ) , DEC) ; 306 S e r i a l . pr in t ( ’ : ’ ) ; 307 S e r i a l . pr in t (now . second ( ) , DEC) ; 308 309 S e r i a l . pr in t ( " , " ) ; 310 S e r i a l . pr in t ( Sensor ) ; 311 S e r i a l . pr in t ( " , " ) ; 312 S e r i a l . pr in t (Q) ; 313 S e r i a l . pr in t ( " , " ) ; 314 S e r i a l . pr in t (SM) ; 315 S e r i a l . pr in t ( " , " ) ; 316 S e r i a l . pr in t (h) ; 317 S e r i a l . pr in t ( " , " ) ; 318 S e r i a l . p r i n t l n ( t ) ; 319 } 320 } 68 Arduino code 69 Bibliography [1] Krishna S. Nemali and Marc W. van Iersel. «An automated system for controlling drought stress and irrigation in potted plants». In: Scientia Horticulturae 110.3 (2006), pp. 292–297. issn: 0304-4238. doi: https://doi.org/10.1016/ j.scienta.2006.07.009 .url: http://www.sciencedirect.com/science/ article/pii/S0304423806002871 (cit. on p. 1). [2] Rhuanito Ferrarezi, sue Dove, and Marc Van Iersel. «An Automated System for Monitoring Soil Moisture and Controlling Irrigation Using Low-cost Opensource Microcontrollers». In: HortTechnology 25 (Feb. 2015), pp. 110–118. doi:10.21273/HORTTECH.25.1.110 (cit. on p. 2). [3] US Department of Agriculture Soil Conservation Service. «SSM - Ch. 3. Examination and Description of Soil Profiles». In: () (cit. on p. 3). [4] Alberto Pardossi, Luca Incrocci, Giorgio Incrocci, Fernando Malorgio, Piero Battista, Laura Bacci, Bernardo Rapi, Paolo Marzialetti, Jochen Hemming, and J. Balendonck. «Root Zone Sensors for Irrigation Management in Intensive Agriculture». In: Sensors (Basel, Switzerland) 9 (Apr. 2009), pp. 2809–35. doi:10.3390/s90402809 (cit. on p. 4). [5] Fedro S. Zazueta; Jiannong Xin2. «Soil Moisture Sensors». In: Florida Cooperative Extension Service, Insitute of Food ans Agricultural Science (Apr. 1994) (cit. on pp. 5, 6). [6] METER Group. «Soil moisture sensors - How they work. Why some are not research-grade». In: (July 2020) (cit. on pp. 5, 30, 38). [7] J.L. Varble and José Chávez. «Performance evaluation and calibration of soil water content and potential sensors for agricultural soils in eastern Colorado». In: Fuel and Energy Abstracts 101 (Dec. 2011), pp. 93–106. doi: 10.1016/j.agwat.2011.09.007 (cit. on p. 6). [8] Jasreman Singh, Derek Heeren, Daran Rudnick, Wayne Woldt, Geng Bai, Yufeng Ge, and Joe Luck. «Soil Structure and Texture Effects on the Precision 70 BIBLIOGRAPHY of Soil Water Content Measurements with a Capacitance- Based Electromagnetic Sensor». In: Transactions of the ASABE 63 (Jan. 2020), pp. 141–152. doi:10.13031/trans.13496 (cit. on p. 6). [9] Dilrukshi & E A Ayesha, Nagahage & Isura, and Fujino & Takeshi. «Calibration and Validation of a Low-Cost Capacitive Moisture Sensor to Integrate the Automated Soil Moisture Monitoring System». In: Agriculture 9 (July 2019), p. 141. doi:10.3390/agriculture9070141 (cit. on p. 6). [10] Z. & Clark & J.A. Ganjegunte & G.K. Sheng. «Evaluating the accuracy of soil water sensors for irrigation scheduling to conserve freshwater». In: Appl Water Sci 2 (Feb. 2012), pp. 119–125. doi: 10.1007/s13201-012-0032-7 (cit. on pp. 6, 31). [11] I. Iturria1 & M.A. Campo-Bescós & U. Gómez & M. López & R. Giménez. «Evaluación de 24 sondas de humedad: calibración y volumen de influencia». In: Estudios en la Zona No Saturada. Vol XIV (2019) (cit. on p. 6). [12] Radi & Murtiningrum; Murtiningrum & Ngadisih; & Muzdrikah; Fajar & Nuha; M. & Alfinur Rizqi; Fathi. «Calibration of Capacitive Soil Moisture Sensor /(SKU:SEN0193)». In: (Aug. 2018). doi: 1-6.10.1109/ICSTC.2018. 8528624. (cit. on pp. 6, 30). [13] Saleh; Mahdi, Elhajj; Imad, Asmar; Daniel, Bashour; Isam, and Kidess; Samer. «Experimental Evaluation of Low-Cost Resistive Soil Moisture Sensors». In: Conference: 2016 IEEE International Multidisciplinary Conference on Engineering Technology (IMCET) (Nov. 2016), pp. 179–184. (Cit. on p. 7). [14] Mackay & J. D. & Archer N. A. L. & Rawlins B. R. & Machant & B. P. and P. I. Meldrum. «Approaches to calibrate in-situ capacitance soil moisture sensors and some of their implications». In: SOIL Discuss (2016). doi: 10.5194/soil- 2016-40 (cit. on p. 30). 71