0% found this document useful (0 votes)
12 views55 pages

Final - Report Final

The document presents a project report on an Intelligent Irrigation and Crop Advisory System that utilizes IoT and AI/ML technologies to enhance agricultural practices. It details the development of a mobile application that helps farmers manage irrigation, monitor soil conditions, and receive crop recommendations based on real-time data. The system aims to optimize water usage, improve crop yield, and support sustainable agriculture through data-driven insights.

Uploaded by

tpgitspotify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views55 pages

Final - Report Final

The document presents a project report on an Intelligent Irrigation and Crop Advisory System that utilizes IoT and AI/ML technologies to enhance agricultural practices. It details the development of a mobile application that helps farmers manage irrigation, monitor soil conditions, and receive crop recommendations based on real-time data. The system aims to optimize water usage, improve crop yield, and support sustainable agriculture through data-driven insights.

Uploaded by

tpgitspotify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

INTELLIGENT IRRIGATION AND CROP ADVISORY

SYSTEM USING IOT AND AIML

A PROJECT REPORT

Submitted by

MOHAN J 513121106303
NARESH P 513121106304
GOKUL R 513121106701

in partial fulfilment for the award of the degree

of

BACHELOR OF ENGINEERING
in
ELECTRONICS AND COMMUNICATION ENGINEERING

THANTHAI PERIYAR GOVERNMENT INSTITUTE OF


TECHNOLOGY,

VELLORE - 632 002.

ANNA UNIVERSITY: CHENNAI 600 025

MAY 2025
ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report “INTELLIGENT IRRIGATION AND

CROP ADVISORY SYSTEM USING IOT AND AIML” is the bonafide

work of MOHAN J (513121106303), NARESH P (513121106304) and

GOKUL R (513121106701) who carried out the project work under our

supervision.

SIGNATURE SIGNATURE SIGNATURE


Dr.S. LETITIA, M.E., Ph.D., Dr. S. SATHISHBABU, M.E., Ph.D., Mrs.S.KRITHIGA, M.E.,

HEAD OF THE DEPARTMENT, PROJECT CO-ORDINATOR, SUPERVISOR,

PROFESSOR, ASSOCIATE PROFESSOR, ASSISTANT PROFESSOR

Department of Electronics and Department of Electronics and Department of Electronics and

Communication Engineering, Communication Engineering, Communication Engineering,

Thanthai Periyar Govt.Institute Thanthai Periyar Govt .Institute Thanthai Periyar Govt .Institute

Of Technology, Vellore-632002. Of Technology, Vellore-632002. Of Technology, Vellore-632002.

Project viva voce held on …………………

INTERNAL EXAMINER EXTERNAL EXAMINER

i
ACKNOWLEDGEMENT

The satisfaction that accompanies the successful completion of and task

would be incomplete without the mention of the people who made it possible,

their constant guidance and encouragement crowned our effects with success.

Our profound thanks go to Our Principal Dr. P. K. PALANI, M.E.,


Ph.D., Thanthai Periyar Government Institute of Technology, Vellore, for
scholarly guidance and valuable motivation throughout the career.

We articulate our special honour to Professor Dr. S. LETITIA, M.E.,


Ph.D., Head of the Department of Electronics and Communication Engineering,
Thanthai Periyar Government Institute of Technology, Vellore, for her valuable
suggestions and moral support to complete the project in a efficacious way.

We extend our heartfelt thanks to our esteemed class Faculty Advisor


Dr.B. SENTHIL MURUGAN, M.E., Ph.D., for his invaluable guidance and
unwavering support. His expertise has been instrumental in shaping our
project's success, and we are deeply grateful for their dedication. Our special
thanks to our project supervisor Mrs. S. KRITIGA, M.E., for her valuable
guidance, ideas and encouragement for the successful completion of this
project. We are greatly thankful to our project coordinator Dr. S.
SATHISHBABU, M.E., Ph.D., Associate Professor for his valuable
suggestions and moral support.

Also, we express our sincere thanks to all the teaching and non-teaching
staff members of Electronics and Communication Department for their
encouragement in bringing our project successful.

ii
ABSTRACT

A mobile application that could help farmers manage irrigation, monitor

soil conditions, and plan future crops effectively. The system integrates real-

time weather updates and forecasts a week, enabling farmers to schedule

irrigation based on weather conditions and water availability. Soil sensors

(NPK, moisture, and pH) installed on farmland collect real-time field data,

which is displayed on the App. Farmers can automate irrigation or control it

manually through the application. Additionally, a machine learning-based

crop advisory system analyzes soil nutrients, humidity, pH levels, and crop

season to recommend suitable crops. A price prediction feature, based on

historical market trends, helps farmers estimate potential profits and losses

for better financial planning. This integrated solution enhances water

efficiency, improves crop yield, and supports sustainable agriculture by

providing data-driven insights directly through a user-friendly mobile

application.

iii
TABLE OF CONTENTS
CHAPTER TITLE PAGE

NO NO

ABSTRACT iii

LIST OF FIGURES viii

LIST OF TABLE ix

LIST OF ABBREVIATION x

1 INTRODUCTION 1

1.1 BACKGROUND AND MOTIVATION 1

1.2 PROBLEM STATEMENT 2

1.3 OBJECTIVES 2

1.4 SCOPES 2

1.5 EXISTING SYSTEM 2

1.5.1 CHALLENGES IN EXISTING SYSTEM 3

1.6 PROPOSED SOLUTION 3

1.7 ORGANIZATION OF THESIS 4

2 LITERATURE REVIEW 5

2.1 INTRODUCTION 5

2.2 REVIEW OF EXISTING SYSTEM 5

2.3 CONCLUSION 7

3 PROPOSEDSYSTEM 8

3.1 DESIGN AND APPROACH 8

iv
CHAPTER TITLE PAGE

NO NO

3.1.1 REAL-TIME SOIL MONITORING 8

3.1.2. AUTOMATED IRRIGATION CONTROL 8

3.1.3. CROP RECOMMENDATION USING ML 9

3.1.4. MOBILE APPLICATION INTERFACE 9

3.1.5. CLOUD INTEGRATION WITH FIREBASE 9

3.2 BLOCK DIAGRAM 10

3.3 CONCLUSION 10

4 HARDWARE COMPONENTS 11

4.1 ESP32 11

4.2 NPK SENSOR (RS485 INTERFACE) 12

4.3 SOIL MOISTURE SENSOR 12

4.4 PH MODULE 13

4.5 DHT11 SENSOR 13

4.6 OLED DISPLAY 14

4.7 RELAY MODULE 15

4.8 WATER PUMP 16

4.9 CONCLUSION 16

5 SOFTWARE IMPLEMENTATION 17

5.1 SYSTEM OVERVIEW AND SETUP 17

v
CHAPTER TITLE PAGE

NO NO

5.2 HARDWARE SETUP 18

5.2.1KEY COMPONENTS AND SETUP 18

5.2.2ASSEMBLY PROCESS 19

5.3 SOFTWARE DEVELOPMENT AND 20


INTEGRATION

5.3.1 SOFTWARE DEVELOPMENT PROCESS 21

5.3.2 INTEGRATION ARCHITECTURE 22

5.3.3 DEPLOYMENT STRATEGY 23

5.3.4 FINAL SOFTWARE WORKFLOW 23

5.4 TESTING AND VALIDATION 24

5.4.1 DATA PREPARATION AND HANDLING 24

5.4.2 MODEL TRAINING AND OPTIMIZATION 24

5.4.3 PERFORMANCE EVALUATION METRICS 25

5.4.4 FEATURE ENGINEERING 25

5.4.5 REAL-TIME PRICE VALIDATION 25

5.4.6 END-TO-END TESTING 26

5.5 CONCLUSION 26

6 RESULTS AND DISCUSSION 27

6.1 RESULTS FROM MODEL TRAINING 27

vi
CHAPTER TITLE PAGE

NO NO

6.2 REVENUE ANALYSIS & PRICE INTEGRATION 28

6.3 CROP DISTRIBUTION AND VISUALIZATION 29

6.4 REAL-TIME WEATHER FORECAST 30


INTEGRATION

6.5 HARDWARE VALIDATION AND OUTPUT 31

6.6 MOBILE APPLICATION INTERFACE 33

6.7 WEB APPLICATION DEPLOYMENT 34

6.8 DISCUSSION 35

6.9 CONCLUSION 36

7 CONCLUSION AND FUTURE WORK 37

7.1 CONCLUSION 37

7.2 RECOMMENDATIONS FOR FUTURE WORK 38

REFERANCE 40

APPENDIX 41

vii
LIST OF FIGURES
FIGURENO TITLE PAGENO

3.1 Block Diagram 10

4.1 General ESP32 diagram 12

4.2 NPK Sensor With RS485 13

4.3 Soil Moisture Sensor 14

4.4 PH module 15

4.5 DHT11 16

4.6 OLED 16

4.7 Relay 16

4.8 Water Pump 17

6.1 Model Evaluation Report 28

6.2 Prediction Results 29

6.3 Prediction Results 30

6.4 Crop Distribution Pie Chart 31

6.5 Real-Time Weather 32

6.6 Hardware Setup 33

6.7 NPK sensor 33

6.8 Arduino Output 34

6.9 Sign Up Page 35

6.10 Smart Crop Recommendation System 36

viii
LIST OF TABLES

TABLE TITLE PAGE

NO NO

5.1 STACK AND LAYER-WISE FUNCTIONALITY 23

ix
LIST OF ABBREVIATIONS

ABBREVIATION EXPANSION
AI Artificial Intelligence
AIML Artificial Intelligence and Machine Learning
BLE Bluetooth Low Energy
CSV Comma-Separated Values
DHT Digital Humidity and Temperature Sensor
ESP32 Espressif Systems 32-bit Microcontroller
HTML HyperText Markup Language
IDE Integrated Development Environment
IoT Internet of Things
ML Machine Learning
NPK Nitrogen, Phosphorus, and Potassium
OLED Organic Light Emitting Diode
PCB Printed Circuit Board
pH Potential of Hydrogen
RNN Recurrent Neural Network
SMOTE Synthetic Minority Over-sampling Technique
UI User Interface
UART Universal Asynchronous Receiver Transmitter
Wi-Fi Wireless Fidelity
XGBoost eXtreme Gradient Boosting
API Application Programming Interface

x
CHAPTER 1

INTRODUCTION

1.1 BACKGROUND AND MOTIVATION

• Traditional irrigation practices often lead to inefficient water usage,


affecting crop yield and soil health. Moreover, farmers lack access to
real-time data on soil fertility, leading to improper crop choices and
resource wastage.
• Emerging technologies like IoT and AI offer a smarter way to manage
irrigation and crop selection. With real-time sensor data and intelligent
algorithms, farmers can make informed decisions about watering
schedules and crop planning.

1.2 PROBLEM STATEMENT

Water scarcity in agriculture leads to inefficient irrigation and


reducedcrop yields. Traditional methods often cause overuse of water, while
farmers struggle to select suitable crops due to a lack of data-driven insights. To
address these issues, a smart agriculture system integrating IoT and machine
learning is needed. Sensors willmonitor soil moisture, NPK levels, and weather
conditions, providing real-time data. A machine learning-based crop advisory
system willanalyse soil parameters to recommend suitable crops. This solution
enables informed decision-making, optimizing water usage, improving
productivity, and increasing profitability for farmers.

1
1.3 OBJECTIVES

• Develop an intelligent irrigation system using IoT.


• Develop a crop advisory system using machine learning.
• Integrate both the intelligent irrigation system and crop advisory system
into an app.
• Optimize water usage by monitoring real-time soil moisture and weather
conditions.
• Provide farmers with data-driven insights for crop planning and irrigation
scheduling.

1.4 SCOPE

The system integrates NPK sensors, soil moisture sensors,


temperature/humidity sensors, and a pH sensor, all connected to an ESP32
microcontroller. Data is uploaded to Firebase and visualized through a mobile
app. AI-based recommendations help farmers make optimal choices

1.5 EXISTING SYSTEM

• Soil Moisture-Based Automated Irrigation These systems automate


irrigation based on soil moisture levels but do not consider other
important factors like soil nutrients, pH, or weather forecasts.
• Weather Forecasting Applications General-purpose weather apps
provide weather updates but are not specifically tailored for agricultural
use or linked with irrigation decisions.
• Government Advisory Platforms (e.g., Kisan Suvidha, Agmark net):
These platforms provide seasonal crop recommendations and market
prices. However, the recommendations are not personalized, and market
data is often historical rather than predictive.

2
1.5.1 Challenges in Existing System

• Lack of Integration Most existing solutions work in silos and do not


combine key components such as real-time sensor data, weather updates,
irrigation control, crop advisory, and market price prediction into a single
platform.
• Limited Personalization and Accuracy Crop recommendations are
often generic and not tailored to specific field conditions like soil
nutrients (NPK), pH levels, or climate, resulting in poor decision-making
and reduced yield.
• High Cost and Low Accessibility Advanced systems are often expensive
to install and maintain, and require continuous internet access, making
them impractical for small or remote farmers.

1.6 PROPOSED SOLUTION

The proposed system is a smart and adaptive solution that combines IoT-
based sensing, AI-powered decision-making, and cloud connectivity to address
challenges in modern agriculture. It incorporates multiple sensors such as soil
moisture, temperature, humidity, pH, and NPK sensors to collect real-time data
on soil and environmental conditions. An ESP32 microcontroller is used to
process this data and upload it to Firebase, enabling cloud-based storage and
synchronization with a mobile application. The Android app provides an
intuitive interface for farmers to monitor sensor readings, receive crop
recommendations, and control irrigation systems either manually or
automatically.

To improve water efficiency, the system features an automated irrigation


mechanism that activates water flow when soil moisture drops below a defined
threshold and stops it once optimal moisture is achieved. A machine learning

3
algorithm analyses soil fertility, seasonal patterns, and weather data to
recommend the most suitable crops for cultivation. Additionally, the system
includes market price prediction functionality to guide farmers in selecting
crops that offer higher profitabe. This integration of real-time sensing,
automation, and ML ensures precise, data-driven farm management while
reducing water wastage, labour, and input costs.

1.7 ORGANIZATION OF THESIS

The Report is organized into seven chapters. They discussed as follows:

Chapter 1: deals with introduction. It also includes objectives and existing


system limitations.

Chapter 2: presents a review of existing smart agriculture systems using IoT


and AI technologies.

Chapter 3: outlines the design and architecture of the proposed intelligent


irrigation and crop advisory system.

Chapter 4: describes the hardware components used for sensing, control, and
field deployment.

Chapter 5: explains the software development, system integration, and AI model


implementation.

Chapter 6: discusses the results, system validation, and performance evaluation


of the developed solution.

Chapter 7: concludes the project and suggests directions for future and
improvements and enhancements.

4
CHAPTER 2

LITERATURE SURVEY

2.1 INTRODUCTION

The adoption of IoT and AI in agriculture has led to the development of


smart systems aimed at improving irrigation efficiency and crop planning. This
chapter reviews existing research focused on intelligent irrigation systems and
machine learning-based crop advisory models. It identifies the strengths and
limitations of previous works and sets the foundation for the proposed
integrated solution that combines real-time monitoring, automation, and
economic forecasting to support modern precision farming.

2.2 REVIEW OF EXISTING SYSTEM

[1] Sharma, S., & Gupta, R. "Towards Precision Agriculture: IoT-Enabled


Intelligent Irrigation Systems Using Deep Learning Neural Network."
IEEE Sensors Alert, 2021.

Sharma and Gupta [1] proposed an IoT-enabled intelligent irrigation system


employing deep learning models, specifically a Long Short-Term Memory
Recurrent Neural Network (LSTM-RNN), to predict soil moisture levels based
on historical data. Their work emphasizes precision irrigation through predictive
analytics. However, our proposed system integrates real-time weather updates
and forecasting within a mobile application, ensuring dynamic and adaptive
irrigation scheduling rather than relying solely on past data trends.

[2] Patel, M., & Singh, A. "Towards a Multimodal System for Precision
Agriculture using IoT and Machine Learning." arXiv preprint
arXiv:2107.04895, 2021.

5
Patel and Singh [2] introduced a multimodal system for precision agriculture
that utilizes IoT for real-time data collection and ML for crop damage and
disease prediction. Their study highlights the significance of data integration in
improving crop yield quality. In contrast, our system extends beyond damage
prediction by incorporating an ML-based crop advisory system that suggests
optimal crops based on soil conditions, weather parameters, and seasonal trends.

[3] Kumar, R., & Verma, S. "Application of Machine Learning


Approaches in Supporting Irrigation Management." 280, 108123, 2024.

Kumar and Verma [3] developed an AI-driven irrigation system that employs
real-time soil and weather data, using a decision tree algorithm for automated
irrigation scheduling based on predefined rules. While their work provides a
rule-based approach to irrigation control, our system enhances user flexibility
by integrating both automated and manual irrigation control through a mobile
application, allowing farmers to make informed decisions based on real-time
conditions.

[4] Sharma, P., & Khan, M. "Smart Farming - Precision Agriculture Using
ML." 2023.

Sharma and Khan [4] explored the application of IoT and ML in smart farming,
particularly in yield prediction using soil nutrient levels, pH, and weather data.
Their study focuses on optimizing crop selection and monitoring, whereas our
approach further integrates sensor-based field monitoring to display real-time
soil moisture, pH, and NPK measurements on a mobile platform for immediate
actionable insights.

[5] Shaukat, F., & Ahmed, S. "Machine Learning-Based Optimal Crop


Selection System in Agriculture." 13, 42356, 2023.

6
Shaukat and Ahmed [5] proposed an ML-based predictive system to determine
the most suitable crop for a given season by analyzing historical and real-time
field data. While their work is centered on seasonal crop selection, our project
introduces an additional market-driven price prediction module to estimate
profitability, enabling farmers to make economically informed decisions.

By integrating IoT, ML, real-time weather analytics, sensor-based monitoring,


and a price prediction model into a unified platform, our system provides a
holistic, user-friendly, and cost-effective solution for modern precision farming.
Unlike prior studies, which primarily focus on isolated aspects such as
predictive analytics or rule-based irrigation, our work offers a comprehensive
approach that not only optimizes irrigation and crop selection but also enhances
financial decision-making for farmers.

2.2CONCLUSION

Itprovides a comprehensive literature review of existing research in


precision agriculture, particularly focusing on IoT and machine learning
applications for irrigation and crop planning. While previous studies have
contributed valuable insights such as predictive irrigation and disease detection
many lacked a fully integrated, end-to-end solution. This chapter highlights the
uniqueness of the proposed system by comparing it with earlier works. It
concludes that a unified approach combining real-time soil monitoring,
automated irrigation, AI-based crop recommendations, and market price
prediction offers a more practical, scalable, and impactful solution for farmers.

7
CHAPTER 3

PROPOSED SYSTEM

3.1 DESIGN AND APPROACH

The proposed system integrates Internet of Things (IoT) technology,


Machine Learning (ML), and cloud computing to enable intelligent irrigation
control and crop recommendation. The methodology consists of real-time soil
monitoring, automated irrigation control, AI-based crop prediction, mobile
application interfacing, and cloud-based data storage.

3.1.1 Real-Time Soil Monitoring

Multiple sensors are deployed in the agricultural field to monitor essential


parameters such as soil moisture, temperature, humidity, pH, and NPK
(Nitrogen, Phosphorus and Potassium) content. These sensors are interfaced
with an ESP32 microcontroller, which reads the sensor values and prepares
them for transmission. Real-time data is essential for determining soil health
and deciding both irrigation timing and suitable crops.

3.1.2. Automated Irrigation Control

The system offers automated irrigation capabilities through a mobile


application. In automatic mode, it continuously monitors soil moisture levels. If
the moisture level drops below a predefined threshold, the ESP32
microcontroller activates a relay to initiate irrigation. Once the optimal moisture
level is reached, the system stops watering to prevent over-irrigation, thereby
conserving water.

8
3.1.3. Crop Recommendation Using ML

An ML-driven crop recommendation model is trained on historical


agricultural data, considering factors such as soil fertility (NPK), pH value,
temperature, humidity, and seasonal patterns. Based on current sensor readings
and environmental conditions, the AI model predicts and recommends the most
suitable crops for the specific field. The model also factors in market trends,
allowing economically optimized crop planning.

3.1.4. Mobile Application Interface

A user-friendly Android application is developed to serve as the primary


interface for farmers. It displays real-time sensor data, provides irrigation
control options and delivers crop recommendations. This centralized control
empowers farmers with decision-making capabilities without requiring them to
be physically present in the field.

3.1.5. Cloud Integration with Firebase

The system uses Firebase to store and sync sensor data in real time. This
cloud platform enables multi-user access, data backup, and scalability. Farmers
can access environmental data from any location, allowing for long-term
analysis and planning. This also ensures that data is not lost even if the local
system fails.

9
3.2 BLOCK DIAGRAM:

Figure3.1 Block Diagram

The Figure3.1 illustrates the block diagram of the Intelligent Irrigation


System. This system is centred around the ESP32 microcontroller, which
functions as the main processing and control unit. The design integrates
multiple sensors and communication modules to monitor environmental and soil
conditions in real time, enabling automated irrigation management.

3.3 CONCLUSION

The proposed IICRS system effectively integrates IoT, Machine


Learning, and cloud computing to enable smart irrigation and crop
recommendation. Real-time sensor data ensures precise irrigation control, while
the ML model suggests optimal crops based on soil and environmental factors.
The mobile app enhances user accessibility, and Firebase provides reliable
cloud storage and remote monitoring. This approach promotes efficient farming,
resource conservation, and increased productivity.

10
CHAPTER 4

HARDWARE COMPONENTS

4.1 ESP32

The ESP32, developed by Espressif Systems, is a highly versatile


microcontroller renowned for its dual-core processor, integrated Wi-Fi, and
Bluetooth connectivity. Its dual-core architecture enhances multitasking
capabilities, while the built-in Wi-Fi (802.11 b/g/n) and Bluetooth
(Bluetoothv4.2 and BLE) enable seamless connectivity for IoT
applications.Figure 4.1 illustrates the general architecture of the ESP32,
highlighting its dual-core processor, integrated Wi-Fi and Bluetooth modules,
and various I/O interfaces that support diverse IoT applications.

Figure 4.1General ESP32 diagram


11
4.2NPK SENSOR (RS485 INTERFACE):

It Measures the nitrogen, phosphorus, and potassium content of the soil. It


is connected via the RS485 protocol for stable long-distance communication.
Figure 4.2 shows the NPK sensor with an RS485 interface, depicting its
connection setup and how it facilitates accurate soil nutrient measurement over
long distances.

Figure 4.2 NPK Sensor With RS485

4.3SOIL MOISTURE SENSOR

Soil moisture sensors measure the amount of water present in the soil,
typically by detecting changes in electrical properties or measuring water
tension. Figure 4.3 illustrates the soil moisture sensor used to detect the water
content in soil, crucial for regulating irrigation automatically.

12
Figure 4.3SoilMoistureSensor

4.4PH MODULE

Evaluates the soil's acidity or alkalinity which is crucial for crop


suitability. The Energy Efficiency pH module, often referred to as a pH sensor
or pH probe, is a device used to measure the acidity or alkalinity of a solution. It
works based on the principle of potentiometry, where a voltage is generated
between the sensing electrode and a reference electrode in response to the
hydrogen ion concentration in the solution. Figure 4.4 shows the pH module
setup, which helps assess soil acidity or alkalinity to ensure optimal crop growth
conditions.

Figure 4.4 PH module

13
4.5 DHT11 SENSOR

The DHT22 temperature and humidity sensor, also known as the


AM2302, is a widely used sensor in various IoT projects and environmental
monitoring applications. It utilizes a capacitive humidity sensor and a thermistor
to measure relative humidity and temperature respectively. Figure 4.5 displays
the DHT11 sensor, demonstrating how temperature and humidity data are
captured for environmental monitoring

Figure 4.5 DHT11

4.6 OLED DISPLAY

Displays live sensor readings locally for monitoring without mobile


access. Figure 4.6 depicts the OLED display module that visually presents live
sensor data for easy local monitoring.

14
Figure 4.6 OLED

4.7 RELAY MODULE

Connected to the ESP32, this controls a water pump or irrigation valve,


activating it based on the soil moisture level. A relay is an electromechanical
switch operated by an electrical current. It consists of a coil and one or more
contacts. When current flows through the coil, it generates a magnetic field that
moves the contacts into position, either opening or closing the circuit. Figure
4.7 shows the relay module connected to the ESP32, enabling control of
irrigation hardware like water pumps based on sensor input.

Figure 4.7 Relay

15
4.8 WATER PUMP

The motor’s operation is controlled by an electrical relay or motor driver,


such as the L298N, which switches the motor ON or OFF based on the input
signal in a smart irrigation system, the motor is activated when environmental
conditions, like soil moisture, signal the need for irrigation. In Figure 4.8The
motor controls the water pump to irrigate the crops. When the soil moisture
reaches an adequate level, the motor automatically switches off. This ensures
efficient water usage and energy-saving, making the irrigation process fully
automated.

Figure 4.8 Water Pump

4.9 CONCLUSION

This chapter presented the key hardware components used in the


Intelligent Irrigation and Crop Recommendation System. Each module ranging
from the ESP32 microcontroller to sensors for soil monitoring and
environmental data collection plays a critical role in ensuring system accuracy
and efficiency. The integration of these components enables real-time data
acquisition, automated irrigation control, and on-field monitoring, laying a
strong foundation for implementing a reliable and scalable smart agriculture
solution.

16
CHAPTER 5

SOFTWAREIMPLEMENTATION

5.1 SYSTEM OVERVIEW AND SETUP

The implementation phase involves the practical realization of the


Intelligent Irrigation and Crop Recommendation System (IICRS), transforming
the system design into a functional prototype. This chapter presents the steps
followed in setting up and integrating both hardware and software components
to create a cohesive and fully operational smart agriculture platform.

The system setup begins with the initialization and programming of the
ESP32 microcontroller. The microcontroller serves as the core processing unit,
coordinating sensor readings, decision-making algorithms, cloud database
communication, and output control actions. Firmware is developed using the
Arduino IDE, which includes embedded C/C++ code to interface with various
sensors and modules.

Upon powering the system, the ESP32 sequentially establishes


connections with all onboard sensors. The sensors gather real-time
environmental data, which is processed and used to make decisions on irrigation
control. Simultaneously, this data is transmitted to the cloud and visualized in
the mobile application for user access.

The overall system setup is as follows:

• All sensors are mounted securely and connected to the ESP32's GPIO
pins.
• A 5V regulated power supply is used to energize the components.
• The microcontroller is flashed with firmware that handles data
acquisition, processing, and transmission.

17
• Firebase credentials are programmed for seamless wireless
communication.
• The mobile application is linked to Firebase, allowing real-time data
access and notifications.

This setup ensures an efficient loop of sensing, decision-making, actuation,


and monitoring, laying the groundwork for precision agriculture in real time.

5.2 HARDWARE SETUP

The hardware setup focuses on the physical arrangement and electrical


connections of the various components in the system. This stage is critical to
ensure that the data collected by sensors is accurate and that the control
mechanisms function reliably.

5.2.1Key Components and Setup

• ESP32 Microcontroller: Mounted on a breadboard or PCB with


connections to all sensor modules. It serves as the brain of the system,
handling all processing and wireless communication tasks.
• DHT11 Sensor: Connected to a digital pin of the ESP32, it provides
temperature and humidity readings. Placed in an open environment to
ensure accurate ambient measurements.
• Soil Moisture Sensor: Inserted into the soil, it is connected to an analog
input pin. It detects soil moisture levels and provides analog data for
irrigation decision-making.
• pH Sensor Module: Calibrated using standard solutions and connected to
the ESP32's analog pin. It helps determine the soil’s acidity or alkalinity.
• NPK Sensor (via RS485): Integrated using the RS485 communication
module. It is connected to the ESP32 through UART pins and provides
vital information on nutrient levels in the soil.

18
• OLED Display: Wired to I2C pins of the ESP32. Displays sensor
readings and system status for real-time on-site feedback.
• Relay Module: Connected to a digital pin on the ESP32. It controls the
irrigation pump based on commands from the microcontroller.
• Power Supply Unit: A regulated power module (5V/3.3V) ensures stable
voltage levels for all components. Connected via USB or external battery
pack depending on deployment location.
• Firebase Integration: Wi-Fi credentials and Firebase API keys are
embedded in the ESP32’s firmware. Sensor data is pushed to Firebase,
and mobile users retrieve it through an app interface.

5.2.2Assembly Process

• All components were initially tested individually to ensure proper


functionality.
• The ESP32 was programmed and flashed using the Arduino IDE.
• Sensors were connected according to the block diagram using jumper
wires and breadboard or soldered connections.
• The mobile application was configured to link with Firebase and display
the live data.
• A fully functional prototype was deployed in a testbed environment with
real soil and simulated weather conditions.

This hardware setup lays the foundation for real-world application in


agricultural fields, where farmers can monitor soil health, automate irrigation,
and receive insights through a smartphone interface.

19
5.3 SOFTWARE DEVELOPMENT AND INTEGRATION

The software development and integration phase combine multiple


platforms and programming environments to create a unified smart agriculture
ecosystem. This section details the development lifecycle, component
integration, and deployment strategies adopted for both the Intelligent Irrigation
System and the AIML-based Crop Advisory System.

5.3.1 Software Development Process

The software stack comprises embedded firmware, cloud databases, a


mobile application, and a web-based crop recommendation platform. The
development process followed a modular approach with specific roles for each
layer:

1. ESP32 Firmware (Arduino IDE)

The firmware was developed in C++ using the Arduino IDE to interface
with environmental and soil sensors. It performs the following tasks:

• Reads data from DHT11, pH, NPK, and soil moisture sensors.
• Processes and packages this data into JSON format.
• Establishes a Wi-Fi connection and continuously uploads data to Firebase
Realtime Database.
• Triggers relay activation based on soil moisture thresholds for automated
irrigation.

2. Firebase Cloud Integration

Firebase serves as the central database for sensor data. Key


functionalities:

• Stores real-time data streamed from the ESP32.


20
• Offers seamless integration with both mobile and web applications.
• Ensures synchronization across all user devices.

3. AIML Model Development (Jupyter Notebook + Flask)

An XGBoost Classifier model was trained on an engineered dataset,


where:

• SMOTE was applied to resolve class imbalance.


• New indices such as NPK-TH and Soil Moisture Index were created to
enhance prediction quality.
• The final model was exported as a .pkl file and integrated into a Flask
application.

4. Web Application (Flask + HTML/CSS

The web application acts as the user interface for crop advisory:

• Built using Flask for backend API handling and HTML/CSS for frontend
layout.
• Accepts inputs such as NPK levels, pH, temperature, humidity, soil type,
and cultivation period.
• Displays top crop recommendations, revenue forecasts, and dynamic
charts.
• Scrapes live market data using custom Python modules and updates it in
real time.

5. Mobile Application (Thunkable)

Thunkable was used to build a cross-platform mobile application that integrates


hardware and software components:

• Blocks were created to fetch real-time sensor data from Firebase.

21
• Displays soil temperature, humidity, moisture, and pH directly on the
app.
• Sends irrigation control signals based on conditions or manual trigger.
• Links to the web-based crop recommendation system (hosted on Render)
for one-click access from the mobile app.

5.3.2 Integration Architecture

The system integration ensures seamless interaction between sensing,


analytics, and user interfaces. The entire ecosystem is orchestrated as
follows:

TABLE 5.1 TECHNOLOGY STACK AND LAYER-WISE FUNCTIONALITY

Layer Technology Function


Hardware Layer ESP32, Sensors, Relay Collects and acts on
environmental/soil data
Cloud Layer Firebase Stores sensor data,
syncs with mobile app
AIML Layer Python, XGBoost, Predicts crops,
Flask revenue, and
profitability
Web App Layer Flask, HTML/CSS, Provides web-based
Render advisory with UI
Mobile App Layer Thunkable Shows sensor readings
and links to crop
advisor

The ESP32 uploads data to Firebase in real-time. Thunkable blocks are


configured to continuously fetch and display this data in the mobile app.

22
Meanwhile, users can navigate to the advisory system on Render through a link
or embedded view within the app.

5.3.3 Deployment Strategy

To make the system reliable, scalable, and accessible:

• Web Application is deployed on Render, allowing global access to users


from any device.
• Thunkable Mobile App is compiled and shared as an Android
application or accessible via a web-view link.
• Firebase ensures high-speed, real-time data syncing across all layers.

The integration of the mobile app with real-time Firebase readings and the
web-based crop advisor makes the solution highly usable for farmers, students,
and agriculture stakeholders.

5.3.4 Final Software Workflow

• ESP32 reads sensor data and uploads it to Firebase.


• Thunkable fetches this data and displays it on the user’s mobile screen.
• User clicks on the advisory link in the app to open the web-based crop
recommendation system.
• Inputs are either manual or auto-fetched (planned future enhancement).
• The AI model predicts suitable crops and shows expected revenue and
market prices.
• Farmers make informed decisions on irrigation and cultivation, all within
a single integrated app.

23
5.4 TESTING AND VALIDATION

The Smart Crop Recommendation System underwent rigorous testing and


validation to ensure its accuracy, robustness, and real-world applicability. The
testing involved multiple components including data preprocessing, model
training with hyperparameter tuning, validation using stratified sampling,
performance evaluation, and testing the end-to-end integration with web
scraping for real-time pricing.

5.4.1 Data Preparation and Handling Imbalance

The training dataset was pre-processed using label encoding for


categorical variables like soil type and cultivation period. To address the issue
of class imbalance in crop categories, SMOTE (Synthetic Minority Over-
sampling Technique) was applied. This ensured that minority crops received
sufficient representation in the training data, thereby improving model
generalization.

5.4.2 Model Training and Optimization

An XGBoost Classifier was selected due to its robustness, high


performance on tabular data, and ability to handle non-linear relationships. The
training process was further enhanced by using Optuna, an advanced
hyperparameter optimization framework, which automatically selected the best
parameters for learning rate, max depth, and estimators using stratified K-fold
cross-validation.

24
5.4.3 Performance Evaluation Metrics

The model was evaluated on multiple metrics:

• Accuracy Score: Measured overall correctness.


• Classification Report: Provided precision, recall, and F1-score for each
class.
• Confusion Matrix: Used to visualize model predictions and identify
common misclassifications.

The high accuracy and balanced performance across classes demonstrated the
effectiveness of combining SMOTE with XGBoost and feature engineering.

5.4.4 Feature Engineering and Interpretability

Important synthetic features like:

• NPK Ratio
• Temperature-Humidity Index
• Soil Moisture Index
• NPK-TH Index

were introduced to enhance model performance and interpretability. These


features helped capture complex soil and environmental conditions influencing
crop suitability.

5.4.5 Real-Time Price Validation via Web Scraping

The revenue and profitability aspects of the recommendation were


validated using a custom Python-based web scraper that fetched real-time crop
prices from government market portals. The scraper parsed HTML content and
extracted up-to-date prices for both primary and companion crops, which were
then integrated into the model's output for accurate revenue prediction.
25
5.4.6 End-to-End Testing

The full pipeline from sensor data input to final crop recommendation
and price forecasting was tested in an integrated environment. The AI/ML
model was deployed using Flask, and the frontend interfaces (web and mobile)
were validated for data flow integrity with Firebase as the backend sync
platform. The complete system was hosted using Render, and all outputs
including predicted crops, price-based revenue estimates, and land allocation
pie charts were visually and functionally validated.

5.5 CONCLUSION

The implementation of the Intelligent Irrigation and Crop


Recommendation System (IICRS) successfully integrated hardware, software,
and AI components into a cohesive solution for smart farming. Through real-
time sensing, automated irrigation, and intelligent crop prediction, the system
demonstrated practical applicability in enhancing agricultural efficiency. The
thorough testing and validation ensured system reliability, while the seamless
integration of mobile and web interfaces made it user-friendly and accessible to
end-users.

26
CHAPTER 6

RESULTS AND DISCUSSION

This chapter showcases the real-world performance of the Intelligent


Irrigation and Crop Recommendation System (IICRS), presenting key
observations from model deployment, real-time integration, and live application
testing. The system combines AI-powered analytics with IoT hardware and
cloud technology to provide intelligent and actionable insights to farmers.

6.1 RESULTS FROM MODEL TRAINING

The crop recommendation model, developed using XGBoost Classifier


with SMOTE oversampling and Optuna-based hyperparameter tuning,
achieved a robust performance across 20+ crop classes. The model produced a
final accuracy of 75.91%, as shown in the classification report (Figure 6.1). The
F1-scores across most classes remained above 0.70, demonstrating balanced
predictive power.

Figure 6.1 Model Evaluation Report

27
Additionally, the deployed model successfully predicted (Figure 6.2)the top
3 crops based on current soil and environmental inputs:

• Citrus Fruits – 13.42% confidence

• Sunflower Seeds – 9.22%

• Lentils – 7.99%

Figure 6.2 Prediction Results

6.2 REVENUE ANALYSIS & PRICE INTEGRATION

The integration of real-time price data via a Python-based scraper allowed


dynamic revenue forecasting. The scraper fetched prices from Agmark net, e-
NAM, and TNAU, storing them in .csv, .Json, and .pkl formats. The Figure 6.3
Based on current market rates, the system calculated:

• Yield per acre

• Price per kg

• Estimated revenue

28
For example, Lentils were projected with:

• Yield: 12.00 kg/acre

• Price: ₹73.92/kg

• Revenue:₹887.09

Figure 6.3 Prediction Results

6.3 CROP DISTRIBUTION AND VISUALIZATION

To enhance understanding, a crop probability pie chart was displayed


(Figure 6.4). It visualized the land distribution for the recommended crops:

• 33.3% Citrus Fruits

• 33.3% Sunflower Seeds

• 33.3% Lentils

29
Figure 6.4 Crop Distribution Pie Chart

6.4 REAL-TIME WEATHER FORECAST INTEGRATION

The Thunkable mobile app integrated with Firebase displays real-time


temperature, humidity, and soil moisture. It also connects with third-party
weather APIs for 7-day forecasts (Figure 6.5), providing localized agricultural
advisories

30
.

Figure 6.5 Real-Time Weather

6.5 HARDWARE VALIDATION AND OUTPUT

The IoT setup was tested in a prototype field environment. The ESP32
microcontroller read sensor values for:

• Temperature

• Humidity

• Soil Moisture

• NPK Levels

The NPK sensor placed in the field (Figure 6.7). These readings were
displayed on an OLED screen and synced live to Firebase (Figure 6.6).

31
Figure 6.6 Hardware Setup

Figure 6.7 NPK sensor

The Firebase console and terminal logs (Figure 6.8) confirmed correct data
logging and system response:

• Data transmitted in real-time

32
• Relay switched ON/OFF based on moisture threshold

• Sensor values pushed successfully to Firebase

Figure 6.8Arduino Output

6.6 MOBILE APPLICATION INTERFACE

The mobile app (Figure 6.9) provided the following:

• Login/Signup interface

• Sensor dashboard

• Access to AI-based crop advisor

• Live environmental updates

33
Figure 6.9 Sign Up Page

6.7 WEB APPLICATION DEPLOYMENT

The complete AI-based system was deployed on Render at


croplify2.onrender.com. The web UI accepted soil parameters and returned:

• Top 3 crop suggestions

• Revenue forecast

• Graphical outputs

This deployment ensured accessibility across platforms.

34
Figure 6.10 Smart Crop Recommendation System

6.8 DISCUSSION

The results validate that the IICRS system is fully functional, integrated,
and field-ready. The fusion of AI and IoT has enabled data-driven farming,
helping farmers:

• Optimize water usage

• Choose the right crop

• Maximize yield and profit

Despite some limitations (like simulated scraping fallback or training time),


the system offers a complete end-to-end solution.

35
6.9 CONCLUSION

The demonstrated the successful deployment and real-world performance


of the Intelligent Irrigation and Crop Recommendation System (IICRS). The
integration of IoT sensors, machine learning algorithms, and cloud connectivity
resulted in a fully functional smart agriculture platform. The system accurately
monitored environmental and soil parameters, automated irrigation based on
real-time data, and provided crop recommendations with revenue forecasts
using AI models. The mobile and web applications ensured ease of access and
usability for farmers. Validation through testing confirmed the system's
reliability, efficiency, and scalability. Overall, the chapter confirms that the
IICRS is not only technically sound but also practically viable, offering a
comprehensive solution for modern precision farming

36
CHAPTER 7

CONCLUSION AND FUTURE WORK

7.1 CONCLUSION

The Intelligent Irrigation and Crop Recommendation System


(IICRS) successfully integrates IoT-based environmental monitoring with AI-
powered agricultural analytics to provide a smart, data-driven solution for
modern farming. The system effectively gathers real-time data on temperature,
humidity, soil moisture, pH, and nutrient levels using sensors connected to an
ESP32 microcontroller. These readings are transmitted wirelessly to Firebase,
where they are accessed via a user-friendly mobile application developed in
Thunkable.

Simultaneously, the system leverages a robust AI model, developed using


XGBoost Classifier and optimized through Optuna and SMOTE, to
recommend the most suitable crops based on current field conditions.
Additional integration with a live web scraping module enables dynamic
pricing analysis from trusted government sources, helping to forecast revenue
and profitability for each recommended crop.

The AI model was trained with real agricultural datasets, featured advanced
feature engineering, and achieved a strong overall performance. The system is
not only functional but also scalable, and has been deployed as a responsive
web application via Render, making it accessible to farmers, researchers, and
agricultural planners across devices.

Through this project, a complete end-to-end smart farming solution has been
realized—offering precision irrigation, profitable crop recommendations,
and real-time monitoring, thereby addressing critical challenges like water
conservation, yield optimization, and farmer income stability.

37
7.2 RECOMMENDATIONS FOR FUTURE WORK

To further enhance the impact and capabilities of the IICRS, the following
future enhancements are recommended:

1. Integration of Satellite Weather APIs

Incorporate automated weather forecasting from APIs like Open


Weather or IBM Weather to make crop decisions more dynamic and
region-specific.

2. Addition of Crop Disease Detection

Extend the model with computer vision (CV) capabilities to detect


plant diseases using leaf images captured through a mobile app.

3. Offline Data Logging

Implement SD card or EEPROM storage for offline data backup in


case of connectivity failures.

4. Voice-Assisted App Interface

Introduce multilingual voice guidance in the mobile app to support


non-literate farmers in local languages.

5. Automated Fertigation System

Integrate automatic nutrient mixing and dispensing mechanisms


based on NPK readings, completing the smart irrigation loop.

6. Blockchain Integration

Use blockchain to ensure transparency in market price forecasting


and to enable direct crop selling platforms.

38
7. Model Retraining Dashboard

Develop a retraining module for updating the AI model


periodically using newly collected field data for better adaptability over
time.

By implementing these enhancements, the IICRS can evolve into a full-fledged


smart agriculture platform capable of revolutionizing traditional farming
practices.

39
REFERANCES

[1]. Bhakta, I., Phadikar, S., & Majumder, K. (2019). Crop selection system
using machine learning: A review. Smart Agricultural Technology, 1, 100003.

[2]. Kumar, R., & Verma, S. (2024). Application of Machine Learning


Approaches in Supporting Irrigation Management. Agricultural Water
Management, 280, 108123.

[3]. Liakos, K. G., et al. (2018). Machine learning in agriculture: A review.


Sensors, 18(8), 2674..

[4]. Patel, M., & Singh, A. (2021). Towards a Multimodal System for Precision
Agriculture using IoT and Machine Learning. arXiv preprint arXiv:2107.04895.

[5]. Sharma, A., & Jain, P. (2023). IoT and AI-Based Smart Agriculture
System: An Efficient Crop Monitoring Model. Journal of Agricultural
Informatics, 14(1), 32–45..

[6]. Sharma, P., & Khan, M. (2023). Smart Farming - Precision Agriculture
Using ML. ResearchGate.

[7]. Sharma, S., & Gupta, R. (2021). Towards Precision Agriculture: IoT-
Enabled Intelligent Irrigation Systems Using Deep Learning Neural Network.
IEEE Sensors Alert.

[8]. Shaukat, F., & Ahmed, S. (2023). Machine Learning-Based Optimal Crop
Selection System in Agriculture. Scientific Reports, 13, 42356.

[9]. Sishodia, R. P., Ray, R. L., & Singh, S. K. (2020). Applications of remote
sensing in precision agriculture: A review. Remote Sensing, 12(19), 3136.

[10]. Zhang, C., & Kovacs, J. M. (2012). The application of small unmanned
aerial systems for precision agriculture: a review. Precision Agriculture, 13,
693–712.

40
APPEDIX

CONFERENCE CERTIFICATES

41
42
43
44

You might also like