Trusted Academic Publisher
Serving Researchers Since 2012

Machine Learning Based IoT Irrigation System for Water Optimization

DOI : https://doi.org/10.5281/zenodo.19973758
Download Full-Text PDF Cite this Publication

Text Only Version

Machine Learning Based IoT Irrigation System for Water Optimization

Anushka Bhatt

Instrumentation Engineering Vishwakarma Institute of Technology, Pune

Trisha Belitkar

Instrumentation Engineering Vishwakarma Institute of Technology, Pune

Praveen Pol

Instrumentation Engineering Vishwakarma Institute of Technology, Pune

Sagrika Bhagat

Instrumentation Engineering Vishwakarma Institute of Technology, Pune

Bhoomi Date

Instrumentation Engineering Vishwakarma Institute of Technology, Pune

Vikas J Nandeshwar

Instrumentation Engineering Vishwakarma Institute of Technology, Pune

Abstract – Irrigation in the field of agriculture is gradually improving by incorporating sensors and small microcontrollers to facilitate the management of water usage in the field in a more efficient manner. This article discusses a workable IoT-based irrigation system that can be easily deployed in the field by incorporating sensors that utilize an ESP32 microcontroller, capacitive soil sensors, and a DHT22 module. The system has been developed by using a lightweight Python/Flask-based backend and a random forest classifier to monitor the soil moisture levels in the field. The system also utilizes publicly available weather information by calling an external API to prevent irrigation before the onset of rainfall in the field. The system has been successfully tested in the field by improving the soil moisture levels in the field by a significant degree by reducing the number of unnecessary irrigations performed in the field.

Keywords Smart irrigation, IoT, Machine learning, Precision agriculture, Soil moisture sensors, Water resource management.

  1. INTRODUCTION

    Water required for irrigation is a finite and expensive resource in many agricultural areas. The conventional method of irrigation is either through the visual inspection of the soil state or through the application of fixed irrigation schemes. The consequence of such schemes is either over-irrigation or under-irrigation depending on the prevailing environmental conditions. The modern application of Internet of Things technology has the capability to monitor the state of the soil as well as the environmental parameters in real time. Such modern technologies can make the irrigation scheme proactive instead of reactive, as it can utilize the prevailing environmental parameters in real time to decide the state of the soil. The modern project has been designed to consist of three different components that can be utilized to implement the modern irrigation system. The components of the modern project are the development of an ESP32-based compact module that can be utilized to sense the state of the soil as well as the prevailing climatic conditions, the development of a Python Flask-based module that can be utilized to implement the decision-making component of the modern project, and the development of a

    Random Forest-based module that can be utilized to implement the decision-making component of the modern project.

  2. LITERATURE REVIEW

    Literature has documented numerous IoT-based irrigation systems, along with numerous comprehensive surveys on this specific field. An extensive review on smart irrigation systems is provided by Garcia et al., where the authors have identified the most commonly monitored parameters, including moisture, environmental factors, and water level. This literature also highlights the growing trend of adopting automatic decision logic for efficient water usage. Recent research focuses on practical irrigation and greenhouse monitoring system designs based on the ESP32, emphasizing its affordability, on-board Wi-Fi, and power efficiency. Pereira et al. proposed a smart drip irrigation system based on the ESP32, which includes soil moisture, temperature, and humidity sensors, with data transmitted to cloud-based displays. This body of research confirms the ESP32’s viability for real-time agricultural monitoring. Systematic reviews of irrigation automation research conducted between 2015 and 2021 indicate that there is a move towards data-based methodologies, away from traditional control strategies. However, many of the implemented methodologies remain static, often failing to include real-time weather forecasting, which limits their ability to respond dynamically to environmental changes. In the field of agricultural analytics, the effectiveness of machine learning techniques has been demonstrated in the past few years, among which the efficacy of the Random Forest classifier has been prominent in terms of robustness, noise tolerance, and interpretability of the results. The effectiveness of the Random Forest classifier in the prediction of irrigation needs has already been established in the past, thus validating the application of the technique in the development of the intelligent decision-making system for irrigation needs in the current work. Recent studies published in 2023 and 2024 highlight the application of the technique in real-world applications, including the integration of Internet of Things technology, cloud computing, and analytics in the

    decision-making system, as well as the demonstration of the effectiveness of the system in terms of the savings that can be achieved in the water usage by incorporating the decision intelligence in the system, despite the challenges faced in the application of the system in the real world in terms of reliability. However, the application of the technique in the development of the system has not been demonstrated in the past in the form of a compact system that can be replicated in the real world using the ESP32-based sensing module, real-time weather API, Flask-based backend, and random forest-based decision intelligence module proposed in the current work.

  3. METHODOLOGY

    1. Sensing and Data Acquisition Layer

      The ESP32 microcontroller has been used for this system, which is cost-effective, reliable, and has built-in Wi-Fi connectivity. The data acquisition layer of the system involves aggregation of data from various sensors, including:

      • Ca acitive soil moisture sensors, which provide reliable data with good corrosion resistance

      • DHT22 se sors, which provide ambient temperature and humidity data

      • Wate flow and rainfall sensors, which can be used for validating purposes ESP32 sends the data in compact JSON format at regular intervals after performing basic preprocessing operations such as filtering and timestamping. Local data caching is used for maintaining data integrity during network disconnections.

    2. Backend Processing and Data Management

    A Python-based Flask framework is used for data acquisition, validation, and storage in the SQLite database for simplicity and reproducibility of results. The weather data, including rainfall probability, temperature, and humidity, is obtained from the OpenWeatherMap API for generating weather forecasts.

    A Random Forest algorithm is used for training the model on historical environmental data and irrigation decisions, which can be used for adapting the irrigation requirements of the system, unlike traditional systems where decisions are made based on thresholds, which can be inflexible for real-world scenarios. The proposed system can adapt irrigation requirements based on the model, which can be expressed as:

    • The system will rovide a probability score:

      P(Irrigation = Requred | X)

      A safe decision strategy is implemented for irrigation decisions, which can be expressed as follows:

    • Irrigati n will be initiated only if: P > P_threshold, where P_threshold is a high confidence level, and

    • The rai fall probability should be below a certain level. Irrigation should not be initiated during rainfall, which can be naturally available for the crops, or during periods of sufficient moisture levels of the soil. As inferred from the machine learning output, the microcontroller generates a digital control signal that controls the relay or transistor driver circuit,

    thus enabling the ON/OFF operation of the water pump as required. Upon the operation of the irrigation system, water is supplied through the irrigation pipe, thus causing the soil moisture level to gradually rise. The updated sensor readings are fed back into the system to form a loop of intelligent control.

    Fig 1. Basic Logic Diagram

    Fig.2 Circuit Diagram

  4. THEORY

    Table 1- List of components

  5. WO ING PRINCIPLE OF THE PROPOSED SYSTEM

    Sr.

    No.

    Major Component

    Features

    1.

    ESP 32

    Dual-core processor with built-in Wi-Fi and Bluetooth for cloud connectivity and AI data transmission.

    2.

    Capacitive Soil Moisture Sensor

    Measures volumetric water content in soil. Corrosion-resistant design for long-term outdoor durability.

    3.

    Rain Sensor Module

    Digital and analog output to detect immediate precipitation and override irrigation cycles.

    4.

    5V Relay Module

    Acts as an electrically operated switch to safely control high-power submersible pumps from the ESP32.

    5.

    Submersible Water Pump

    DC powered pump used to deliver water to the plants when the AI or sensor logic triggers a ‘1’.

    6.

    Micro USB Data Cable

    High-speed data transmit and charging cable used for flashing firmware and providing power to the ESP32.

    7.

    9V HW Battery

    External power source for the water pump, integrated into the circuit via a common ground architecture.

    The proposed Automated Irrigation System operates using a hybrid decision mechanism that combines real-time sensing, machine learning-based intelligence, and crop- and soil-aware control logic. The system follows a closed-loop architecture integrating sensing, processing, prediction, communication, and actuation modules.

    1. Soil Moisture and Envi nmental Data Acquisition

      The system continuously collects environmental and soil parameters using integrated sensors:

      • Soil moisture sensor

      • Temperature sensor

      • Humidity sensor

        The soil moisture sensor measures volumetric water content by detecting resistance/capacitance variation in soil. The analog signal generated is converted into digital form using the microcontrollers ADC.

        In addition to real-time sensor readings, the system retrieves:

      • Forecasted rainfall probability (via API/cloud service)

      • User-selected crop type

      • User-selected soil type (sandy, loamy, clayey, etc.)

        The crop and soil type are selected through the web interface and stored as configuration parameters.

    2. Feature Construction and Preprocessing

      The microcontroller/cloud module constructs a feature vector consisting of:

      X = {Mt, Mtrend, T, H, Rf, C, S}

      Where:

      • Mt= current soil moisture

      • Mtrend

        = moisture variation over time

      • T= temperature

      • H= humidity

        f

      • R = forecasted rainfall probability

      • C= crop type

      • S= soil type

        Crop type and soil type are encoded as categorical variables and incorporated into the decision model.

    3. Machine Learni -Based Decision Intelligence

      A Random Forest classifier is trained using historical environmental data and corresponding irrigation decisions.

      Unlike conventional threshold-based systems, the proposed system dynamically adjusts irrigation requirements based on:

      • Crop-specific water demand

      • Soil water retention capacity

      • Environmental conditions

      • Predicted rainfall

        The model outputs a probability score:

        P(Irrigation = Required X)

        A conservative decision policy is applied:

        Irrigation is triggered only when:

        1. P > Pthreshold (High-confidence requirement), and

        2. Forecasted rainfall probability is below a predefined limit.

        This ensures irrigation is not activated when natural rainfall is expected or when soil retention characteristics already support adequate moisture levels.

    4. Actuation Mechanism (Pump Control)

      Based on the ML output:

      • The microcontroller generates a digital control signal.

      • The signal activates a relay/transistor driver circuit.

      • The water pump is turned ON or OFF accordingly.

        When irrigation is activated:

      • Water is supplied through the irrigation pipeline.

      • Soil moisture gradually increases.

      • Updated readings are continuously fed back into the system.

        This establishes a closed-loop intelligent control system.

    5. IoT Communication and User Interaction

      The system is connected to a cloud/web platform via Wi-Fi. The web interface allows users to:

      • Monitor real-time soil moisture

      • View temperature and humidity

      • Check pump status

      • Select crop type

      • Select soil type

      • Observe irrigation history

        The selected crop and soil parameters directly influence the ML decision model, enabling adaptive irrigation tailored to agronomic conditions.

    6. Operational Cyc

      The system operates continuously in the following loop:

      1. Acquire sensor data

      2. Retrieve weather forecast

      3. Read crop and soil selection

      4. Construct feature vector

      5. Predict irrigation probability using Random Forest

      6. Apply conservative decision rule

      7. Activate/deactivate pump

      8. Update dashboard

      9. Repeat cycle

    7. ture of Control Strategy

      • Control Type: Intelligent feedback control

      • Decision Strategy: Supervised Machine Learning (Random Forest)

      • Adaptivity: Crop-aware and soil-aware

      • Architecture: IoT-eabled cloud-assisted embedded system

    8. K Advantages of the Modified Working Principle

      • Adaptive irrigation instead of fixed thresholds

      • Crop-specific water optimization

      • Soil retention-aware decision making

      • Rainfall-aware irrigation avoidance

      • Reduced water wastage

      • Improved agricultural yield

        Fig 3. Working flow chart

  6. RESULTS AND DISCUSSIONS

    1. Evaluation Metrics

      System performance was evaluated by different metrics such as water usage, soil moisture levels, false irrigations, and response time.

    2. Observed Results

      In the pilot plots, it was observed that our system reduced water usage by around 28% compared to a fixed schedule, while keeping soil moisture levels within the range almost always. The results obtained by the Random Forest model showed high precision and recall values. Most errors occurred during sudden weather changes. The addition of weather forecasts prevented almost 40% of false irrigations.

    3. Practical Observations

      Capacitive sensors require calibration depending on soil type and periodic recalibration. Data intervals can be made shorter for better response, but it increases network load. The explainability of our system received a good response from users, resulting in reduced overrides.

      Fig 4. Actual setup

      Fig 5. User interface – Dashboard

  7. CONCLUSION

    The work in this article also presents a Smart Automated Irrigation System that integrates IoT sensors with machine learning-based decision-making to facilitate efficient irrigation management. The system integrates real-time environmental parameters with a Random Forest classifier to facilitate crop/soil-based decision-making in a closed-loop system. The ESP32-based embedded system minimizes power consumption while providing reliable communication capabilities to the cloud-based interface. The experiments show that decision-making based on real-time parameters and rainfall predictions can reduce the number of unnecessary irrigation events, thus improving water efficiency. The system can be scaled up to different crop/soil types by using the modular structure of the proposed system, which can be applied to small-scale farming as well as large-scale agricultural environments. The future work of the authors of the article will also focus on incorporating predictive modeling, multi-parameter sensing, including nutrient sensing, to enhance the reliability of the system in irrigation management, thus promoting the importance of data-driven precision agriculture in water management.

  8. FUTURE SCOPE

    The Smart Automated Irrigation System offers great performance for autonomously regulating the delivery of water in its current form, but there continue to be many opportunities for technical improvement and operational

    optimization.

      1. Integrated drainage and salinity management

        A possible step in the future could be to develop an automated drainage management subsystem to improve drainage management. Precision agriculture necessitates not only the delivery of moisture, but also the effective disposal of excess moisture in order to avoid problems like waterlogging and root-suffocation. Integration of soil moisture probes and automated drainage valves would transform the current system into a bi-directional water regulation framework to effectively manage both drought and excessive rain situations to maintain optimal soil salinity levels.

      2. Advanced predictive architectures

        The intelligence of the current system can be further enhanced by moving from a Random Forest Classifier to deep learning-based architectures. By implementing LSTM and/or Transformer-based architectures, the system could provide long-term weather forecasting and improved irrigation recommendations based on historical temporal patterns.

      3. Scalability and connectivity

        To provide more extensive coverage within the field, it is suggested that low-power long-range wireless sensor networks (WSN) based on LoRaWAN communication

        protocol be used. This would allow distributed clusters of sensors to work cooperatively under a common decision-making architecture across a larger geographic area. Finally, transitioning to a fully solar-powered system architecture will enhance the ability of the system to be operated off-grid, especially in rural applications where there is typically little or no access to electrical power.

      4. Multi-Sensory Data Collection and Edge Processing. In addition to expanding the scope, adding multi-sensory data collection allows for;

        • Nutrient Analysis – Is there a way to monitor NPK levels in real time?

        • Evapotranspiration Monitoring – How can I quantify the amount of water lost from transpiration?

        • Edge Processing – How can I process the data on the ESP32 or another gateway so that there is minimal latency when the ESP32 is not connected to the network.

      5. Mobile Device and Cloud-Based Integration

    As a final result of the synchronized mobile device/cloud service; farmers would be able to access historical and current analytic data via the mobile interface in real-time, thus making the Crop Intelligence Management System an end-to-end solution for all crop intelligence/data management needs.

  9. ACKNOWLEDGMENT

    The authors would like to express their sincere gratitude to the faculty members of the Department of Instrumentation and Control Engineering for their guidance and support during the development of this project. The laboratory facilities provided by the institution greatly contributed to the successful implementation of the system.

  10. REFERENCES

  1. A. Roy, S. Misra, S. K. Raghuwanshi, and S. Das, “AgriSens: IoT-Based Dynamic Irrigation Scheduling System for Water Management of Irrigated Crops,” IEEE Internet of Things Journal, vol. 8, no. 6, pp. 4923-4930, 2021.

  2. B. Priya et al., “IoT-Based Smart Irrigation System,” in Proc. Int. Conf. Smart Computing and Communication, 2020.

  3. . Z. A. Quadri et al., “Smart Irrigation Monitoring System Using IoT,” in Proc. Int. Conf. Computing, Communication and Automation (ICCCA), 2021.

  4. S. Alvi et al., “Intelligent Smart Irrigation Using IoT,” in Proc. Int. Conf. Emerging Trends in Engineering & Technology, 2021.

  5. P. Sharma et al., “Precision IoT Irrigation for Sustainable Agriculture,” in Proc. Int. Conf. Advances in Smart Agriculture, 2022.

  6. V. Kumar and R. Singh, “ML-Based Irrigation Decision Support System Using Random Forest,” in Proc. Int. Conf. Machine Learning and Applications (ICMLA), 2023.

  7. S. Tanwar et al., “Weather-Aware IoT Irrigation System,” in Proc. IEEE Int. Conf. IoT and Climate-Smart Agriculture, 2024.

  8. X. Li et al., “Deep Learning-Based Crop Water Requirement Prediction Using LSTM Networks,” IEEE Access, vol. 13, 2025.

  9. F. Rahman et al., “Microcontroller-Based Smart Irrigation System with AI-Powered Decision Logic,” in Proc. Electronics, Communications, and Computing Summit, pp. 33-38, an. 2025. [Online].

  10. S. Puajpanda, D. Mahapatra, S. Mishra, N. Padhy, and R. Panigrahi, “Enhancing Predictive Accuracy in IoT-Based Smart Irrigation Systems: A Comparative Analysis of Advanced Ensemble Learning Models and Traditional Techniques for Soil Fertility Assessment,” Engineering Proceedings, vol. 87, no. 1, p. 65, 2025.

  11. M. A. Febriantono, N. W. Prasetya, and S. Sidharta, “Intelligent irrigation management system based on iot and machine learning,” AIP Conference Proceedings, vol. 3110, no. 1, p. 040002, 2024.

  12. H. Hammouch, M. A. El-Yacoubi, H. Qin, and H. Berbia, “A Systematic Review and Meta-Analysis of Intelligent Irrigation Systems,” IEEE Access, vol. 12, pp. 128285-128304, 2024.

  13. D. Vallejo-Gómez, M. Osorio, and C. A. Hincapié, “Smart Irrigation Systems in Agriculture: A Systematic Review,” Agronomy, vol. 13, no. 2, p. 342, 2023.

  14. V. S. Reddy, S. Harivardhagini, and G. Sreelakshmi, “IoT and Cloud Based Sustainable Smart Irrigation System,” E3S Web of Conferences, vol. 472, p. 01026, 2024.

  15. M. Belghachi, “Smart Irrigation Systems Using AI to Optimize Water Usage,” in Cases on AI-Driven Solutions to Environmental Challenges, M. Tariq and R. Sergio, Eds. IGI Global, 2025, pp. 241-268