LAB-3-SOIL
LAB-3-SOIL
Laboratory Activity 3
Submitted by:
Miro G. Angeles
Deen Reiner B. Crusem
Julius Caezar R. Eugenio
BS CPE 4-1
Submitted to:
Prof. Aileen V. Rocillo
November 2024
Laboratory Activity 3
Arduino-Based Soil Moisture Monitoring and Irrigation Automation System
OBJECTIVES
At the end of the experiment, the students should be able to:
1. Monitor soil moisture levels using a soil moisture sensor.
2. Automatically control a water pump through a relay module based on moisture readings.
3. Display real-time moisture data on an LCD screen.
Introduction
Automated technologies for tracking soil conditions and managing irrigation are
essential to smart agriculture because they maximize water use and boost crop productivity.
Yu (2021) asserts that because soil moisture directly affects the amount of irrigation that plants
need, it is one of the most important variables affecting crop yield. Crop problems like water
stress and dehydration, which can result in decreased quality and yield, can be avoided with
proper soil moisture management. By keeping an eye on soil moisture levels, farmers can
optimize crop quality and reduce water waste, guaranteeing that plants get the exact amount
of water they require.Farmers may prevent the negative consequences of both excessive and
insufficient watering, which have a substantial impact on crop health and yield, by keeping an
eye on soil moisture. In order to prevent these issues, Rivai (2019) emphasizes the
significance of regular and accurate irrigation, stressing that inadequate water management
can result in stunted growth, lower yields, and even crop loss. Automated irrigation and real-
time soil moisture monitoring assist maintain ideal soil conditions. By ensuring that water is
used responsibly and crops receive the precise amount of water they need, smart irrigation
systems help to improve agricultural operations' sustainability and efficiency (Taneja, 2017).
This approach is especially valuable in water-scarce regions where resource conservation is
critical, as proper automation supports both agricultural success and environmental protection
by reducing unnecessary water use (Kumar, 2022).
This project builds an automatic irrigation and soil moisture monitoring system using
an Arduino, relay module, water pump, LCD display, and soil moisture sensor. The Arduino
receives data from the soil moisture sensor, which determines the soil's water content. To start
irrigation, the Arduino automatically activates the water pump via the relay module if the
moisture content drops below a predetermined threshold. In order to securely operate high-
power components like the water pump, the Arduino serves as the primary control unit,
processing input from the soil moisture sensor and sending signals to the relay, which
operates as an electrical switch (Chew, 2020). By doing this, over-watering is avoided and
water resources are preserved because the water pump only runs when required. In order to
guarantee that the soil is sufficiently irrigated without wasting any water, the water pump then
distributes precise amounts of water. Furthermore, users may immediately monitor soil
conditions and measure the efficacy of the irrigation process thanks to the LCD display's real-
time soil moisture readings. By reducing labor costs and encouraging optimal water use, this
integrated system provides an effective, automated method of crop irrigation that supports
agricultural sustainability on both an economic and environmental level.
CIRCUIT DIAGRAM
This schematic diagram shows a circuit where an Arduino Uno (U2) controls a 16x2
LCD display (U1), a sensor (SEN1), and a water pump motor (M1) through a relay module
(K1). The components are powered by a 5V source, with the Arduino acting as the central
controller for processing sensor data and operating the motor.
Procedure
The table below provides a summary of the pin assignments for the various components
connected to the Arduino Uno board:
After thoroughly reviewing the Arduino code, upload it to the Arduino board
using the Arduino IDE and conduct several tests to ensure proper functionality.
Simulate different soil moisture levels by placing the sensor in dry or wet soil and
observe the system’s response on the LCD, ensuring it accurately displays the
moisture percentage and pump status. Verify that the relay triggers the pump when
moisture falls below 30% and turns it off above 70%. If issues arise, check wiring,
sensor readings, and code logic, adjusting parameters as needed for reliable
operation. Repeat testing to confirm consistent performance.
Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h> void loop() {
// Read the raw soil moisture sensor value
// Initialize the LCD with I2C address 0x27 and soilMoistureValue = analogRead(A0);
16x2 display size
LiquidCrystal_I2C lcd(0x27, 16, 2); // Debugging: Log raw soil sensor value to the
Serial Monitor
const int AirValue = 600; // Dry soil sensor Serial.print("Raw Soil Value: ");
reading (adjust if needed) Serial.println(soilMoistureValue);
const int WaterValue = 310; // Wet soil sensor
reading // Convert the sensor value to a moisture percentage
const int RelayPin = 8; // Relay pin for moisturePercentage = map(soilMoistureValue,
controlling the pump AirValue, WaterValue, 0, 100);
moisturePercentage = constrain(moisturePercentage,
int soilMoistureValue = 0; // Raw sensor reading 0, 100); // Ensure value is between 0-100%
float moisturePercentage = 0; // Mapped moisture
percentage // Debugging: Log moisture percentage to the Serial
bool pumpStatus = false; // Track pump state Monitor
float lastMoisturePercentage = -1; // Previous Serial.print("Moisture Percentage: ");
moisture value for LCD optimization Serial.println(moisturePercentage);
bool lastPumpStatus = false; // Previous pump
// Ensure the LCD always displays moisture
state
percentage
void setup() { if (moisturePercentage != lastMoisturePercentage) {
Serial.begin(9600); lcd.setCursor(10, 0);
Serial.println("System Initialization..."); lcd.print(" "); // Clear previous value
lcd.setCursor(10, 0);
// Initialize the LCD and turn on the backlight lcd.print(moisturePercentage, 0); // Display
lcd.init(); moisture percentage
lcd.backlight(); lcd.print("%");
lastMoisturePercentage = moisturePercentage;
// Setup the relay pin }
pinMode(RelayPin, OUTPUT);
digitalWrite(RelayPin, HIGH); // Ensure the
water pump is off initially
Serial.println("Initialization Complete");
}
// Control the water pump based on moisture level
if (moisturePercentage < 30.0 && !pumpStatus) {
Serial.println("Pump Turned ON"); // Debugging
digitalWrite(RelayPin, LOW); // Turn the water pump on (LOW triggers the relay)
pumpStatus = true;
}
else if (moisturePercentage > 70.0 && pumpStatus) {
Serial.println("Pump Turned OFF"); // Debugging
digitalWrite(RelayPin, HIGH); // Turn the water pump off (HIGH turns relay off)
pumpStatus = false;
}
Results
The outcomes of the Soil Moisture Monitoring and Irrigation System met the objectives
of the project effectively. The soil moisture sensor accurately measured moisture levels, and
the relay module automated the activation and deactivation of the water pump. When the soil
moisture level dropped below the set threshold of 30%, the water pump was triggered,
demonstrating efficient irrigation automation. Conversely, the pump turned off when the
moisture level exceeded 70%, ensuring water conservation and avoiding over-irrigation.
Additionally, the LCD display consistently showed real-time moisture readings and
pump status, confirming successful data communication between the sensor, Arduino, and
display module. The system reliably adjusted irrigation according to varying soil conditions,
emphasizing its potential as a sustainable solution for agricultural applications.
Test No. Soil Moisture Pump LCD Status Notes
Level (%) Status
1 25 On Displayed: “Pump: ON” Works as expected
2 75 Off Displayed: “Pump: OFF” Works as expected
3 40 On Displayed: “Pump: OFF” Works as expected
4 80 Off Displayed: “Pump: OFF” Works as expected
5 20 On Displayed: “Pump: ON” Works as expected
6 65 Off Displayed: “Pump: OFF” Works as expected
The results from testing the Arduino-Based Soil Moisture Monitoring and Irrigation
Automation System demonstrated that the soil moisture sensor effectively detected varying
moisture levels in the soil and triggered appropriate actions. When the moisture level fell below
the threshold of 30%, the system automatically activated the water pump, ensuring timely
irrigation. Conversely, the pump deactivated once the moisture level exceeded 70%,
highlighting the system's ability to conserve water. The LCD display successfully provided
real-time updates on soil moisture levels and the pump's status, offering clear and accessible
feedback for the user.
However, during the testing phase, some challenges and potential areas for
improvement were identified. One challenge encountered was the sensor's sensitivity to
external environmental factors, such as variations in soil composition and ambient
temperature. These factors occasionally caused slight inconsistencies in the readings.
Additionally, the water pump's response time to changing soil moisture levels was sometimes
delayed, particularly when transitioning between thresholds. This delay could potentially
impact irrigation timing in critical scenarios.
Proposed Improvements:
1. Enhanced Calibration of the Soil Moisture Sensor: Regular calibration of the sensor
to account for variations in soil type and environmental conditions could improve the
accuracy of moisture readings. Adding an adjustable threshold mechanism in the
system design would also enhance its adaptability for different agricultural
applications.
2. Integration of a Backup Power Source: Including a backup power source, such as
a rechargeable battery, could ensure uninterrupted operation during power outages,
which are critical for maintaining consistent irrigation cycles.
3. Improved Response Time for the Water Pump: Optimizing the relay module's
operation or incorporating a faster-acting relay system could address the delayed
response of the pump, ensuring more precise irrigation control.
Conclusion
In conclusion, the project objectives for the Arduino-Based Soil Moisture Monitoring
and Irrigation Automation System were successfully achieved. The integration of a soil
moisture sensor with the Arduino allowed the system to accurately detect real-time moisture
levels in the soil and automate the irrigation process. When the moisture level fell below the
threshold of 30%, the water pump was activated to ensure adequate irrigation, and it was
automatically deactivated when the moisture level exceeded 70%, conserving water
effectively.
Furthermore, the system included an LCD display that provided clear, real-time
feedback on soil moisture levels and the pump's operational status. This automation improved
the system's efficiency, reduced manual intervention, and ensured consistent monitoring and
irrigation.
Lastly, the overall functionality of the system was demonstrated successfully through
testing under various moisture conditions. The integration of sensor technology, Arduino
components, and automation illustrated a practical and reliable application for sustainable
agriculture. The project highlights how such systems can enhance agricultural practices by
optimizing water usage and ensuring timely irrigation, offering a promising solution for efficient
resource management in farming.
References
Yu, L., Gao, W., R Shamshiri, R., Tao, S., Ren, Y., Zhang, Y., & Su, G. (2021). Review of
research progress on soil moisture sensor technology
Kumar, K., Devi, V. L., & Kumar, M. D. (2022). Design of solar powered smart water pump for
moisture controller in agriculture sector. Materials Today: Proceedings, 64, 130-140.
Rivai, M., Ashari, M., & Mustaghfirin, M. A. (2019, October). Drip irrigation system using bldc
motor-driven direct pumping and soil moisture sensor. In 2019 International
Conference on Computer Science, Information Technology, and Electrical Engineering
(ICOMITEE) (pp. 221-226). IEEE.
Taneja, K., & Bhatia, S. (2017, June). Automatic irrigation system using Arduino UNO. In 2017
International Conference on Intelligent Computing and Control Systems (ICICCS) (pp.
132-135). IEEE.
Chew, K. M., Tan, S. C. W., Loh, G. C. W., Bundan, N., & Yiiong, S. P. (2020, February). IoT
soil moisture monitoring and irrigation system development. In Proceedings of the
2020 9th International Conference on Software and Computer Applications (pp. 247-
252).
Appendices
Fig 7. Members Wiring and Coding the Soil Moisture Monitoring System