Hanoi University of Science and Technology
----School of Electrical & Electronic Engineering----
Project Report
SOIL MOISTURE MEASUREMENT AND
AUTO WATERING SYSTEM
Subject: Sensor & Instrumentation
Instructor: Nguyen Thanh Huong
Group members:
Trần Quang Anh 20212398
Trần Thế Anh 20212399
Trần Đào Nguyên Giáp 20212408
Trịnh Quang Minh 20210589
0
Contents
ABSTRACT .............................................................................2
I. Introduction..........................................................................3
1. Problem statement...............................................................3
2. Block diagram.....................................................................3
II. Implementation...................................................................4
1. Block’s components.............................................................4
2. Analysis and measurement calibration...............................9
3. Circuit design......................................................................11
4. Measurement results............................................................14
5. Comparison of sensors........................................................17
III. Conclusion..........................................................................17
1. Project evaluation................................................................17
2. Task distribution..................................................................17
REFERENCES.........................................................................18
1
ABSTRACT
In the realm of precision agriculture, efficient soil moisture management is
paramount for optimizing crop yield and resource utilization. This mini project
introduces a cost-effective and user-friendly solution for accurate soil moisture
measurement using Arduino microcontrollers. The project aims to address the critical
need for real-time data on soil moisture levels, enabling farmers to make informed
decisions regarding irrigation schedules and water conservation.
The proposed system employs a soil moisture sensor interfaced with an Arduino
microcontroller to measure the volumetric water content of the soil. The sensor
utilizes capacitance-based technology, offering a reliable and non-invasive method to
assess soil moisture levels. The Arduino, acting as the central processing unit, collects
data from the sensor and translates it into meaningful information displayed on a user
interface, providing valuable insights for agricultural decision-making.
The mini project encompasses the design, development, and implementation of the
soil moisture measurement system. The hardware components include the soil
moisture sensor, Arduino board, and a simple yet effective user interface. The
Arduino's versatility and programmability allow for customization based on specific
crop requirements and soil types, enhancing the adaptability of the system to diverse
agricultural scenarios.
The system's software is programmed to process and interpret the sensor data,
presenting it in a user-friendly format for easy comprehension. Additionally, the
system can be configured to send alerts or notifications when soil moisture levels
deviate from predefined thresholds, ensuring timely intervention to prevent over-
irrigation or water stress.
The mini project also explores the potential integration of wireless communication
modules, such as Bluetooth or Wi-Fi, to enable remote monitoring and control. This
feature enhances the system's accessibility, allowing farmers to manage their fields
from a distance, reducing the need for physical presence.
In conclusion, the Arduino-based soil moisture measurement system presents an
affordable and scalable solution for precision agriculture. By providing real-time data
on soil moisture levels, the system empowers farmers to make informed decisions,
ultimately contributing to sustainable farming practices, resource conservation, and
improved crop productivity.
2
I. Introduction:
I.1. Problem statement:
Precision agriculture has emerged as a pivotal paradigm in modern farming
practices, emphasizing the efficient use of resources to optimize crop yield while
minimizing environmental impact. One of the critical factors influencing agricultural
productivity is soil moisture content. In many regions, imprecise irrigation practices
lead to water wastage, increased operational costs, and suboptimal crop growth.
Traditional methods of assessing soil moisture are often labor-intensive, time-
consuming, and lack the real-time data necessary for responsive decision-making.
In this context, our mini project addresses the challenge of precise soil moisture
measurement through the integration of Arduino microcontrollers. Conventional
approaches to soil moisture monitoring often fall short in providing accurate, timely,
and cost-effective solutions for farmers. The proposed system aims to bridge this gap
by leveraging the capabilities of Arduino to develop a reliable and accessible soil
moisture measurement system. By doing so, the project seeks to empower farmers
with the means to monitor and manage soil moisture levels with greater precision,
fostering sustainable agricultural practices and contributing to increased crop yield
and resource efficiency. The need for a scalable, adaptable, and user-friendly solution
to soil moisture measurement forms the basis of this mini project, aligning with the
broader goal of advancing precision agriculture for the benefit of the farming
community and the environment.
I.2. Block diagram
Figure 1. Block diagram of the circuit
The soil moisture will be recorded by 3 different types of sensors: resistive,
capacitive and Chirp. The data will be displayed on LCD 20x4 via Arduino UNO, and is
used to activate the watering system depending on the conditions. Components of each
block is shown in the illustration.
3
II. Implementation
1.1 Block’s components:
II.1.1. Soil moisture sensor
II.1.1.1. Capacitive soil moisture Sensor
Input voltage: 3.3 – 5V
Output: A0 (Analog Output). This pin provides an analog voltage signal that varies
based on the capacitance changes.
Operating principle:
A positive plate, a negative plate and the gap between the plates known as
dielectric. There are different physical forms of capacitor, but all have two
metal plates and di-electric between them.
A capacitive moisture sensor works by measuring capacitance changes caused
by the changes in the dielectric. It does not measure soil moisture directly (as
pure water does not conduct electricity well), instead it measures the ions that
are dissolved in the moisture. Capacitive measuring basically measures the
dielectric that is formed by the soil and the water is the most important factor
that affects the dielectric.
The capacitance of the sensor is measured with the help of a 555 timer-based
circuit that creates a voltage which is directly proportional to the capacitor
inserted in the soil. We then measure this voltage by use of an Analog to Digital
Converter which produces a value that we represent as percentage of soil
moisture.
Figure 2. Schematic and pins configuration of capacitive soil moisture sensor
4
II.1.1.2. Resistive soil moisture sensor
Input voltage: 3.3 – 5V
Output: A0 (Analog Output). This pin provides an analog voltage signal that varies based
on the electrical conductivity changes.
Operating principle:
The resistive soil moisture sensor typically consists of two electrodes (probes)
inserted into the soil.
The space between the electrodes is covered with a material that allows electrical
conductivity and is sensitive to changes in moisture.
As the soil moisture level changes, the electrical conductivity between the two
electrodes also changes.
Dry soil has higher electrical resistance, while wet soil has lower resistance.
The analog output A0 is taken by the voltage drop on potentiometer.
Figure 3. Schematic and pins configuration of resistive soil moisture sensor
II.1.1.3. Chirp soil moisture sensor
Input voltage: 3 – 6V
Output: I2C data of temperature, humidity and moisture
Function: Measure temperature, humidity and moisture, and auto alert watering.
Operating principle:
5
Uses capacitive sensing to measure moisture. 1MHz square wave (system clock is
used for that) is output from the chip through a resistor into a big pad that together
with the surrounding ground plane forms a parasitic capacitor. The resistor and the
capacitor form a low pass filter whose cutoff frequency changes with changing
capacitance.
Soil around the sensor acts as an electrolyte whose dielectric constant changes
depending on the amount of moisture in it, so the capacitance of our makeshift
capacitor changes too.
The filtered square wave is fed into a peak detector formed of out a diode and a
capacitor - the diode lets through positive peaks and the capacitor stores the
maximum voltage of those peaks. This voltage is measured by an ADC in the
microcontroller.
Figure 4. Chirp sensor and pins configuration
1 – MISO, 2 – VCC, 3 – SCK/SCL, 4 – SDA, 5 – RESET, 6 – GND
II.1.2. Arduino UNO R3
Arduino Uno R3 is a microcontroller board in Arduino family based on the ATmega328P
microcontroller.
Function: Reads an analog sensor signal from A0 and displays the sensor data on a 20x4
LCD using a 4-bit mode interface, provide the signal controller to the pump and LEDs
Pins configuration:
14 digital I/O pins (0-13), used for input or output.
6 analog input pins (A0-A5) for reading varying voltage levels.
Power pins: VIN (external power supply), 5V, 3.3V, and multiple GND pins.
6
Other pins: RESET (resetting the microcontroller), AREF (analog reference).
Communication ports: RX/TX for serial communication, I2C (A4/SDA, A5/SCL),
and SPI (10-SS, 11-MOSI, 12-MISO, 13-SCK).
Figure 5. Arduino UNO R3 board
II.1.3. LCD 20x4
Function: Displays the sensor data in real-time and give the command (if necessary)
Pins configuration:
RS pin indicates whether the data being sent is a command or actual character data.
E pin enables or triggers the LCD to read the incoming data.
R/W pin determines whether the data bus from 00 to 07 is used for writing.
VDD, anode (A) and GND, cathode(K) pins are connected power source for LCD.
Figure 6. Pins configuration of LCD 20x4
II.1.4. LEDs
7
Function: Notify that the pump is turned on or not depending on the moisture.
II.1.5. Relay
Input voltage: maximum 5V
Maximum load voltage:
COM pin: 125VAC – 15A
NC (normally-closed) and NO (normally-opened) pin: 250VAC – 10A
Function: As a contactor of pump’s controlling
Operating principle:
This relay is an electromechanical switch that is controlled by an electrical signal.
It consists of a coil and one or more sets of contacts.
When a current flows through the coil (controlled by the Arduino), it generates a
magnetic field that attracts or repels the switch contacts, either closing or opening
the circuit.
Figure 7. Pin configuraion of relay (left) and pump (right)
II.1.6. Pump
Function: Provide the water into the area that is needed
Operating principle: The pump is dipped in the water and connected with a long tube to
pump the water.
1.2 Analysis and measurement calibration
2.2.1. Resistive soil moisture sensor
8
Output voltage of sensor can be defined as
Rs
V 0= V
R A + Rs cc
Figure 8. Simplified circuit of resistive soil moisture sensor
For simple measurement, we can assume that the resistance changes linearly when
humidity changes, that is, the output voltage is proportional to moisture.
When there is no interaction between soil and sensor (in free air), Rs >> Ra, Vo = 5V.
When the sensor is in very high moisture soil (nearly 100%), Rs = 0 => Vo = 0
Then, soil moisture U (%) can be calculated by formula:
(
U ( % )= 1−
Vo
5 )
×100 % (1)
In Arduino IDE, we can use this formula by using function map(read_val, 0, 1023, 0,
100) to get moisture value, which read_val is output voltage Vo, and analog range 0-1023
is corresponding to output range 0-5V then converted to humidity range 0-100%.
2.2.2. Capacitive soil moisture sensor
From the schematic, we can notice that two conducting plates form a capacitor.
Capacitance and reactance can be determined by formula:
εA 1
C= ; X c=
d 2 πf .C
which:
C: capacitance of the capacitor
ε : dielectric constant
d: distance between 2 plates
9
X c: capacitive reactance
f: frequency of square wave (created by timer 555)
When the sensor is in soil, the water in soil change the capacitance, which also
changes the reactance. This result in the change of the output voltage.
From the capacitance formula, we can notice that the moisture is proportional to
capacitance, thus the moisture is also proportional to output voltage.
The soil moisture formula (1) in previous part can be written as:
Dry boundary −Output voltage
U ( % )= ×100 %
Dry boundary −Wet boundary
which:
Dry boundary: output voltage in free air
Wet boundary: output voltage in water
These 2 values can be found through experiments by finding analog output. In free air
and in water, analog values are 260 and 700, respectively.
2.2.3. Chirp soil moisture sensor
The working principle is similar to capacitive soil moisture sensor. The capacitance
value is recorded and can be read through Arduino by I2C communication.
Here, an Arduino library name <I2CSoilMoistureSensor.h> is used to interact with
sensor, in which function getCapacitance() is used to get capacitance value.
Having the capacitance value x , the moisture can be determined by the formula from
the datasheet:
U ( % )=( A x 2 +Bx +C ) × 100 %
which A = 1.007 ×10−6, B = 2.4885 ×10−5, C = −0.062508722
10
Figure 9. Relationship curve between moisture and capacitance value
2.3. Circuit design
The Arduino board is connected as schematic below:
Figure 10. Overall circuit diagram
11
1. Pin 0 connects to the relay to activate the pump. The relay is connected to external
voltage source.
2. Pin 2,3 are connected to LEDs to notify whether the pump is turned on or not. If
the pump is turned on, LED red is ON and LED green is OFF, and vice versa.
3. Pin 6,7,9,10,11,12 is connected to LCD 20x4 to display soil moisture and state of
the pump. An Arduino name <LiquidCrystal.h> is used to interact with LCD.
Figure 11. Implementation of circuit connecting to sensors
With resistive and capacitive sensor, VCC and GND pins of sensor are connected to
board to supply power for the sensor. Pin AO is connected to pin A0 to read the analog
output.
With Chirp sensor, VCC and GND pin are connected to board, SDA and SCL pins of
sensor are connected to SDA and SCL pins of the board to read the capacitance.
Flowchart of the circuit:
12
Figure 12. Flow chart of overall circuit and display
Initially, the circuits are turned off, so nothing is active. After turning on the circuits,
the sensor measures the moisture from soil and then the LCD shows its measurement. If
the moisture is larger than 30%, green and red LED be ON, OFF respectively.
If the moisture is equal to or less than 30%, the green LED is OFF, the red LED is
ON, LCD will notify watering, the pump will be activated through relay and stop until to
reach over 70%, the watering notification on LCD will disappear, the pump will be
deactivated, and circuit will be back in initial state.
13
2.4. Measurement result
2.4.1. Resistive soil moisture sensor
Time (s) Moisture (%) ∆ U (%)
1 96.2 1.14
2 95.8 0.74
3 95.4 0.34
4 95.2 0.14
5 95.0 -0.06
6 94.8 -0.26
7 94.6 -0.46
8 94.6 -0.46
9 94.4 -0.66
10 94.6 -0.46
U =95.06 %
√
n
∑ Δ ui
i=1
Standard deviation=σ= =0.59(%)
n−1
√∑
n
Δ ui
i=1
Absolute error=∆ U= =0.18 (%)
n
∆U
Relative error (Accuracy )=∆ U %= =0.19 %
U
U =95.06 ± 0.18 ( % )=95.06 % ± 0.19 %
14
2.4.2. Capacitive soil moisture sensor
Time (s) Moisture (%) ∆ U (%)
1 97.95 -0.23
2 98.21 0.03
3 98.21 0.03
4 97.95 -0.23
5 98.21 0.03
6 98.46 0.28
7 98.21 0.03
8 98.21 0.03
9 97.95 -0.23
10 98.46 0.28
The sensor reacts with the change of moisture immediately.
U =98.18 %
√
n
∑ Δ ui
i=1
Standard deviation=σ= =0.19(%)
n−1
√∑
n
Δ ui
i=1
Absolute error=∆ U= =0.06 (%)
n
∆U
Relative error ( Accuracy )=∆ U %= =0.06 %
U
U =98.18 ± 0.06 ( % ) =98.18 % ± 0.06 %
15
2.4.3. Chirp soil moisture sensor
Time (s) Moisture (%) ∆ U (%)
1 97.75 0.12
2 97.75 0.12
3 97.95 -0.08
4 97.95 -0.08
5 97.95 -0.08
6 97.95 -0.08
7 97.75 0.12
8 97.95 -0.08
9 97.95 -0.08
10 97.75 0.12
The sensor takes 2-3s to setup and finish the measurement.
U =97.87 %
√
n
∑ Δ ui
i=1
Standard deviation=σ= =0.10(%)
n−1
√∑
n
Δ ui
i=1
Absolute error=∆ U= =0.03 (%)
n
∆U
Relative error ( Accuracy )=∆ U %= =0.03 %
U
U =97.87 ± 0.03 ( % ) =97.87 % ± 0.03 %
16
2.5. Comparison of sensor
Attribute Resistive Capacitive Chirp
Cost (VND) 9000 49000 68000
Measurement range 1 ÷ 98 % 0 ÷ 100 % 0 ÷ 100 %
Accuracy Poor Good Excellent
Sensitivity Medium High High
Salinity sensitivity Extreme Yes in high salinary Yes in high salinary
Linearity Fair Good Good
Complexity Easy Easy to intermediate Intermediate
Long-term ability <1 year 10-20 years Up to 20 years
Power use Low Low Very low
III. Conclusion
III.1. Project evaluation
Constructed the moisture formula of each sensor for measurement
Implemented the measurement circuit with watering system
Successful simulation, circuit works stable, the actual measured values are
approximately expected values.
Make comparison 3 types of soil moisture sensors.
III.2. Task distribution
Contribution
Student Individual works
percentage
Trần Quang Anh - Implement real circuit and code Arduino. 25%
20212398 - Test circuit and measure data.
Trần Thế Anh - Make project report. 25%
20212399
Trần Đào Nguyên Giáp - General description of the circuit’s operating 25%
20212408 principle and block diagram’s function.
- Do simulation on Proteus
Trịnh Quang Minh - Make presentation for project. 25%
20210589
17
REFERENCE
[1] Resistive and capacitive soil moisture sensor diagram and working principle
[Link]
[2] Chirp soil moisture sensor information [Link]
[3] Arduino UNO R3 information [Link]
18