Low-cost soil moisture sensor calibration

 

Jean Rodrigues Duarte1 & Daniel Noe Coaguila Nuñez1,2

 

1 Centro Universitário UniBRAS Rio Verde - UniBRAS, Rio Verde, Goiás State, Brazil

2 Universidad Nacional de San Agustin de Arequipa, Arequipa, Peru

Correspondence: Jean Rodrigues Duarte, Centro Universitário do Sudoeste Goiano - UniBRAS, Rio Verde, Goiás State, Brazil. E-mail: jean123771@gmail.com

 

Received: November 10, 2023                    DOI: 10.14295/bjs.v3i2.517

Accepted: December 22, 2023                    URL: https://doi.org/10.14295/bjs.v3i2.517

 

Abstract

Brazil has been experiencing several instabilities regarding the climate. There is a great climatological variation in the cultures that have been suffering drastically from this stress, mainly water. Therefore, it is necessary to quickly and efficiently check the soil moisture rate, before any operation in the field, avoiding production losses and unnecessary extra expenses for the producer. Methods for measuring soil moisture are extremely important for carrying out adequate irrigation, thus optimizing water resources and saving water. Humidity directly affects seed quality, germination rate and crop yield, other unit operations. In this study the low-cost WeMos sensor was evaluated regarding its efficiency and possible calibration in comparison to high-cost equipment with an average of US$: 405,75 dollars. The gravimetric method was used to calibrate the sensor, which consists of sample preparation, drying, determination of its mass and evaluation calculation. The gravimetric method was used to calibrate the sensor, which consists of sample preparation, drying, determination of its mass and evaluation calculation. From the data obtained, the equation was used, which was first inserted into the programming carried out in the Arduino system transmitted to the WeMos sensor. The results obtained by the WeMos sensor were consistent with the gravimetric humidity results obtained. It is concluded that the WeMos Arduino sensor presents reliability in sampled data and that it is an economically viable option for rural producers who need to obtain an answer regarding the humidity of the planting soil.

Keywords: gravimetric humidity, WeMos system, Arduino, soil moisture, electric properties of humity sensors, capacitance and resistance of humity sensors.

Calibração de sensor de umidade do solo de baixo custo

Resumo

O Brasil vem passando por várias instabilidades em relação ao clima. Há uma grande variação climatológica sobre as culturas que vêm sofrendo drasticamente com esse estresse, principalmente hídrico. Sendo assim, necessário a verificação rápida e eficiente sobre a taxa de umidade do solo, antes de qualquer operação na lavoura, evitando perdas de produção e gastos extras desnecessários ao produtor. Os métodos de aferição da umidade no solo é de grande importante para a realização adequada de irrigação, otimizando assim, os recursos hídricos e economizando água. A umidade afeta diretamente a qualidade das sementes sobre a taxa de germinação e o rendimento da cultura, demais operações unitárias. Neste estudo, foi avaliado o sensor WeMos de baixo custo, quanto a sua eficiência e a possível calibração em comparação a equipamentos de alto custo com média de R$: 2.000,00 reais. O método gravimétrico foi utilizado para a calibração do sensor, que consiste em preparação de amostra, secagem, determinação de sua massa e o cálculo de avaliação. A partir dos dados obtidos, foi utilizado a equação, que primeiramente foi inserida na programação realizada em sistema Arduino transmitida para o sensor WeMos. Os resultados obtidos pelo sensor WeMos foram consistentes com os resultados de umidade gravimétrica obtidos. Conclui-se que, o sensor WeMos por Arduino apresenta confiabilidade em dados amostrados e que é uma opção economicamente viável para os produtores rurais que necessitam obter resposta quanto a umidade do solo de plantio.

Palavras-chave: umidade gravimétrica, sistema WeMos, Arduino, umidade do solo, propriedades elétricas de sensores de umidade, capacitância e resistência de sensores de umidade.

 

1. Introduction

Accurate moisture detection and moisture control are important factors in various sectors, including agriculture for determining moisture in various types of soils (Afzal et al., 2022). Soil moisture analysis is important to be verified in experiments and in the field, as it will directly influence the productivity rate and profit percentage. The incorrect humidity directly affects germination, crop growth and plant germination rate. And combined with this important analysis, we can verify the use of sensors for this purpose, with different models: capacitive, resistance, water voltage, and electrical conductivity, this being the most used and easy to acquire (Placidi et al., 2020; Cherlinka, 2022).

Thus, an unsealed capacitor is used equipped with a porous dielectric medium with capacitance variation that depends exclusively on the type and quantity of matter present between the plates, since the other parameters that influence the capacitance value can be considered constant for this case. In this way as the soil around the sensor becomes more humid, the porous medium that makes up the dielectric absorbs a certain amount of water, proportional to the moisture content present in the substrate. When the soil becomes drier, the dielectric medium loses water depending on the amount of moisture present around the sensor. This behavior is due to the phenomenon of diffusion through porous media that is measured using a specific sensor for this function (Segundo; Kardek, 2010; Afzal et al., 2022).

Using capacitive sensors (WeMos) and programming in Arduino, it can be programmed to meet specific needs, as it is hardware that can be used to program the equipment (Makiyama,2022). Faced with this need, a device was created on an electronic prototyping platform, which consists of a free software and hardware system. WeMos is characterized by an electronic circuit board containing a microcomputer that allows direct interaction between the electronic medium and the environment. This interaction is made using simple doors or inputs, combined with easily editable programming.

The great versatility of the application of equipment with Arduino boards lies in the low-cost focus, which has brought this type of equipment closer to functional reality, especially for the agricultural environment (Silva, 2021). The WeMos Board is an ESP8266-12EX type module. A microcontroller with Wi-Fi connection capability, which allows these activations and many other functions, not requiring an external module to connect to wireless networks, programming can be done directly via Arduino (Neumann, 2021).

Sensor-based irrigation to measure soil moisture can be used to optimize agricultural production and accurately deliver water on demand. However, commercially available control systems have high values. To reduce the cost of automated irrigation systems, researchers have used alternative low-cost open source platforms coupled with capacitive sensors that can monitor the volumetric water content of soil in real time, enabling on-demand water delivery to plants. (Moura et al., 2021).

Thus, we need to produce cheaper sensors for determining humidity to meet a greater demand from producers (small, medium and large producers), making the use of Arduino technology and its easy interface combined with rural production more flexible and accessible. In view of the above, the objective was to calibrate the low-cost WeMos sensor based on the Arduino system using gravimetric humidity as a traditional soil moisture analysis standard.

 

2. Material and Methods

2.1 Experimental local

The experiment was carried out at the Centro Universitário do Sudoeste Goiano (UniBRAS), Rio Verde, Goiás, Brazil, in the Soil Analysis Laboratory, where all tests and soil drying were carried out (Figure 1).

 


Figure 1. Determination of soil moisture using the gravimetric method. Source: Authors, 2023.

 

2.1 Sensor WeMos

The WiFi BT ESP Lilygo T-Hidrow BME280 ground temperature/humidity sensor of the “WeMos” capacitive type was used in the experiment, with ESPRESSIF-ESP32 Chipset module (Bluetooh and WiFi), LX6 32-bit Xtensa single/dual-core 240 MHz MICROPROCESSOR , QSPI flash 4 MB flash, SRAM 520 kB SRAM and humidity and ambient temperature sensors, the system was modified by adding an 18650 battery type power source. The sensor used was developed by the company (HiGrow, China) and acquired by Saravati Brazil.

 


Figure 2. Capacitive sensor. Source: Authors, 2023.

 

2.3 Application and readings

A soil sample was placed in a 150 mL beaker for analysis. Then, the blade (sensor) was introduced into the soil. After this procedure, the sensor was connected directly to the Arduino system to obtain moisture values for each soil sample.

 


Figure 3. Sensor in operation. Source: Authors, 2023.

 

To calibrate the sensor, gravimetric methodology was used, a method established by LaCoste (1908-1995) and described by Harrison (1995). The Method consists of taking small samples of soil in the evaluated area and at the depth at which the water content is desired, placing them in a closed container, usually made of Aluminum (or glass), and bringing them to the laboratory. The mass of the container with the wet soil sample is determined on an analytical balance (M1), then the open container is transferred to an oven with air circulation and a temperature set at 105 °C. After 24 h, the container containing dry soil is removed from the oven and kept in a desiccator at 25 °C, after this time, the mass of the container containing soil is obtained again (M2). The mass (M3) is then obtained from the container, the percentage of water content in mass is obtained through the difference in mass and the result expressed as a percentage (%) according to the following equation:



Figure 4. Arduino programming. Source: Authors, 2023.

 

As seen in Figure 4, the link between the computer and the WeMos board was made using the Arduino system and the program was inserted to obtain soil moisture data (Frame 1). Therefore, the values obtained were correlated with gravimetric humidity.

 

#include "DHT.h"

#include <WiFi.h>

 

#define DHTTYPE DHT11  // DHT 22  (AM2302), AM2321

 

// Replace with your network credentials

const char* ssid = "EXACTA AI 2G";  //wifi id

const char* password = "3x@cT@202e"; //password

 

WiFiServer server(80);

 

// DHT Sensor

const int DHTPin = 22;

// Initialize DHT sensor.

DHT dht(DHTPin, DHTTYPE);

// Temporary variables

static char celsiusTemp[7];

static char fahrenheitTemp[7];

static char humidityTemp[7];

 

// Client variables

char linebuf[80];

int charcount = 0;

 

void setup() {

  // initialize the DHT sensor

  dht.begin();

 

  //Initialize serial and wait for port to open:

  Serial.begin(115200);

  while (!Serial) {

    ;  // wait for serial port to connect. Needed for native USB port only

  }

 

  // We start by connecting to a WiFi network

  Serial.println();

  Serial.println();

  Serial.print("Connecting to ");

  Serial.println(ssid);

 

  WiFi.begin(ssid, password);

 

  // attempt to connect to Wifi network:

  while (WiFi.status() != WL_CONNECTED) {

    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:

    delay(500);

    Serial.print(".");

  }

  Serial.println("");

  Serial.println("WiFi connected");

  Serial.println("IP address: ");

  Serial.println(WiFi.localIP());

 

  server.begin();

}

 

void loop() {

  // listen for incoming clients

  WiFiClient client = server.available();

  if (client) {

    Serial.println("New client");

    memset(linebuf, 0, sizeof(linebuf));

    charcount = 0;

    // an http request ends with a blank line

    boolean currentLineIsBlank = true;

    while (client.connected()) {

      if (client.available()) {

        char c = client.read();

        Serial.write(c);

        //read char by char HTTP request

        linebuf[charcount] = c;

        if (charcount < sizeof(linebuf) - 1) charcount++;

        // if you've gotten to the end of the line (received a newline

        // character) and the line is blank, the http request has ended,

        // so you can send a reply

        if (c == '\n' && currentLineIsBlank) {

          // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

          float h = dht.readHumidity();

          // Read temperature as Celsius (the default)

          float t = dht.readTemperature();

          // Read temperature as Fahrenheit (isFahrenheit = true)

          float f = dht.readTemperature(true);

          // Check if any reads failed and exit early (to try again).

          if (isnan(h) || isnan(t) || isnan(f)) {

            Serial.println("Failed to read from DHT sensor!");

            strcpy(celsiusTemp, "Failed");

            strcpy(fahrenheitTemp, "Failed");

            strcpy(humidityTemp, "Failed");

          } else {

            // Computes temperature values in Celsius + Fahrenheit and Humidity

            float hic = dht.computeHeatIndex(t, h, false);

            dtostrf(hic, 6, 2, celsiusTemp);

            float hif = dht.computeHeatIndex(f, h);

            dtostrf(hif, 6, 2, fahrenheitTemp);

            dtostrf(h, 6, 2, humidityTemp);

           

          }

          // send a standard http response header

          client.println("HTTP/1.1 200 OK");

          client.println("Content-Type: text/html");

          client.println("Connection: close");  // the connection will be closed after completion of the response

          client.println();

          client.println("<!DOCTYPE HTML><html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");

          client.println("<meta http-equiv=\"refresh\" content=\"30\"></head>");

          client.println("<body><div style=\"font-size: 3.5rem;\"><p>EXACTA Agricultura Inteligente</p><p>");

          if (atoi(celsiusTemp) >= 25) {

            client.println("<div style=\"color: #930000;\">");

          } else if (atoi(celsiusTemp) < 25 && atoi(celsiusTemp) >= 5) {

            client.println("<div style=\"color: #006601;\">");

          } else if (atoi(celsiusTemp) < 5) {

            client.println("<div style=\"color: #009191;\">");

          }

          client.println(celsiusTemp);

          client.println("*C</p><p>");

          client.println(fahrenheitTemp);

          client.println("*F</p></div><p>");

          client.println(humidityTemp);

          client.println("%</p><p>");

          client.println(analogRead(32));

          client.println("</p></div>");

          client.println("</body></html>");

          break;

        }

        if (c == '\n') {

          // you're starting a new line

          currentLineIsBlank = true;

          memset(linebuf, 0, sizeof(linebuf));

          charcount = 0;

        } else if (c != '\r') {

          // you've gotten a character on the current line

          currentLineIsBlank = false;

        }

      }

    }

    // give the web browser time to receive the data

    delay(1);

 

    // close the connection:

    client.stop();

    Serial.println("client disconnected");

  }

}

 

Frame 1. Arduino programming sketch of the WeMos WiFi & Bluetooth battery board. Source: Modified by Rui Santos (http://randomnerdtutorials.com).

 

3. Results and Discussion

The sensors met the needs of the study, it was possible to verify and quantify the gravimetric soil moisture by comparing the traditional method with the electronic method using an Arduino device (Table 1).

In our study, an exhaustive step was observed in programming the sensors according to our evaluation needs, there was the development of MACROS and tables for data conversion. However, our values were on a linear scale according to the sample and its moisture content, which was discussed in the study by Sena et al. (2020).

 

Table 1. Parameters evaluated between gravimetric data and WeMos by Arduino using a humidity sensor*.

Becker weight

Becker + moist soil

Becker + dry soil

Wet soil sensor reading

Wet soil weight

Dry soil weight

Weight moisture

Gravimetric humidity (%)

1

37.08

94.00

79.93

2771

56.92

42.85

14.07

32.84

2

38.09

95.75

81.54

2821

57.66

43.45

14.21

32.70

3

37.88

99.54

84.86

 -

61.66

46.98

14.68

 -

4

38.83

100.51

85.75

2959

61.68

46.92

14.76

31.46

5

35.04

91.98

78.27

 -

56.94

43.23

13.71

 -

6

35.16

89.90

76.78

2987

54.74

41.62

13.12

31.52

7

34.69

90.25

76.60

2751

55.56

41.91

13.65

32.57

8

35.15

90.72

77.23

 -

55.57

42.08

13.49

 -

9

34.86

91.66

77.75

2855

56.80

42.89

13.91

32.43

10

35.66

92.48

78.45

 -

56.82

42.79

14.03

 -

* Weight in grams (g). Source: Authors, 2023.

 

With the adjustment line plotted in Figure 5, it is possible to observe the linearity between the values obtained. From the analysis of the graph obtained, it was possible to generate a linear adjustment equation y = -0.0058x + 48.964 and a coefficient of determination with R2 = 0.87, which indicates that the soil moisture values are explained in approximately 87% by the results recorded soil capacitance by WeMos on the Arduino system. According to Nascimento & Araújo (2009), a coefficient of determination that indicates a perfect fit is R2 = 1, where this means that the closer the coefficient results to 1, the better the fit to the data. Paris & Rosa (2018) found R2 = 93% by evaluating the linear regression between soil moisture and capacitance by the evaluated humidity sensor.

Similar results were obtained by Gomes (2016) where the author used his own capacitance sensor and obtained a coefficient of determination with R2 = 0.988 from 10 fresh soil samples. In the study carried out by Pizetta (2015), the researcher tested sensors of the 10HS type developed by Decagon, Eletrodex and Grove in three different types of soil, namely dystrophic Red Claysol, dystrophic Red Oxisol and Nitisol.

Eutrophic red, where he obtained results for the coefficient of determination for the 10HS sensor with R2 = 0.93 (Ultisol), R2 = 0.98 (Oxisol) and R2 = 0.99 (Nitosol), and for the Eletrodex sensor R2 = 0 .70 (Ultisol), R2 = 0.72 (Oxisol) and R2 = 0.48 (Nitosol) and for the Grove sensor with R2 = 0.65 (Ultisol), R2 = 0.72 (Nitosol) and R2 = 0.11 (Oxisol). Results close to ours were also described by Costa et al. (2013), using a capacitive sensor model IRRIGAP for Neossolo Quartzarenic, where they describe with precision and accuracy the variation in soil moisture, where their R2 results presented values close to unity (0.99).

Our results are consistent with the soil moisture values found by Sena et al. (2020) in their study where they evaluated clayey soils. According to Crubelatti (2020), the researcher also obtained a linear result similar to our study with substrates for the production of fruit and vegetables, thus corroborating this new method of electronic humidity measurement and a low-cost Arduino system. Still in this study, the researcher managed to obtain calibration of the sensors evaluated on different types of humid substrates.

 


Figure 5. Linear regression of soil moisture. Source: Authors, 2023.

 

4. Conclusion

The data obtained by the capacitive sensor was related to the corresponding gravimetric humidity and the WeMos sensor proved to be efficient in measuring soil humidity, making it a reliable and beneficial low-cost reproductive option.

 

5. Authors’ Contributions

Jean Rodrigues Duarte: study design, scientific writing, submission and publication. Daniel Noe Coaguila Nuñez: advisor, scientific corrections and publication.

 

6. Conflicts of Interest

No conflicts of interest.

 

7. Ethics Approval

Not applicable.

 

8. References

Afzal, U., Afzal, J., & Aslam, M. (2022). Analysing the imprecise capacitance and resistance data of humity sensors. Sensors and Actuators B: Chemical, 367, 132092. https://doi.org/10.1016/j.snb.2022.132092

Alves de Carvalho, A. (2023). O papel do Arduino e sensores de baixo custo na agropecuária digital: avanços e perspectivas no brasil.

Campos, H. M., Oliveira, H. F. E., Mesquita, M., Castro, L. E. V., & Ferrarezi, R. S. (2021). Low-cost open-source platform for irrigation automation. Computers and Electronics in Agriculture, 190, 106481. https://doi.org/10.1016/j.compag.2021.106481

Cherlinka, V. (2022). Umidade do solo: nível ótimo e controle de déficit. In: EOS Data Analytics. Available: https://eos.com/pt/blog/umidade-do-solo. Access in: November 2, 2023.

Crubelatti, G. H. (2020). Avaliação de sensores capacitivos para determinação da umidade de substratos de cultivo. Unicamp.

Costa, B. R. S., Santos, L. M., & Bassoi, L. H. (2013). Calibração do sensor de capacitância IRRIGAP® para a medida da umidade em solo do Semiárido. In: Embrapa Semiárido, Anais do XLII Congresso Brasileiro de Engenharia Agrícola – CONBEA, Fábrica de Negócios – Fortaleza, Ceará, Brasil, 4 a  8 de Agosto, 4 f. https://ainfo.cnptia.embrapa.br/digital/bitstream/item/96448/1/Bassoi2.pdf

Gomes, I. C. (2016). Desenvolvimento de um sensor digital de umidade do solo e unidade remota de monitoramento utilizando comunicação sem fio. Trabalho de Conclusão de Curso (Graduação) pela Universidade Tecnológica Federal do Paraná, Pato Branco, PR, Brasil, 57 f. http://repositorio.utfpr.edu.br/jspui/handle/1/14642

Harrison, C. (1995). Lucien J. B. LaCoste [1908-1995]. Eos, Transactions American Geophysical Union, 76(50), 515-515. https://doi.org/10.1029/95EO00319

Makiyama, M. (2023). O que e Arduino, para que serve, benefícios e projetos. Available in: https://victorvision.com.br/blog/o-que-e-arduino/. Access in: November 2, 2023.

Nascimento, G., & Araújo, P. F. (2009). Estudo acerca do coeficiente de determinação nos modelos lineares e algumas generalizações. Universidade Federal do Paraná, Curitiba, PR, Brasil.

Neumann, I. (2021). ESP8266 e HTML: Tudo o que você precisa saber. Available in: https://www.crescerengenharia.com/post/tudo-sobre-esp8266-e-htmls. Access in: November 20, 2023.

Paris, L. A., Helton, E., & Rosa, A. (2018). Calibração do sensor de umidade de solo capacitivo em latossolo vermelho distroférrico. In: SEAGRO – 12ª Semana Acadêmica de Agronomia, de 6 a 8 de Julho de 2018, 17-20 p. Available in: https://www.fag.edu.br/upload/revista/seagro/6310c0bd3adf5.pdf. Access in: December 21, 2023.

Pizetta, S. C. (2015). Calibração de sensores de capacitância (FDR) para estimativa da umidade em diferentes solos. Dissertação de Mestrado (Programa de Pós-Graduação em Recursos Hídricos em Sistemas Agrícolas), Universidade Federal de Lavras, Lavras, Minas Gerais, Brasil, 67 f.

Placidi, P., Gasperini, L., Grassi, A., Cecconi, M., & Scorzoni, A. (2020). Characterization of low-cost capacitive soil moisture sensors for IoT networks. Sensors, 20(12), 3585. https://doi.org/10.3390/s20123585

Segundo, R., & Kardek, A. (2010). Desenvolvimento de sensor de teor de água do solo e de sistema de controle e automação em malha fechada para uso em irrigação. Dissertação de Mestrado em Engenharia Agrícola, pela Universidade Federal de Viçosa, UFV, Minas Gerais, Brasil, 65 f. https://locus.ufv.br//handle/123456789/3563

Sena, C. C. R., Alves, J., Domingos, M. V. H., Antunes, E. J., Battisti, R., Evangelista, A. W. P., & Casaroli, D. (2020). Calibração do sensor capacitivo de umidade do solo ec-5 em resposta a granulometria do solo. Brazilian Journal of Development, 6(4), 17228-17240. https://doi.org/10.34117/bjdv6n4-043

Silva, M. M. (2021). Análise da hidrodinâmica com sensores capacitivo e resistivo de arduino em solo do cerrado. Dissertação de Mestrado (Programa de Pós-Graduação em Irrigação no Cerrado) pelo Instituto Federal Goiano, Campus Ceres, Ceres, Goiás, Brasil, 47 f. https://repositorio.ifgoiano.edu.br/bitstream/prefix/2362/3/12%20-%20Disserta%c3%a7%c3%a3o.pdf

 

Funding

Not applicable.

 

Institutional Review Board Statement

Not applicable.

 

Informed Consent Statement

Not applicable.

 

Copyrights

Copyright for this article is retained by the author(s), with first publication rights granted to the journal.

This is an open-access article distributed under the terms and conditions of the Creative Commons Attribution license (http://creativecommons.org/licenses/by/4.0/).