BEST FINAL YEAR PROJECTS ideas

IoT-Based Crop Recommendation System using ESP8266, DHT, Soil Moisture, Rainfall, and PIR Sensors

IoT-Based Crop Recommendation System

Abstract

Crop recommendation system based smart agriculture plays a crucial role in strengthening developing economies like India, where a large portion of the population depends on farming for livelihood. Despite its importance, agricultural productivity is frequently affected by unpredictable weather conditions, improper irrigation practices, poor crop selection, and the lack of real-time field monitoring.

Traditionally, farmers rely on experience, intuition, or generalized government advisories when choosing crops. While useful to some extent, these approaches often ignore localized factors such as soil moisture, temperature, humidity, and rainfall, which directly influence crop yield. Consequently, farmers may experience reduced productivity, soil degradation, and financial losses. To address these challenges, modern technologies have enabled the development of an intelligent crop recommendation system that supports data-driven decision-making in agriculture.

This project presents an IoT-enabled crop recommendation system that integrates real-time environmental sensing with an intelligent decision-making framework to recommend suitable crops. The system utilizes an ESP8266 microcontroller as the core processing and communication unit, interfaced with multiple sensors including a DHT11 sensor for temperature and humidity measurement, a soil moisture sensor for estimating soil water content, a rainfall sensor for detecting precipitation, and a PIR sensor for monitoring motion associated with animal or human intrusion. Sensor data collected by the ESP8266 is preprocessed and transmitted wirelessly to a Flask-based backend server or IoT cloud platform, where the crop recommendation system analyzes the data for crop suitability.

The backend of the crop recommendation system applies rule-based logic or machine learning techniques to evaluate environmental conditions and generate appropriate crop recommendations. Soil moisture values, represented as percentage water content and combined with rainfall data, help determine whether the land is suitable for water-intensive crops such as rice or for low-water crops like millets. Temperature and humidity measurements further assist the crop recommendation system in identifying seasonal crop suitability, ensuring that recommendations are accurate and localized rather than generic.

In addition to crop selection, the proposed crop recommendation system provides advisory features to assist farmers during cultivation. Low soil moisture levels trigger irrigation alerts, while excessive moisture generates drainage recommendations. The PIR sensor adds a security dimension to the crop recommendation system by detecting animal or unauthorized human intrusion, helping farmers protect crops from damage. This integrated approach offers a holistic solution that combines crop advisory, field monitoring, and security.

The system is designed to be scalable, affordable, and accessible. The ESP8266 microcontroller is chosen for its low cost, built-in Wi-Fi capability, and compatibility with the Arduino IDE, making the crop recommendation system suitable for small-scale and resource-constrained farmers. The backend, developed using Python and Flask, is lightweight and can be deployed on cloud platforms, local servers, or low-cost devices such as Raspberry Pi.

Experimental results demonstrate that the crop recommendation system effectively monitors real-time environmental parameters and provides reliable, context-aware crop recommendations. The system performs well across varying soil and climatic conditions, while intrusion alerts enhance field safety. Overall, the proposed IoT-based crop recommendation system contributes to sustainable and precision agriculture by optimizing resource usage, improving crop yield, and supporting informed decision-making, paving the way toward smart and digitally empowered farming practices.

Introduction

Background

Crop recommendation system driven agriculture forms the foundation of modern efforts to improve farming efficiency and sustainability. Agriculture has long been the cornerstone of human civilization, providing food, raw materials, and livelihoods to billions of people worldwide. In many developing countries, including India, agriculture is not merely an economic activity but a way of life that supports a large section of the population.

Despite its critical role, agriculture continues to face serious challenges arising from unpredictable weather patterns, climate change, limited resources, and heavy dependence on traditional farming practices. Farmers often make vital decisions related to crop selection, irrigation, and pest control based on intuition, inherited knowledge, or generalized government advisories, which frequently fail to capture localized environmental variations affecting crop productivity.

In recent years, technology-driven solutions have emerged as powerful enablers for transforming agriculture into a more scientific, efficient, and sustainable domain. The adoption of Information and Communication Technology (ICT), Internet of Things (IoT), and Artificial Intelligence (AI) has accelerated the shift toward smart farming and precision agriculture. These approaches emphasize data-driven decision-making, where real-time field data collected through sensors and microcontrollers is analyzed to guide farmers toward optimized agricultural practices. Within this context, an intelligent crop recommendation system plays a crucial role by translating raw environmental data into meaningful cultivation guidance.

One of the most critical decisions in farming is the selection of an appropriate crop for a given season. This decision depends heavily on environmental parameters such as temperature, humidity, soil moisture, and rainfall. Poor crop selection can result in reduced yields, economic losses, and long-term soil degradation. An IoT-enabled crop recommendation system that considers real-time environmental conditions can significantly reduce these risks by recommending crops best suited to local field conditions, thereby improving productivity and sustainability.

The availability of affordable microcontrollers such as the ESP8266, along with low-cost sensors like DHT11/DHT22 for temperature and humidity, soil moisture sensors, and rainfall sensors, has made it feasible to deploy low-cost IoT-based solutions even for small and marginal farmers. The inclusion of a PIR sensor further enhances the crop recommendation system by enabling intrusion detection, helping protect crops from animals or unauthorized access. This integration ensures that the system not only assists in crop selection but also supports field monitoring and farm security.

The proposed IoT-based crop recommendation system represents a holistic approach to modern agriculture by combining real-time sensing, wireless communication, and intelligent data analysis. By bridging the gap between environmental data and actionable insights, the system empowers farmers to make informed decisions, optimize resource utilization, and enhance overall farm productivity and profitability. Through its focus on precision and sustainability, this crop recommendation system contributes meaningfully to the evolution of smart and resilient agricultural practices.

Problem Statement

Crop recommendation system limitations continue to pose serious challenges to modern agriculture, despite advances in agricultural research and the availability of improved farming techniques. Farmers in many regions still experience reduced crop productivity and increased risk to food security due to the absence of localized, real-time decision-support solutions. Traditional agricultural advisories often provide generalized recommendations over large geographic areas, failing to account for microclimatic variations within individual farms. This disconnect frequently results in the selection of crops that are poorly suited to specific field conditions.

Several critical problems motivating the need for an intelligent crop recommendation system are outlined below:

  1. Inappropriate Crop Selection:
    Farmers commonly choose crops based on tradition, prior experience, or generalized advisories. Without a localized crop recommendation system, such decisions may not align with current soil moisture, rainfall, or temperature conditions, leading to reduced yields and financial losses.
  2. Inefficient Resource Utilization:
    The absence of real-time monitoring prevents optimal water management. Without support from a data-driven crop recommendation system, farmers may over-irrigate or under-irrigate, causing water wastage, soil waterlogging, or moisture stress in crops.
  3. Dependence on Unpredictable Weather:
    Climate change and erratic rainfall patterns have made agriculture increasingly uncertain. Farmers who rely solely on forecasts or intuition, rather than a real-time crop recommendation system, often face unexpected losses when weather conditions change abruptly.
  4. Limited Access to Technology:
    Many small and marginal farmers lack access to advanced and costly agricultural technologies. This limits the adoption of intelligent crop recommendation system solutions and forces continued dependence on traditional practices that may not be effective under current climatic conditions.
  5. Crop Protection Challenges:
    Crop damage caused by animals or unauthorized human intrusion is a significant issue in rural areas. In the absence of integrated monitoring within a crop recommendation system, farmers frequently become aware of such damage only after substantial losses have occurred.
  6. Fragmented Solutions:
    Existing technologies often address individual aspects such as soil moisture sensing or weather monitoring in isolation. Very few solutions integrate multiple parameters into a unified crop recommendation system that delivers direct, actionable crop guidance. Many available systems remain experimental or are financially inaccessible to small-scale farmers.

Considering these challenges, there is a pressing need for a low-cost, real-time, and user-friendly crop recommendation system that not only collects environmental data but also converts it into practical and reliable crop suggestions. The system must be scalable, easy to deploy, and capable of operating on affordable hardware suitable for rural environments.

The problem can therefore be summarized as follows:

How can a cost-effective IoT-based crop recommendation system be designed and implemented using real-time environmental data—such as temperature, humidity, soil moisture, rainfall, and field intrusion—to recommend suitable crops and support farmers in making informed agricultural decisions?

Objectives

Crop recommendation system development is the central focus of this project, aiming to leverage IoT technology and real-time data for intelligent agricultural decision-making. The primary goal is to design and implement an IoT-based crop recommendation system that utilizes real-time sensor data to suggest suitable crops while also supporting effective farm monitoring and protection. To achieve this overall goal, the following specific objectives are defined:

  1. Crop recommendation system hardware design using an ESP8266 microcontroller integrated with DHT sensors, soil moisture sensors, rainfall sensors, and a PIR sensor for real-time agricultural data collection.
  2. To preprocess, calibrate, and normalize sensor data within the crop recommendation system, enabling accurate interpretation of parameters such as converting raw soil moisture readings into percentage values.
  3. To develop a backend framework for the crop recommendation system using Python and Flask that receives sensor data, stores it efficiently, and applies rule-based logic or machine learning models to generate crop recommendations.
  4. To establish a reliable wireless communication mechanism in the crop recommendation system, where the ESP8266 transmits sensor readings to the backend server via Wi-Fi.
  5. To implement a rule-based decision engine within the crop recommendation system (with future extensibility to machine learning) that recommends crops based on soil moisture, rainfall availability, temperature, and humidity conditions.
  6. To integrate an alert and monitoring module into the crop recommendation system using a PIR sensor, enhancing crop protection by detecting animal or unauthorized human intrusion.
  7. To design a simple, intuitive, and accessible user interface or web dashboard for the crop recommendation system, enabling farmers to view real-time sensor data, crop recommendations, and alerts.
  8. To experimentally validate the crop recommendation system under diverse environmental conditions and evaluate the accuracy, reliability, and relevance of its recommendations.
  9. To ensure the crop recommendation system is affordable, scalable, and suitable for small and marginal farmers, while remaining extensible to larger agricultural deployments.
  10. To promote sustainable agricultural practices through the crop recommendation system by optimizing water usage, improving crop selection, enhancing productivity, and reducing the risk of crop failure.

By achieving these objectives, the proposed crop recommendation system aims to deliver a comprehensive, end-to-end solution that extends beyond basic sensing, providing actionable crop recommendations, real-time monitoring, and security features tailored to real-world agricultural challenges.

Scope of the Project

Crop recommendation system implementation defines the boundaries, applications, and future potential of the proposed IoT-based solution. While the project aims to introduce intelligent decision-making into agriculture, it is carefully structured to remain practical, affordable, and feasible for real-world farming environments.

  1. Technological Scope:
    • The crop recommendation system is built around the ESP8266 microcontroller, selected for its low cost, low power consumption, and integrated Wi-Fi capability.
    • The system incorporates sensors such as the DHT11 for temperature and humidity measurement, a soil moisture sensor for estimating soil water content, a rainfall sensor for precipitation detection, and a PIR sensor for intrusion monitoring.
    • The software stack supporting the crop recommendation system includes Arduino IDE for firmware development, Python and Flask for backend processing, and optional cloud platform integration to enable scalability and remote access.
  2. Functional Scope:
    • Real-time collection of environmental parameters required by the crop recommendation system.
    • Preprocessing, calibration, and normalization of raw sensor data for accurate interpretation.
    • Implementation of crop recommendation logic based on predefined environmental rules and thresholds.
    • Generation of alerts for critical conditions such as low soil moisture levels or intrusion detection through the PIR sensor.
    • A basic and user-friendly mobile or web interface that allows farmers to view sensor readings, crop recommendations, and alerts generated by the crop recommendation system.
  3. Geographical Scope:
    • Initially, the crop recommendation system can be tested in controlled environments such as agricultural research fields, pilot farms, or small-scale cultivation plots.
    • With appropriate calibration and parameter tuning, the system can be adapted and deployed across different geographical regions with varying climatic conditions and crop requirements.
  4. Limitations:
    • The current version of the crop recommendation system relies primarily on rule-based decision logic; advanced machine learning and predictive analytics are identified as future enhancements.
    • Soil fertility parameters such as pH, nitrogen, phosphorus, and potassium are not included in the present scope due to hardware constraints, though they can be integrated in future extensions of the crop recommendation system.
    • Alternative power solutions such as solar energy and long-term battery operation are considered extensions rather than core components of the current implementation.
  5. Expected Impact:
    • Enable farmers to make informed, data-driven decisions using insights generated by the crop recommendation system.
    • Reduce water wastage by supporting irrigation decisions based on real-time soil moisture and rainfall data.
    • Enhance crop protection and field security through PIR-based intrusion monitoring integrated into the crop recommendation system.
    • Establish a foundation for future smart farming solutions that integrate predictive analytics, drone-based monitoring, and weather forecast services.

In summary, the scope of this project is to deliver a low-cost, real-time crop recommendation system combined with farm monitoring capabilities using IoT technologies. The design emphasizes accessibility and practicality for small and medium-scale farmers, while remaining flexible for future technological enhancements aimed at improving agricultural productivity and sustainability.

Existing Crop Recommendation and Smart Farming Systems

Crop recommendation system technologies have become a key component of modern smart farming practices, significantly influencing agricultural productivity and sustainability. Agriculture remains one of the most critical sectors shaping the global economy, livelihoods, and food security. With rapid technological advancements, traditional farming methods are increasingly being replaced by smart farming approaches that emphasize data-driven decision-making to minimize risks, optimize resources, and improve crop yield. Within this transformation, the crop recommendation system has emerged as a vital application that supports informed crop selection.

Existing crop recommendation system solutions commonly integrate sensors, Internet of Things (IoT) devices, machine learning algorithms, and cloud computing platforms to analyze soil properties, climatic conditions, and environmental parameters. By processing this data, a crop recommendation system suggests crops that are best suited to prevailing field conditions, helping farmers make scientifically informed decisions. These systems play a crucial role in reducing uncertainty in farming, improving sustainability, and enhancing overall agricultural efficiency within the smart farming ecosystem.

Proposed System Architecture

Crop recommendation system architecture plays a crucial role in determining the efficiency, reliability, and scalability of an IoT-based agricultural solution. The success of such systems depends on a well-structured design that clearly defines how hardware and software components interact, how environmental data is collected and processed, and how actionable insights are delivered to end users. In this project, the proposed crop recommendation system leverages real-time environmental sensing combined with data-driven decision-making to identify and suggest the most suitable crops for specific field conditions.

The architecture of the crop recommendation system is designed to ensure seamless integration between sensing units, processing modules, communication layers, and user interfaces. Sensor data collected from the field is transmitted to the processing unit, where it is analyzed and transformed into meaningful information. This processed data is then used by the crop recommendation system to generate crop suggestions based on predefined rules or intelligent algorithms.

This section presents a detailed overview of the proposed system architecture, including the hardware components, software framework, and the overall data flow model. By clearly defining the interaction between each module, the crop recommendation system ensures accurate data acquisition, reliable communication, efficient processing, and timely delivery of recommendations to farmers, enabling informed and effective agricultural decision-making.

System Design Overview

Crop recommendation system design is centered on integrating sensing, processing, communication, and application components into a unified and efficient architecture. The proposed system combines multiple sensors, a microcontroller, and a software ecosystem to deliver accurate and real-time crop recommendations. The overall crop recommendation system architecture is organized into four distinct layers, each responsible for a specific function.

  1. Sensing Layer (Data Acquisition):
    • This layer forms the foundation of the crop recommendation system and consists of physical sensors deployed in the agricultural field.
    • Sensors such as the DHT (temperature and humidity sensor), soil moisture sensor, rainfall sensor, and PIR sensor are used to capture essential environmental parameters.
    • These sensors act as the primary data sources, continuously collecting information that directly influences crop growth and selection within the crop recommendation system.
  2. Processing Layer (Edge Computing):
    • The ESP8266 microcontroller serves as the edge processing unit of the crop recommendation system.
    • It acquires raw data from the sensors, performs initial preprocessing tasks such as noise filtering, calibration, and averaging, and then prepares the data for transmission.
    • Basic computations, including threshold checks for soil moisture levels or rainfall detection, are executed at this layer to reduce latency and minimize the processing load on higher layers of the crop recommendation system.
  3. Network and Communication Layer:
    • This layer enables seamless data transfer between the ESP8266 and the backend infrastructure of the crop recommendation system.
    • Sensor data is transmitted over Wi-Fi to cloud platforms such as ThingSpeak, Firebase, or AWS IoT, or to a locally hosted Flask server.
    • Communication is handled using standard IoT protocols such as MQTT or HTTP REST APIs, ensuring reliability and interoperability within the crop recommendation system.
  4. Application Layer (Decision-Making and User Interaction):
    • At this layer, the crop recommendation system applies Python-based rule engines or machine learning algorithms to analyze incoming sensor data and determine the most suitable crops.
    • A Flask-based web application serves as the user interface, allowing farmers to view real-time sensor readings, receive crop recommendations, and obtain alerts related to environmental conditions or intrusion detection.
    • Web or mobile dashboards ensure that the crop recommendation system remains accessible to farmers, including those in remote or resource-constrained regions.

This layered architecture provides modularity, scalability, and fault tolerance to the crop recommendation system. Each layer can be enhanced or upgraded independently without affecting the overall operation. For instance, advanced sensors or improved recommendation algorithms can be integrated seamlessly, ensuring long-term adaptability and robustness of the system.

Hardware Components

Crop recommendation system hardware forms the backbone of the proposed solution, enabling real-world environmental sensing and reliable data transmission. The selected components are chosen for their affordability, availability, and suitability for agricultural environments. The detailed description of each hardware component used in the crop recommendation system is given below.

1. ESP8266 Microcontroller

Role: Acts as the central processing unit and communication hub of the crop recommendation system.

Features:

  • Built-in Wi-Fi module for wireless data transmission
  • Low power consumption, making it suitable for rural and remote deployments
  • Cost-effective and easily programmable using the Arduino IDE

Function in the Crop Recommendation System:

  • Collects data from all connected sensors
  • Performs basic preprocessing such as averaging and normalization
  • Transmits processed sensor data to the cloud or a local Flask server

2. DHT Sensor (Temperature and Humidity Sensor)

Role: Measures ambient temperature and humidity levels.

Importance in Agriculture:

  • Temperature and humidity significantly influence crop germination, growth cycles, and yield
  • Helps the crop recommendation system identify crops suitable for specific microclimatic conditions

Function in the Crop Recommendation System:

  • Provides input for recommending heat-tolerant or cold-tolerant crops
  • Assists in identifying disease-prone conditions, such as fungal growth caused by high humidity

3. Soil Moisture Sensor

Role: Monitors the water content present in the soil.

Importance in Agriculture:

  • Soil moisture is one of the most critical parameters used by a crop recommendation system
  • Different crops require different irrigation and moisture levels

Function in the Crop Recommendation System:

  • Determines suitability for water-intensive crops (e.g., rice) or drought-resistant crops (e.g., millets)
  • Generates alerts for irrigation scheduling and water management

4. Rainfall Sensor

Role: Detects and measures rainfall in the agricultural field.

Importance in Agriculture:

  • Rainfall is a major water source in rainfed farming regions
  • Plays a key role in seasonal crop planning

Function in the Crop Recommendation System:

  • Works in conjunction with soil moisture data to improve irrigation decisions
  • Influences seasonal crop recommendations, such as promoting paddy cultivation during high rainfall periods

5. PIR Sensor (Passive Infrared Sensor)

Role: Detects motion caused by animals or humans in the field.

Importance in Agriculture:

  • Helps protect crops from animal intrusion and unauthorized access
  • Reduces crop losses due to stray animals

Function in the Crop Recommendation System:

  • Triggers alerts when intrusion is detected
  • Can be extended to activate deterrent mechanisms such as alarms or lights

Summary of Hardware Benefits

By integrating the ESP8266 with multiple environmental sensors, the crop recommendation system gains a comprehensive understanding of soil, atmospheric, and field conditions. This holistic sensing capability enables accurate crop recommendations while also ensuring crop health, efficient resource usage, and improved field security.

Software Components

Crop recommendation system software components enable data acquisition, processing, intelligent analysis, and user interaction. The software stack consists of development tools, programming environments, frameworks, and optional IoT platforms.

1. Arduino IDE

Purpose: Programming and configuring the ESP8266.

Features:

  • Supports embedded C and Arduino libraries for sensor interfacing
  • Provides serial monitoring and debugging tools

Role in the Crop Recommendation System:

  • Uploads firmware to the ESP8266
  • Manages communication between the microcontroller and sensors

2. Python Programming Environment

Purpose: Backend logic, data analysis, and crop recommendation algorithms.

Libraries Used:

  • Pandas & NumPy: Data handling and preprocessing
  • Scikit-learn: Machine learning models for crop recommendation
  • Matplotlib / Seaborn: Visualization of environmental trends

Role in the Crop Recommendation System:

  • Analyzes real-time sensor data
  • Matches environmental conditions with crop requirements stored in datasets

3. Flask Framework

Purpose: Lightweight web framework for building the farmer dashboard.

Features:

  • Supports RESTful API development
  • Renders dynamic web pages for visualization

Role in the Crop Recommendation System:

  • Displays real-time sensor data and crop recommendations
  • Generates alerts through web notifications or SMS integration

4. IoT Platforms (Optional / Future Integration)

Platforms: ThingSpeak, Firebase, Blynk, AWS IoT

Features:

  • Cloud storage and visualization dashboards
  • Remote access to agricultural data

Role in the Crop Recommendation System:

  • Enhances scalability by storing long-term datasets
  • Enables mobile access and remote monitoring

Overall, the integration of robust hardware with a flexible software stack ensures that the crop recommendation system delivers reliable, scalable, and intelligent support for modern, data-driven agriculture.

System Architecture / Block Diagram

Crop Recommendation System architecture diagram

Conclusion

Crop recommendation system based on IoT and smart sensing technologies demonstrates a practical and effective approach to modernizing agriculture through data-driven decision-making. The proposed IoT-based crop recommendation system and farm monitoring solution successfully integrates environmental sensing, real-time data processing, machine learning techniques, and cloud communication to support farmers in making informed agricultural decisions. By modularizing the system into sensor acquisition, data preprocessing, crop recommendation, intrusion detection, server communication, and user interface components, the crop recommendation system ensures scalability, reliability, and ease of maintenance.

The system efficiently captures critical environmental parameters such as temperature, humidity, soil moisture, rainfall, and field intrusion, enabling continuous monitoring of farm conditions. Preprocessing methods including filtering, normalization, and calibration improve data accuracy, which directly enhances the reliability of recommendations generated by the crop recommendation system using rule-based logic or machine learning models. In addition, the PIR-based intrusion detection module strengthens farm security by promptly identifying potential threats and reducing crop losses.

Seamless communication between the ESP8266 microcontroller, Flask-based server APIs, and cloud databases allows the crop recommendation system to deliver real-time insights to farmers through a user-friendly web dashboard. Visualization tools such as graphs and alerts, along with support for localized and multilingual interfaces, make the system practical and accessible for farmers operating in diverse rural environments.

Overall, the proposed crop recommendation system illustrates how IoT and machine learning technologies can transform traditional agriculture by reducing guesswork, optimizing resource utilization, improving crop yield, and enhancing farm safety. With future enhancements such as predictive analytics, advanced intrusion classification, and mobile application integration, the crop recommendation system can evolve into a comprehensive smart farming ecosystem suitable for large-scale and sustainable agricultural deployment.

To Get The Complete Project

Leave a Comment

Your email address will not be published. Required fields are marked *

Chat with us
Scroll to Top