🔒
Global Research Authority
Serving Researchers Since 2012

Iot System for Soil Nutrients Monitoring and Crop Recommendation using ML

DOI : 10.17577/IJERTV15IS070737
Download Full-Text PDF Cite this Publication

Text Only Version

Iot System for Soil Nutrients Monitoring and Crop Recommendation using ML

Omkar Dalvi (1), Dr. Mugdha A. Kango (2), Om Rahane (3), Sultan Mujawar (4)

(134) Student , Department of E&TC, P.E.S. Modern College of Engineering, Pune, MH, India

(2) Associate Professor, Department of E&TC, P.E.S. Modern College of Engineering, Pune, MH, India

Abstract – Agricultural productivity is significantly influenced by soil fertility, environmental conditions, and appropriate crop selection. However, in many practical situations, farmers still depend on traditional practices and manual soil testing, which often fail to provide timely and accurate information for decision-making Big Data in Smart Farming A review. Recent advancements in the Internet of Things (IoT) and Machine Learning (ML) have enabled the development of smart agricultural systems that support real-time monitoring and predictive analysis Internet of Things (IoT): A vision, architectural elements, and future directions.

This work presents an IoT-based soil nutrient monitoring and crop recommendation system that integrates sensing, data processing, and automated control. The system utilizes sensors such as an NPK sensor, soil moisture sensor, water level sensor, and DHT11 temperature and humidity sensor to collect real-time field data. An ESP32-WROOM microcontroller processes the data and transmits it to a cloud platform for storage and analysis. Based on the collected parameters, a Machine Learning model recommends suitable crops by evaluating soil nutrients and environmental conditions, following approaches similar to those discussed in Random Forests.

In addition, an automated irrigation mechanism is implemented using relay modules, which activates when soil moisture levels fall below a predefined threshold, improving water efficiency as explored in IoT based Smart Agriculture. The system also provides a simple interface for remote monitoring. Overall, the proposed approach offers a cost-effective and practical solution for improving crop productivity and reducing resource wastage.

Keywords: Crop Recommendation System, Internet of Things (IoT), Machine Learning, NPK Sensor, Precision Farming, Soil Nutrient Monitoring, Smart Agriculture.

  1. INTRODUCTION

    Agriculture continues to play an important role in supporting livelihoods and economic stability, especially in regions where a large portion of the population depends on farming. Crop productivity mainly depends on soil fertility, environmental conditions, and proper crop selection. But in real situations, farmers often rely on traditional practices, occasional soil testing, and their own past experience. These methods can be useful, but they do not always provide timely or accurate information. Because of this, decisions related to crop selection and irrigation are sometimes based on assumptions, which can affect yield and lead to inefficient use of resources.

    With increasing pressure on food production and limited natural resources, there is a growing need for better and more reliable farming methods. Technologies such as IoT make it possible to collect real-time data from the field using sensors. These sensors can measure soil moisture, temperature, humidity, and nutrient levels, giving a clearer picture of field conditions at any given time. This reduces the dependency on manual observation and allows more informed decisions. However, many existing systems focus only on monitoring and do not provide direct support for crop selection.

    At the same time, Machine Learning techniques are being used to analyze agricultural data and generate useful predictions. By processing multiple parameters together, these models can suggest crops that are more suitable for specific soil and environmental conditions. In addition, water management remains a critical issue, as manual irrigation methods often result in overuse or uneven distribution of water.

    Considering these challenges, there is a need for a system that combines monitoring, analysis, and automation in a single setup. In this work, an IoT-based soil nutrient monitoring and crop recommendation system is developed using Machine Learning. The system collects real-time data, processes it, and provides crop suggestions while also controlling irrigation based on soil moisture levels, making the overall process more efficient and practical.

  2. LITERATURE REVIEW

    In recent years, the use of smart technologies in agriculture has gained attention to improve productivity and reduce dependency on traditional farming practices. Researchers have explored the integration of IoT, data analytics, and machine learning techniques to support better decision-making in agriculture. According to Wolfert et al. (2017), the use of big data and smart farming technologies allows continuous monitoring of agricultural conditions, which helps farmers take timely and informed decisions.

    Several studies have focused on IoT-based monitoring systems that use sensors to collect real-time data such as soil moisture, temperature, and humidity. Gondchawar and Kawitkar (2016) proposed a smart agriculture system using IoT that enables remote monitoring of field conditions. These systems improve efficiency but are mainly limited to monitoring and do not provide direct crop recommendations.

    Soil nutrient analysis is another critical area of research. Traditional soil testing methods are accurate but time-consuming and not suitable for frequent use. To address this issue, sensor-based approaches have been introduced for detecting soil nutrients like Nitrogen, Phosphorus, and Potassium. However, many existing systems lack integration with intelligent decision-making models, which limits their practical usability in real farming scenarios (Gondchawar and Kawitkar, 2016).

    Machine Learning techniques have been widely applied for crop prediction and recommendation. Algorithms such as Decision Trees, K-Nearest Neighbors, and Random Forest are commonly used for classification tasks. Breiman (2001) introduced the Random Forest algorithm, which improves prediction accuracy by combining multiple decision trees. These models are effective in predicting suitable crops based on environmental and soil parameters, but many implementations rely on static datasets instead of real-time sensor data.

    Water management is also an important aspect of smart agriculture. Automated irrigation systems use soil moisture data to control water supply efficiently. Buyya et al. (2016) discussed IoT architectures that support automation and real-time decision-making in various domains, including agriculture. These systems help reduce water wastage but are often developed as standalone solutions without integration with crop recommendation or soil analysis modules.

    From the overall analysis, it is clear that most existing systems focus on individual functionalities such as monitoring, prediction, or irrigation. Very few systems combine all these features into a single platform. Some approaches also require manual input or involve higher implementation costs. Therefore, there is a need for an integrated system that combines real-time soil monitoring, machine learning-based crop recommendation, and automated irrigation to provide a more practical and efficient solution for modern agriculture.

  3. PROPOSED SYSTEM

    The proposed system is designed to make farming a bit more data-driven, but without making it too complicated for actual use in the field. It combines IoT sensors, a microcontroller, and a machine learning model to monitor soil conditions nd suggest suitable crops based on real-time data. The idea is simple, collect the right data at the right time and use it in a useful way.

    In this setup, different sensors are placed in the soil and surrounding environment. An NPK sensor is used to measure key nutrients like nitrogen, phosphorus, and potassium, which are directly linked to soil fertility. Along with that, a soil moisture sensor checks the water content in the soil, while the DHT11 sensor records temperature and humidity. A SEN18 water level sensor is also included to keep track of water availability. All these sensors continuously gather data, though sometimes readings may slightly vary due to environmental noise, which is normal in real conditions.

    Figure 1: proposed diagram IoT system for soil nutrients monitoring and crop recommendation using machine learning

    The ESP32-WROOM microcontroller acts as the central unit. It collects data from all sensors and sends it to a cloud platform using Wi-Fi. This allows the data to be stored and accessed remotely. Farmers or users can view the readings through a simple dashboard, without needing technical knowledge. The system does not depend on manual data entry most of the time, which reduces human error.

    For crop recommendation, a machine learning model is used. It takes input parameters such as NPK values, soil moisture, temperature, and humidity, and then predicts the most suitable crop for those conditions. The model is trained on an agricultural dataset, so it can give reasonably accurate suggestions, though it may not always be perfect in extreme conditions.

    Another part of the system is irrigation control. A relay module is connected to a water pump, and based on soil moisture levels, the system can automatically turn irrigation on or off. This helps in saving water and avoids over-irrigation.

    Overall, the system connects monitoring, prediction, and control in one setup. It is not overly complex, but still manages to give useful outputs that can support better farming decisions in day-to-day use.

    Table 1: System Specification

    Parameters

    Details

    Controller

    ESP32

    Sensors

    NPK Sensor, SEN18, Soil Moisture Sensor, DHT11

    Communication

    Wi-Fi (HTTP / MQTT)

    Frontend

    HTML , CSS

    Backend

    FLASK

    AI Module

    Machine Learning (Random Forest)

  4. HARDWARE AND SOFTWARE SPECIFICATIONS

    1. Hardware Specification

      The hardware subsystem is built to support continuous soil monitoring, smooth data collection, and stable operation in field conditions. The components are selected in a way that they remain practical and not too difficult to handle during real deployment. It consists of the following components:

      • ESP32-WROOM Microcontroller: This acts as the central unit of the system. It collects data from all connected sensors, performs basic processing, and sends the information to the cloud using Wi-Fi. Since it has built-in connectivity, the setup stays simple without needing extra communication modules.

      • Sensors: Different sensors are used to capture both soil and environmental parameters. The NPK sensor measures essential nutrients such as nitrogen, phosphorus, and potassium, which are important for deciding crop suitability. A soil moisture sensor checks the water content in the soil, helping in irrigation decisions. The DHT11 sensor is used to record temperature and humidity. In addition, the SEN18 water level sensor monitors water availability, which becomes useful during irrigation control. Sensor readings can sometimes show small variations, especially in outdoor conditions, but overall they provide usable data.

      • Power Supply: A regulated 5V/3.3V DC power source is used to provide stable voltage to the ESP32 and sensors. An external 9V battery supply for NPK sensor. Stable power is important, otherwise readings may become inconsistent or the system may restart unexpectedly.

      • Communication Module: The ESP32 includes built-in Wi-Fi, which allows it to transmit sensor data directly to a cloud platform. This makes remote monitoring possible without additional hardware.

      • Connecting Wires: Jumper wires are used to connect all sensors with the microcontroller. Proper connections are necessary to avoid loose contacts, as even small disconnections can affect data flow.

        Table 2: Hardware Components

        Component

        Specification

        Function

        ESP32

        Dual-Core Wi-Fi MCU

        Control and data processing

        NPK sensor

        Soil Nutrient Sensor

        Measures Nitrogen, Phosphorus,

        Potassium

        Soil Moisture Sensor

        Analog/Digital Output Sensor

        Detects soil water content

        DHT11 Sensor

        Temperature & Humidity Sensor

        Temperature and Humidity

        detection

        SEN18 Water Level Sensor

        Water Level Detection Sensor

        Monitors water availability

        Power Supply

        5V / 3.3V DC

        System power

    2. Software Specifications

    The software part of the system manages data handling, user interaction, and communication between devices and the cloud. It is designed to stay simple but still handle real-time monitoring and prediction without much delay.

    • Programming Environment: The development work is carried out using Visual Studio Code. It is used for writing, testing, and debugging both the frontend and backend parts of the system.

    • Frontend: A basic web-based dashboard is developed to display sensor readings and crop recommendations. It allows users to check soil conditions, temperature, humidity, and system status in real time. The interface is kept simple so it can be used without much technical knowledge.

    • Backend: The backend is implemented using Python (Flask framework). It handles data processing, connects the machine learning model, and manages communication between the hardware system and the user interface.

    • Database: Sensor data is stored on a cloud-based platform (such as Firebase or ThingSpeak). This helps in maintaining real-time records and allows users to access past data when needed.

    • Machine Learning Module: A machine learning model is developed using Python libraries like NumPy, Pandas, and Scikit-learn. It takes inputs such as NPK values, soil moisture, temperature, and humidity to recommend suitable crops.

    • Communication Protocols: The ESP32 sends data to the cloud using Wi-Fi. Protocols like HTTP or MQTT are used for reliable data transfer, though small delays may occur depending on network conditions.

    • Programming Language: Embedded C/C++ is used in Arduino IDE for programming the ESP32. Python is used for backend logic and machine learning, while basic web technologies (HTML, CSS, JavaScript) are used for the dashboard.

    Table 3: Software Tools Used

    Tool

    Purpose

    Python

    Data processing and ML model

    Flask

    Backend development

    ThingSpeak

    Real-time data storage

    Aduino IDE

    ESP32 Programming

    HTML/CSS/JS

    Web dashboard interface

  5. SYSTEM IMPLEMENTATION

    The system is implemented by combining hardware setup, data transmission, and machine learning in a step-by-step manner so that everything works together without much complexity. The process starts with assembling the sensors and connecting them properly to the ESP32 microcontroller. Each sensor is interfaced using suitable pins, and basic calibration is done before actual use. In practice, getting stable readings takes a bit of trial and error, especially with the NPK and moisture sensors, as soil conditions can vary.

    Once the hardware setup is ready, the ESP32 is programmed using Arduino IDE. The code is written to read data from all sensors at regular intervals. These readings include soil nutrients, moisture level, temperature, humidity, and water level. After collecting the data, the ESP32 sends it to a cloud platform through Wi-Fi. Sometimes there can be small delays in transmission, but overall the data updates in near real time.

    On the server side, the received data is stored and processed. A backend system built using Python handles this part. It organizes incoming data and prepares it for further use. The machine learning model is then applied to this data. The model is trained earlier using an agricultural dataset, where it learns the relationship between soil parameters and suitable crops. During implementation, the model takes current sensor values as input and predicts the most suitable crop for those conditions.

    A simple dashboard is developed to display all this information. Users can view sensor readings, check soil status, and see crop recommendations. The interface is kept straightforward, so even someone without technical background can use it without much confusion.

    For irrigation control, a relay module is connected to a water pump. The system checks soil moisture levels continuously, and when the moisture drops below a certain threshold, the pump is turned on automatically. Once the required level is reached, it turns off. This part works well in most cases, though occasional manual checks are still useful.

    Overall, the implementation connects sensing, data transfer, prediction, and control in a single flow. It may not be perfect in every condition, but it provides a working system that supports better and more informed farming decisions.

    Figure 2 : Flowchart of proposed IoT system for soil nutrients monitoring and crop recommendation using machine learning

  6. RESULTS AND DISCUSSION

    The system was evaluated under varying field conditions to check its overall performance and reliability. Sensor readings such as NPK levels, soil moisture, temperature, and humidity were recorded over time and displayed on the dashboard. Data updates were generally quick, though minor lag was noticed at times due to network stability.

    Figure 3 : Real time soil nutrients monitoring dashboard displaying parameters values

    The soil moisture sensor responded well to changes in water content. When the value dropped below the defined limit, the relay module triggered the pump, supplying water to the soil. Once the desired level was reached, the pump stopped automatically. This setup helped control excess watering and made irrigation more efficient. In a few instances, rapid fluctuations in readings caused frequent switching, which suggests that careful calibration and threshold selection are necessary.

    The crop recommendation model was tested using multiple input combinations. Based on the given parameters, the system suggested crops that were mostly aligned with expected outcomes. The results were consistent for common conditions, but accuracy may reduce when inputs fall outside the trained dataset range. This shows that model performance still depends on the quality and coverage of training data.

    Figure 3: Machine learning model recommending crop on dashboard

    Temperature and humidity values recorded by the DHT11 sensor were stable enough for general observation, even if not highly precise. Nutrient readings from the NPK sensor provided a basic understanding of soil condition, though occasional variation was observed, which is common with low-cost sensing devices.

    Overall, the system demonstrates a working combination of monitoring, prediction, and control. It reduces manual involvement and supports better decisions in farming practices. At the same time, some challenges remain, including reliance on internet connectivity, minor sensor inconsistencies, and the need for periodic checks. With improved sensors and a more refined dataset, the system can deliver more consistent and dependable results in practical use.

  7. SYSTEM EVALUATION

    1. Advantages

      • Continuous Soil Monitoring : The system keeps track of soil nutrients, moisture, temperature, and humidity on a regular basis, so field conditions are always known without repeated manual checks.

      • Data-Driven Crop Suggestions : It uses a trained model to recommend crops based on current soil and environmental conditions, which helps in better planning before planting.

      • Efficient Water Usage : Irrigation is controlled automatically using moisture levels, which helps avoid both overwatering and dry soil conditions.

      • Cost-Effective Setup : The components used are affordable and easily available, making the system suitable for small and medium-scale farming.

      • Remote Monitoring : With Wi-Fi connectivity, data can be accessed from anywhere, reducing the need to stay physically present in the field.

      • Easy to Use Interface : The dashboard presents information in a simple way, so users can understand the system without technical expertise.

      • Less Manual Work : Regular soil checking and decision-making become easier, saving time and effort.

    2. Limitations of the System

      • Internet Requirement : The system depends on network availability for data transfer and remote access, which can be a challenge in some locations.

      • Sensor Limitations : Low-cost sensors may produce slight variations in readings and may require recalibration after some time.

      • Impact of Surroundings : External factors like temperature changes or soil type can affect sensor performance to some extent.

      • Power Dependency : Continuous operation requires stable power; interruptions can temporarily stop monitoring.

      • Model Constraints : Prediction accuracy depends on the dataset used during training. Limited data can reduce reliability in some cases.

      • System Expansion Issues : Adding more features or sensors may need changes in hardware setup and coding.

    3. Applications

      • Field Crop Management : Helps farmers understand soil condition and select crops that are more likely to grow well.

      • Precision Farming Practices : Supports controlled use of water and nutrients, improving efficiency in farming operations.

      • Greenhouse Control Systems : Can be used to maintain suitable growing conditions in controlled environments.

      • Research and Testing : Useful for analyzing soil behavior and testing crop suitability under different conditions.

      • Support for Rural Areas : Provides basic monitoring where advanced soil testing facilities are not easily accessibe.

      • Educational Projects : Can be used as a learning model for students working on IoT and agriculture-related projects.

    4. Future Scope

      • Better Visualization Tools : The interface can include graphs, alerts, and more detailed insights for easier understanding.

      • Improved Prediction Models : Using more advanced algorithms and larger datasets can increase accuracy.

      • Integration of Extra Sensors : Adding pH, rainfall, or sunlight sensors can improve decision-making.

      • Wider Deployment : Multiple units can be installed across larger farming areas for better coverage.

      • Extended Automation : The system can be expanded to control fertilization or other farming processes.

      • Data-Based Insights : Stored data can be used to study long-term soil patterns and improve planning.

      • Offline Capability : Future versions can store data locally during network issues and update it later.

  8. CONCLUSION

The proposed system presents a practical approach to improving farming decisions using real-time soil monitoring and machine learning. By combining sensors, cloud connectivity, and automated irrigation, it provides useful insights into soil conditions and crop suitability. The setup reduces manual effort and supports better use of water and resources. Although some limitations exist, such as sensor accuracy and internet dependency, the system still performs reliably under normal conditions. With further improvements in data quality and hardware, it can become a more dependable solution for efficient and sustainable agriculture.

REFERENCES :

  1. S. Wolfert, L. Ge, C. Verdouw, and M. J. Bogaardt, Big Data in Smart Farming A Review, Agricultural Systems, 2017.

  2. N. Gondchawar and R. S. Kawitkar, IoT Based Smart Agriculture, International Journal of Advanced Research in Computer and Communication Engineering, 2016.

  3. L. Breiman, Random Forests, Machine Learning Journal, 2001.

  4. R. Buyya et al., Internet of Things (IoT): A Vision, Architectural Elements, and Future Directions, Future Generation Computer Systems, 2016.

  5. P. Mehta and M. Shah, Plant and Soil Nutrient Monitoring in Precision Agriculture: A Review of IoT and Machine Learning, International Journal of Science, Engineering and Technology, 2025.

  6. M. Bouni, B. Hssina, K. Douzi, and S. Douzi, Integrated IoT Approaches for Crop Recommendation and Yield Prediction Using Machine Learning, IoT Journal, vol. 5, no. 4, pp. 634649, 2024.

  7. B. V. A., S. Thomas, M. G., and S. K. S., Precision Crop Prediction Using IoT-Enabled Soil Sensors and Machine Learning, ITEGAM Journal of Engineering and Technology for Industrial Applications, 2024.

  8. K. Anusha et al., Crop Recommendation Using IoT and Machine Learning, International Journal of Engineering Research & Technology (IJERT), 2023.

  9. M. Sunandini et al., Smart Soil Fertilizer Monitoring and Crop Recommendation System by Using IoT and Machine Learning Technology, IJERT, 2023.

  10. S. Kumar et al., Agrosmart Precision Soil Analysis Bot for Nutrient Prediction and Fertilizer Recommendations, International Journal of Scientific Research in Computer Science, 2024.

  11. R. R. Sondhiya and V. K. Singh, Intelligent Agriculture: Integrating IoT and Machine Learning for Soil Nutrients and Crop Selection, ShodhKosh Journal, 2024.

  12. J. Wolfert, L. Ge, C. Verdouw, and M. J. Bogaardt, Big Data in Smart Farming A Review, Agricultural Systems, vol. 153, pp. 6980, 2021.

  13. A. Kamilaris and F. X. Prenafeta-Boldú, Deep Learning in Agriculture: A Survey, Computers and Electronics in Agriculture, vol. 195, pp. 106124, 2022.

  14. S. Navulur, A. Sastry, and M. N. Giri Prasad, Agricultural Management through Wireless Sensors and Internet of Things, International Journal of Electrical and Computer Engineering, vol. 11, no. 4, pp. 34923499, 2021.

  15. M. K. Senapaty, A. Ray, and N. Padhy, IoT-Enabled Soil Nutrient Analysis and Crop Recommendation Model for Precision Agriculture, Computers, vol. 12, no. 3, pp. 117, 2023.

  16. K. Anusha, D. J. Anusha, K. R. Sunidhi, and K. K. M. Kiran, Crop Recommendation Using IoT and Machine Learning, International Journal of Engineering Research & Technology (IJERT), vol. 11, no. 5, pp. 15, 2023.

  17. M. Sunandini, K. Hema Sree, R. Deepiga, and A. Gokulapriya, Smart Soil Fertilizer Monitoring and Crop Recommendation System Using IoT and Machine Learning Technology, International Journal of Engineering Research & Technology (IJERT), vol. 12, no. 3, pp. 16, 2023.

  18. B. V. A., S. Thomas, and M. G. Ramesh, Precision Crop Prediction Using IoT-Enabled Soil Sensors and Machine Learning, ITEGAM Journal of Engineering and Technology for Industrial Applications, vol. 10, no. 2, pp. 8996, 2024.

  19. R. R. Sondhiya and V. K. Singh, Intelligent Agriculture: Integrating IoT and Machine Learning for Soil Nutrients and Crop Selection, ShodhKosh Journal, vol. 5, no. 1, pp. 210218, 2024.