You are on page 1of 28

Internet of Things

SmartzAgri: A ML-IoT aware Crop


Recommendation System for Future Generation
Agriculture
--Manuscript Draft--

Manuscript Number: IOT-D-24-00628

Article Type: Full Length Article

Keywords: Crop recommendations; Crop predictions; XGBoost; monocropping; Smart


Agriculture; Agritech; NPK

Corresponding Author: Deepsubhra Guha Roy, PhD


Institute of Engineering & Management
INDIA

First Author: Vishal Kumar Patel, B.Tech

Order of Authors: Vishal Kumar Patel, B.Tech

Sanjeet Kumar, B.Tech

Ved Anand, B.Tech

Twisha Talukder, B.Tech

Deepsubhra Guha Roy, PhD

Abstract: n the realm of global agriculture, the imperative of sustain-


ing an ever-expanding population is met with challenges in optimizing
crop production and judicious resource management. SmartzAgri heralds
a groundbreaking approach to modern agriculture. This innovative sys-
tem represents a convergence of machine learning algorithms and Internet
of Things (IoT) technology, aimed at reshaping traditional paradigms of
crop recommendation.
At the core of SmartzAgri lies a meticulous process: IoT devices intri-
cately designed collect soil data, focusing on key parameters like Nitrogen
(N), Phosphorus (P), Potassium (K), pH levels, moisture, and temper-
ature. This real-time data is collected using different sensors and seam-
lessly transmitted to a dedicated web platform fortified by cutting-edge
machine learning algorithms including Random Forest, XG-Boost, Naive
Bayes, and Support Vector Machine (SVM). This ensemble of algorithms
facilitates an intelligent analysis, enabling the system to predict with pre-
cision the most suitable crops for a given soil composition. In essence,
SmartzAgri emerges as a sophisticated solution, marrying data-driven in-
sights and real-time analysis to offer farmers nuanced recommendations
for crop selection. This holistic approach holds the promise of enhancing
precision in crop management, ultimately contributing to the elevation
of agricultural productivity in a technologically advanced and informed
manner.

Suggested Reviewers: Priti Deb


Institute of Engineering & Management
pritidb@gmail.com

Shivananda Poojar, PhD


University of Tartu
shivu.poojar@gmail.com

Opposed Reviewers:

Powered by Editorial Manager® and ProduXion Manager® from Aries Systems Corporation
Manuscript (without Author Details)

SmartzAgri: A ML-IoT aware Crop


Recommendation System for Future Generation
Agriculture ⋆

Vishal Kumar Patel1 , Sanjeet Kumar1 , Ved Anand1 , Twisha Talukder1 , and
Deepsubhra Guha Roy2∗
1
Institute of Engineering and Management,University of Engineering and
Management, Kolkata, India
2
IEM Centre of Excellence for Cloud Computing and IoT, Department of
CSE(AIML), Institute of Engineering and Management, University of Engineering
and Management, Kolkata, India
roysubhraguha@gmail.com*

Abstract. In the realm of global agriculture, the imperative of sustain-


ing an ever-expanding population is met with challenges in optimizing
crop production and judicious resource management. SmartzAgri heralds
a groundbreaking approach to modern agriculture. This innovative sys-
tem represents a convergence of machine learning algorithms and Internet
of Things (IoT) technology, aimed at reshaping traditional paradigms of
crop recommendation.

At the core of SmartzAgri lies a meticulous process: IoT devices intri-


cately designed collect soil data, focusing on key parameters like Nitrogen
(N), Phosphorus (P), Potassium (K), pH levels, moisture, and temper-
ature. This real-time data is collected using different sensors and seam-
lessly transmitted to a dedicated web platform fortified by cutting-edge
machine learning algorithms including Random Forest, XG-Boost, Naive
Bayes, and Support Vector Machine (SVM). This ensemble of algorithms
facilitates an intelligent analysis, enabling the system to predict with pre-
cision the most suitable crops for a given soil composition. In essence,
SmartzAgri emerges as a sophisticated solution, marrying data-driven in-
sights and real-time analysis to offer farmers nuanced recommendations
for crop selection. This holistic approach holds the promise of enhancing
precision in crop management, ultimately contributing to the elevation
of agricultural productivity in a technologically advanced and informed
manner.

Keywords: Crop recommendations, Crop predictions, IoT(Internet of


Thing), Machine Learning, XGBoost, SVM (Support Vector Machine),
Random Forest, Naive Bayse, monocropping, Smart Agriculture, Agritech,
NPK, Nitrogen, Phosphorus, Potassium.

Supported by IEM Grant in Aid Project from Institute of Engineering and Manage-
ment, Kolkata, India.
2 V.K Patel et al.

1 Introduction

The agricultural sector stands at the nexus of global food security and economic
prosperity, yet faces persistent challenges in optimizing resource utilization, en-
hancing productivity, and promoting sustainability. Practicing monocropping,
a widespread agricultural approach, frequently results in soil depletion, dimin-
ished crop productivity and quality, and heightened susceptibility to diseases and
pests. These alterations stem from shifts in soil microbial populations, variations
in nutrient accessibility, and the impacts of allelopathy. Nevertheless, recent re-
search has provided insights into the mechanisms underlying the challenges posed
by monocropping and has identified effective strategies to overcome these obsta-
cles. [17] In response to these and many more challenges, SmartzAgri emerges
as a pioneering initiative at the forefront of agricultural innovation, integrating
Internet of Things (IoT), machine learning (ML), and web development tech-
nologies to revolutionize crop cultivation practices.

At its core, SmartzAgri leverages IoT-enabled soil analysis to provide farm-


ers with real-time insights into soil health, including vital parameters such as
Nitrogen (N), Phosphorus (P), Potassium (K), pH, rainfall, and temperature.
This data serves as the foundation for SmartzAgri’s advanced ML algorithms,
which generate tailored crop recommendations optimized for the specific soil
conditions and environmental factors present on the farm. In addition to its IoT
and ML capabilities, SmartzAgri boasts a user-friendly web interface designed
to enhance user experience and accessibility. The platform provides farmers with
intuitive tools to interact with soil health data, receive personalized crop rec-
ommendations, and access a wealth of additional features aimed at facilitating
informed decision-making and optimizing agricultural operations.

One such feature is the integration of cultivation guidance, which not only
provides farmers with comprehensive instructions on how to cultivate the recom-
mended crops effectively but also serves as a valuable learning resource for the
younger generation aspiring to enter farming. This feature equips users with prac-
tical knowledge and best practices, enabling them to maximize crop yield and
quality while minimizing resource wastage and environmental impact. Further-
more, SmartzAgri’s web development component enables seamless integration
with additional IoT features such as smart irrigation systems and environmental
monitoring devices. This holistic approach to precision agriculture ensures that
farmers have access to a comprehensive suite of tools and resources to address
the diverse challenges they face in modern farming practices.

By synergizing IoT, ML, and web development technologies, SmartzAgri not


only addresses the immediate needs of farmers but also contributes to broader
initiatives aimed at promoting sustainable agriculture, mitigating climate change
impacts, and ensuring food security for future generations.
Title Suppressed Due to Excessive Length 3

2 Motivation:

The motivation behind the inception of SmartzAgri stems from the pressing
challenges faced by the agricultural sector globally. Despite being the backbone of
food security and economic stability, agriculture encounters numerous obstacles,
including inefficient resource utilization, unpredictable environmental conditions,
and declining soil health.
One of the primary motivations for SmartzAgri is to leverage technology to
overcome these challenges and empower farmers with data-driven solutions for
sustainable crop management. By integrating Internet of Things (IoT) devices,
machine learning algorithms, and web-based platforms, SmartzAgri aims to rev-
olutionize traditional farming practices and enhance productivity, profitability,
and environmental sustainability.

3 Contribution:

The contribution of SmartzAgri extends beyond mere technological innovation;


it represents a paradigm shift in agricultural practices towards precision farming
and data-driven decision-making. By harnessing the power of IoT and machine
learning, SmartzAgri offers several notable contributions to the agricultural com-
munity:

– Optimized Crop Supervision: SmartzAgri furnishes farmers with instan-


taneous assessments of soil condition, empowering them to make knowledge-
able determinations concerning crop variety, fertilization, and watering. Con-
sequently, this results in enhanced crop productivity, caliber, and resilience
to environmental pressures.
– Sustainable agriculture: Through its emphasis on sustainable practices
and resource optimization, SmartzAgri contributes to the long-term viability
of agricultural systems. By promoting soil health, water conservation, and
biodiversity preservation, SmartzAgri fosters a more sustainable approach
to farming.
– Integrated ML tools for smart agriculture: Our contribution extends
beyond the mere implementation of machine learning models; we’ve not only
seamlessly integrated these models into our web platform but also fine-tuned
them to cater to the specific needs and challenges of agricultural decision-
making. By deploying and operationalizing these ML algorithms on our web-
site’s backend, we’ve democratized advanced analytics, empowering farmers
with user-friendly access to sophisticated tools for informed decision-making
in their agricultural practices.
– IoT Enabled Solutions: Our contribution to IoT-enabled solutions en-
compasses the seamless integration of a variety of sensors, long-range WiFi
modules for extensive data transmission, and wireless modules within our
agricultural framework.Furthermore, we have incorporated cloud integra-
tion features, enabling the seamless uploading of collected data to cloud
4 V.K Patel et al.

platforms. Leveraging cloud technology, the data is then processed using


machine learning algorithms on our website, providing farmers with valu-
able insights for optimized crop management and resource allocation

4 Literature Survey:

1. Incorporation of Machine Learning in Prediction of Crop Yield:


Various ML-based approaches and algorithms are deployed to predict crop
yield, enhancing crop quality and maximizing farmer profits, as discussed
in [1-5]. This highlights the importance of leveraging ML for optimizing
agricultural processes and improving overall crop management strategies.
2. Crop Prediction Model with ML Algorithms: Elbasi et al. [6] devel-
oped a crop prediction model using fifteen different ML algorithms, achieving
high classification accuracy. This study emphasizes the significance of ML in
optimizing agricultural processes and highlights the potential for ML algo-
rithms such as Bayesian Network, Hoeffding Tree, and Naive Bayes Classifier
Algos. to enhance crop prediction accuracy.
3. Utilizing Wireless Sensor Networks for Crop Yield Estimation:
Varghese and Sasidhar [7] proposed a wireless sensor network-based approach
for estimation of crop yield, assisting farmers in making enlightened decisions
about their crop selection and management based on environmental data.
This underscores the importance of IoT and sensor technologies in precision
agriculture for improving crop productivity and resource management.
4. Supervised ML for Crop Selection: To aid farmers in making informed
decisions regarding crop selection, Ramya et al. [8] proposed the use of super-
vised ML algorithms, such as K-Nearest Neighbour (KNN), Logistic Regres-
sion(LR), Gaussian Naive Bayes, Random Forest, and Support Vector Ma-
chine(SVM). This study emphasizes the role of data-driven decision-making
in optimizing crop selection and management practices.
5. Implementation of IoT and Deep Learning for Intelligent Agricul-
ture: Varman et al. [9] introduced a deep learning-based smart agriculture
system incorporated with IoT, showcasing its capability to monitor soil pa-
rameters, predict suitable irrigation practices, and enhance crop productiv-
ity. This highlights the integration of advanced technologies such as IoT and
deep learning in agriculture for optimizing resource utilization and improving
crop yields.
6. Sensing Technology for Smart Farming: Ramya et al. [10] proposed a
sensing technology-based smart farming system to collect environmental data
for better crop production management. This study underscores the role of
sensor technologies in enabling precision agriculture practices for sustainable
crop production.
7. Analysis of Monoculture Impact on Soil Health: Belete and Yadete
[17] emphasized the adverse consequences of monoculture on soil vitality
and fertility, emphasizing the necessity for sustainable agricultural method-
ologies.
Title Suppressed Due to Excessive Length 5

8. ANN-Based Crop Advisor:Ravichandran and Koteeshwari [11] intro-


duced an artificial neural network-driven crop advisory system designed to
suggest appropriate crops considering diverse factors. This investigation il-
lustrates the potential of AI-driven platforms in offering tailored suggestions
for crop cultivation and management.
9. Comprehensive Review of Crop Yield Forecasting: Klompenburga
et al. [12] executed an extensive literature review on the prediction of crop
yields, identifying key algorithms and features used in previous studies and
providing insights for future research.
10. Prediction of Crop Diseases using Data Mining Techniques: Ayub
and Moqurrab [13] proposed a methodology for predicting crop diseases uti-
lizing various data mining methodologies, underscoring the significance of
advanced approaches in enhancing prediction precision.
11. Vegetable Species Identification using Deep Learning: Sinha et al.
[14] leveraged deep learning techniques to identify vegetable species accu-
rately, aiming to improve accessibility for individuals with disabilities.
12. IoT-Based Precision Crop Suggestion: Priya and Yuvaraj [16] proposed
an IoT-based precision crop suggestion approach using a gradient descent
approach. This highlights the effectiveness of IoT-based precision agriculture
systems, contributing to more informed decision-making and improved crop
yields for farmers.
13. Prediction Framework for Farming: Rekha et al. [15] proposed a pre-
diction framework for farming using IoT and decision support systems, pro-
viding farmers with actionable insights for optimal crop management. This
framework also highlights the integration of IoT technologies such as use
of different IOT-based sensors and data-driven Decision Support Systems
(DSS) in enabling precision agriculture practices for maximizing crop yields
by providing helpful suggestions to the farmers for their crop’s benefit.

The transformative potential of technological advancements in agriculture is


underscored, offering valuable insights and actionable recommendations to
farmers for maximizing crop productivity in changing environmental condi-
tions. This highlights the importance of continuous innovation and adoption
of technology in modern farming practices. Moreover, these literature surveys
serve as invaluable resources, providing us with insights and ideas to create,
modify and enhance our own models and projects, thus contributing to the
advancement of agricultural practices and maximizing crop’s productivity in
an everchanging landscape

5 Proposed Methodology:
5.1 Data Collection and Preprocessing:
The data employed in this research was sourced from Kaggle, a renowned online
platform for datasets and modified as per our requirement, a prominent plat-
6 V.K Patel et al.

Fig. 1. Workflow Diagram

form for data science projects and competitions. This dataset comprises approx-
imately 72,312 instances for training and 18,079 instances for testing of 40 dif-
ferent crops namely Sunflower, Coriander, moong, jute, rapeseed, wheat, potato,
maize, cotton, rice,ladyfinger, onion, sweetpotato, ragi, horse gram, soyabean,
turmeric, jowar, banana, cauliflower, barley,papaya, orange, tomato, brinjal, gar-
lic, cabbage, jackfruit, blackpepper, radish, grapes, blackgram, mango,cucumber,
cardamom, bitter gourd, pineapple, bottle gourd, drumstick, pumpkin, encom-
passing soil samples collected from agricultural fields along with corresponding
crop labels. Soil samples were gathered using IoT-enabled devices equipped with
sensors to measure crucial dimensions such as Nitrogen (N),Phosphorus (P),
Potassium (K), pH, soil-moisture, and temperature [18]. Additionally, weather
data,including rainfall and temperature, were integrated into the dataset to pro-
vide comprehensive environmental insights . Prior to model development, the col-
lected data underwent thorough preprocessing procedures.This involved cleaning
noise, addressing missing values, and normalizing features to ensure consistency
and reliability. Moreover, feature selection techniques were applied to identify
the most pertinent parameters for crop recommendation, enhancing the dataset’s
relevance and efficiency. Data augmentation methods were also employed to en-
rich the dataset’s diversity and representativeness, thus bolstering the models’
robustness. By employing the Anova test, we can assess whether there is a re-
lationship or independence between features, uncover patterns, and derive well-
informed conclusions regarding the significance of correlations present within
the dataset. This statistical test allows us to evaluate the interdependence of
variables, unveil potential connections, and derive meaningful insights regarding
the relationships present in the data.
Title Suppressed Due to Excessive Length 7

X = X1 + X2 + . . . + Xj (1)
Here, Equation(1) represents the overall variable X as the sum of individual
group variables X1, X2, ..., Xj. and
X
SSB = nj (X j + X)2 (2)
j

Equation(2) represents SSB(Sum of Squares Between-Group) measures the total


variability between groups, where nj is the number of observations in group j,
and X is the overall mean.
X
SSE = (X − X j )2 (3)
Equation(3) calculates SSE(Within-Group Sum of Squares) quantifies the vari-
ability within groups by summing the squared differences between individual
observations (X) and their respective group means (Xj).
SSB
M SB = (where k is the number of groups) (4)
k−1

SSE
M SE = (where N is the total number of observations) (5)
N −k
Additionally Equation (4) & (5) calculates the mean squared variation between
groups and the mean squared variation within groups respectively.
M SB
F = (6)
M SE

CriticalV alue at α = F (α, k − 1, N − k) (7)


Whereas Equation (6) & (7) utilizes the ratio of MSB to MSE to assess if the
between-group variability is statistically significant compared to within-group
variability and determines the critical value for the F-statistic at a given signif-
icance level () with degrees of freedom (k-1, N-k) respectively.
The Anova scores for each dimension in the crop recommendation dataset
were examined, as shown in Table 1., revealing that the F-statistic score for tem-
perature was the least favorable when compared to the scores of other features.
Consequently, a decision was made to exclude temperature from the dataset in
order to proceed with further analysis.
Next, we employ the Z-score formula Z = (x−µ)σ to filter out outliers from the
dataset. In this formula, x denotes the individual data point, µ is the mean, and σ
represents the standard deviation. A predefined threshold has been established to
detect and eliminate outliers; here, we have taken the threshold as 3. Essentially,
any data point with a Z-score below 3 is considered an outlier and is therefore
removed from the dataset.
8 V.K Patel et al.

Parameters F-Statistic P-Value


N 73500.13 0.000
P 106810.53 0.000
K 63144.69 0.000
pH 21161.13 0.000
Rainfall 1108.46 0.000
Temperature 576.67 0.000

Table 1. Different parameters F-Statistic Value

In the course of this procedure, we identified outliers, leading to a modified


dataset size of 70,377 instances, as opposed to the initial count of 72,312 in-
stances. Fig.2. illustrates the interrelationships between the features in the crop
recommendation dataset by depicting their correlation.

Fig. 2. Heat Map of the Dataset

5.2 Model Validation Metrices:


Accuracy Accuracy serves as a foundational metric, reflecting the overall cor-
rectness of the model’s predictions. It’s determined by the ratio of correctly
predicted instances (true positives and true negatives) to the total number of
predictions made as shown in equation(8) While accuracy offers valuable insights,
Title Suppressed Due to Excessive Length 9

index crop N P K pH Rainfall Temperature


0 sunflower 50 60 30 5.58 75.32 22.676
1 coriander 10 20 20 6.48 1026.64 29.1863
2 moong 20 40 20 5.6 770.44 28.680
3 jute 20 40 40 5.38 1166.94 28.333
4 rapeseed 50 40 20 5.14 19.38 22.766
5 wheat 60 30 30 6.3 145.76 22.033
6 potato 180 60 90 5.08 664.96 29.566
7 maize 80 40 20 5.66 297.66 34.666
8 sunflower 50 60 30 5.58 34.81 23.560
9 potato 180 60 90 5.00 167.38 22.890
10 cotton 120 40 20 5.32 1603.2375 28.500
11 rice 80 40 40 5.46 1145.22 28.994
12 ladyfinger 80 10 40 6.56 942.80 29.037
13 onion 120 60 65 6.14 689.88 1.180
14 wheat 60 30 30 6.11 241.78 22.600
15 maize 80 40 20 5.54 1246.72 22.676
16 wheat 60 30 30 6.9 75.32 23.736
17 sweetpotato 90 20 120 4.88 2169.32 22.280
18 horsegram 20 60 20 6.04 152.54 33.373
19 soyabean 20 60 20 5.52 510.05 34.010
20 moong 20 40 20 5.66 579.75 14.700

Table 2. Training dataset

it may not be adequate for imbalanced datasets where one class significantly out-
weighs the other.
T rueP ositive + T rueN egative
Accuracy = (8)
T otalP redictions

Precision Precision, also referred to as positive predictive value, measures the


accuracy of positive predictions generated by the model. It’s computed as the
ratio of true positive predictions to the sum of true positives and false positives
as given in equation(9) A high precision score indicates that when the model
predicts a positive outcome, it’s likely to be correct.
T rueP ositive
P recision = (9)
T rueP ositive + F alseP ositive

Recall Recall, often known as sensitivity, assesses the model’s ability to capture
all relevant instances of a positive class. As shown in equation(10) it is calculated
as the ratio of true positive predictions to the sum of true positives and false
negatives. A high recall value signifies that the model effectively identifies most
of the actual positive instances.
T rueP ositive
Recall = (10)
T rueP ositive + F alseN egative
10 V.K Patel et al.

F1-Score The F1 Score is a measure that harmonizes precision and recall. As


there’s typically a trade-off between precision and recall, the F1 Score quantifies
how effectively our models manage that trade-off. By considering both false
positives and false negatives, it provides a balanced evaluation. A high F1 score
denotes a model that excels in both precision and recall. Equation(11) shows
F1-Score calculation.
2 × P recision × Recall
F 1Score = (11)
P recision + Recall

5.3 Model Selection and Development:

During this stage, a thoughtful process was undertaken to choose machine learn-
ing algorithms capable of effectively handling the intricacies associated with
crop recommendation in agricultural settings. Each selected algorithm brings
distinct advantages and capabilities that enhance the overall efficiency of the
crop recommendation system. Through the integration of multiple algorithms in
an ensemble approach,SmartzAgri can utilize the combined expertise of diverse
models, ensuring precise and dependable crop recommendations customized to
the unique requirements of farmers.Table 2. represents the training dataset uti-
lized for model training. Four specific algorithms were selected based on their
individual strengths and appropriateness for the given task:

Random-Forest Classifier Random Forest was selected for its robustness and
ability to handle large-scale datasets with high dimensionality. As an ensemble
learning method, Random Forest constructs multiple decision trees during train-
ing and aggregates their predictions to produce a more accurate and stable result.
This method proves exceptionally beneficial for crop recommendation endeav-
ors, adept at capturing intricate connections between soil attributes and crop
compatibility, thus minimizing the likelihood of overfitting.The accompanying
Fig.3. illustrates the evaluation measures of the Random Forest model, includ-
ing precision, F1 score, recall, and accuracy which is 93.62%, 93.62%, 93.92%
and 93.92% respectively.

XG-Boost Classifier XGBoost, an optimized implementation of gradient boost-


ing, was chosen for its superior performance and scalability. This algorithm ex-
cels in handling diverse datasets with heterogeneous features and can effectively
address nonlinearity and interactions between variables. By iteratively improv-
ing the predictive model through gradient boosting, XGBoost can achieve high
accuracy and robustness in crop recommendation tasks, making it a valuable
addition to the model ensemble. The accompanying figure Fig.4. illustrates the
evaluation measures of the XG-Boost model, including precision, F1 score, re-
call, and accuracy which is 93.86%, 93.82%, 94.15% and 94.15% respectively.
Fig.5. illustrates the confusion matrix for the XGBOOST model which is the
best performing model among these.
Title Suppressed Due to Excessive Length 11

Fig. 3. Random Forest Classifier

Fig. 4. XG Boost Classifier


12 V.K Patel et al.

Fig. 5. Confusion Matrix of XGBoost Model


Title Suppressed Due to Excessive Length 13

Naive Bayes Classifier Naive Bayes was integrated into the model selection
phase due to its straightforwardness and effectiveness in managing categorical
data. Although it assumes feature independence, Naive Bayes frequently delivers
commendable performance and offers valuable perspectives in crop recommenda-
tion endeavors. Its computational swiftness and minimal training requirements
render it appealing, particularly in scenarios involving extensive datasets and
constrained computational capabilities. The accompanying Fig.6.. illustrates the
evaluation measures of the SVM model, including precision,F1 score, recall, and
accuracy which is 88.44%, 90.19%, 92.92% and 92.92% respectively.

Fig. 6. Naive Bayes

Support Vector Machine Support Vector Machine (SVM) was chosen for its
ability to handle high-dimensional data and nonlinear relationships. By trans-
forming the provided input data into a higher-dimensional feature space and
identifying the optimal hyperplane that separates different classes, SVM can
effectively capture complex decision boundaries and achieve high classification
accuracy. This makes SVM particularly well-suited for crop recommendation
tasks where the relationships between soil parameters and crop suitability may
be nonlinear and intricate. The accompanying Fig.7. illustrates the evaluation
measures of the SVM model, including precision, F1 score, recall, and accuracy
which is 88.52%, 90.27%, 93.00%, and 93.00%.

Classifiers Accuracy Precision Recall F1-Score


Random Forest 93.92% 93.62% 93.92% 93.62%
XG-Boost 94.15% 93.86% 94.15% 93.82%
Naive Bayes 93.92% 88.44% 92.92% 90.19%
SVM 93.00% 88.52% 93.00% 90.27%

Table 3. Comparitive evaluation metrics analysis of different classifiers


14 V.K Patel et al.

Fig. 7. Support Vector Machine

Fig. 8. Comparision of all models


Title Suppressed Due to Excessive Length 15

5.4 Model Evaluation and Comparative Analysis:

To evaluate the efficacy of the trained models, various evaluation metrics were
employed, including accuracy, precision, recall, and F1-score. Rigorous cross-
validation techniques were implemented to assess the model’s generalization ca-
pacity and mitigate potential overfitting issues. Comparative analyses were con-
ducted to discern the performance disparities between different algorithms and
ascertain the most effective approach for crop recommendation in agricultural
contexts. Table 3. depicts a comparison of metrics for different classifiers, reveal-
ing that XG Boost achieved the highest performance measure.Fig.8. illustrates
a plot representation of all the models.

5.5 Web Platform Development:

The web platform for SmartzAgri was meticulously crafted using a combination
of modern web technologies to ensure scalability, performance, and intuitive user
interaction.Fig.9. displays the cover page of our web application. Fig.10. displays
the data input form of our web application.Fig.11. showcases the result of the
recommended crop.

Fig. 9. Cover Page of SmartzAgri.

Programming Languages: JavaScript (Node.js):Leveraging Node.js, a server-


side JavaScript runtime environment, proved pivotal in crafting scalable and
high-performing web applications. Its versatility allows for both client side and
server-side scripting, facilitating full stack development with a unified language.
Python: Python played a pivotal role in implementing machine learning algo-
rithms to predict crop recommendations based on soil data. Its extensive libraries
for data analysis and machine learning make it an ideal choice for such imple-
mentations.
16 V.K Patel et al.

Frameworks: Express.js: Renowned as a minimalist web application framework


designed for Node.js, Express.js offers formidable capabilities for constructing
web servers and APIs. Its straightforwardness simplifies routing, middleware uti-
lization, and HTTP request management, thereby accelerating the development
workflow.

Templating Language: EJS (Embedded JavaScript): EJS, a templating lan-


guage, facilitated the generation of HTML markup with JavaScript. Its dynamic
content rendering on the server side enabled the creation of dynamic web pages
with reusable components.

Frontend Technologies: HTML (Hypertext Markup Language): HTML served


as the standard markup language for structuring web pages and applications,
defining their layout and content.
CSS (Cascading Style Sheets): CSS enhanced the visual presentation and user
interface of web pages by styling HTML elements, allowing for customization of
colors, fonts, layouts, and other design aspects.
JavaScript: JavaScript enriched web pages with interactivity and dynamic
behavior, enabling features suchas form validation, animations, and event han-
dling.

Database: MongoDB: MongoDB, a NoSQL database, was utilized for stor-


ing crop data in a flexible and scalable manner. Its document-oriented storage
accommodated varying data structures and large datasets efficiently, ensuring
scalability and performance.

Architecture: The architecture of the SmartzAgri web application adheres to


a client server model, where the client (web browser) interacts with the server to
request and receive data. The backend server, powered by Node.js and Express.js,
handles HTTP requests, processes data, interacts with MongoDB, and serves dy-
namic web pages generated using EJS templates. The frontend interface, built
with HTML, CSS, and JavaScript, offers users an intuitive and interactive ex-
perience for inputting soil data and viewing crop recommendations.

Features: User Interface: The web application boasts a user-friendly interface


for inputting soil data, encompassing parameters such as nitrogen, phosphorus,
potassium, pH level, rainfall, and temperature. Users can effortlessly navigate
the interface to provide relevant information necessary for crop recommendation.
Crop Recommendation: Upon submitting soil data, the backend leverages
Python based machine learning algorithms to predict suitable crops based on
soil quality and health. The final recommendations are then displayed to users,
empowering them to make informed decisions regarding crop selection.
Title Suppressed Due to Excessive Length 17

Database Integration: MongoDB seamlessly integrates into the backend for


secure storage of crop data.This integration facilitates efficient data management
and retrieval, ensuring the scalability and reliability of the application.
Dynamic Rendering: EJS templates dynamically render HTML content on
the server side, enabling thegeneration of dynamic web pages based on server-
side data. This dynamic rendering enhances the responsiveness and usability of
the application, providing users with real time updates and feedback.

Fig. 10. Data Input form of SmartzAgri.

Fig. 11. Presenting the suggested crop utilizing SmartzAgri.


18 V.K Patel et al.

5.6 IoT Integration:


IoT-based solutions leverage the power of connected devices and sensors to col-
lect, transmit, and analyze soil data in real-time. These solutions encompass a
network of sensor nodes deployed throughout agricultural fields, which continu-
ously monitor soil conditions and transmit data to a central hub for analysis. By
harnessing IoT technologies such as wireless communication, and data analytics,
farmers gain unprecedented insights into soil health and nutrient levels, enabling
data-driven decision-making and precision agriculture practices.
The implementation of IoT-based soil nutrient monitoring systems in SmartzA-
gri aims to achieve several key objectives:
- Real-time Data Collection
- Precision Agriculture
- Enhanced Decision-making
- Sustainability
The implementation of IoT-based soil nutrient monitoring systems offers sev-
eral expected benefits for farmers and agricultural productivity:
- Increased Yield
- Cost Savings
- Resource Efficiency
- Risk Mitigation

5.7 IoT System Integration:


IoT-based solutions leverage the power of connected devices and sensors to col-
lect, transmit, and analyze soil data in real-time. These solutions encompass a
network of sensor nodes deployed throughout agricultural fields, which continu-
ously monitor soil conditions and transmit data to a central hub for analysis.

Description of the Overall System Architecture: The IoT-based soil mon-


itoring system architecture consists of 3 main layers: the sensing layer, the com-
munication layer, and the application layer.
1. Sensing Layer: This layer includes sensor nodes deployed throughout agri-
cultural fields to monitor soil conditions, which are equipped with various
sensors such as moisture sensors, temperature sensors, and soil NPK sen-
sors. Their purpose is to collect the data on soil parameters and transmit it
wirelessly to the central hub for analysis.
2. Communication Layer:The communication layer enables data transmis-
sion between sensor nodes and the central hub. Wireless transceiver modules
like the NRF2401 are employed to establish communication links between
nodes and the hub.
3. Application Layer: It consists of the central hub and data analysis plat-
forms where soil data is aggregated, processed, and analyzed. Data from
these platforms are sent to our site frontend, which leverages machine learn-
ing algorithms and data visualization techniques to derive insights from soil
data and provide actionable recommendations to farmers.
Title Suppressed Due to Excessive Length 19

Components Involved in the IoT- based Soil Monitoring System:

1. Sensor Nodes: Throughout the field, sensor nodes are deployed to monitor
soil conditions.
2. NRF2401 Wireless Transceiver Module: The NRF2401 wireless transceiver
module serves as the backbone of communication, facilitating wireless links
between sensor nodes and the central hub, ensuring smooth data transmis-
sion.
3. Central Hub: The central hub serves as the gateway for receiving data
from sensor nodes and forwarding it to data analysis platforms.
4. Cloud-based Servers or Local Databases: Soil data collected by the sen-
sor nodes is stored and processed in cloud-based servers or local databases.
These platforms provide scalable storage and computing resources for data
processing.

Implementation of NPK Sensor: Integrating advanced JXCT Soil NPK sen-


sors offers precise analysis of soil nutrient levels, focusing on nitrogen, phospho-
rus, and potassium. To read NPK data, a Modbus Module such as RS485/MAX485
is essential. This module connects to both the microcontroller and the sensor,
operating within a voltage range of 9-24V. With accuracy levels reaching up to
2%, and a resolution of 1mg/kg (mg/l) for nitrogen, phosphorous, and potas-
sium measurements, this sensor ensures reliable and detailed soil nutrient anal-
ysis.Fig.12.(A) represents Soil NPK sensor connected with RS485 MODBUS
module.[18]

Fig. 12. Components Involved in the IoT- based Soil Monitoring System
20 V.K Patel et al.

Implementation of Moisture Sensor:

1. Utilizing an Analog capacitive soil moisture sensor, we gauge soil moisture


levels through capacitive sensing, where capacitance alters with varying soil
moisture. The presence of water content influences capacitance fluctuations.
2. These sensors convert capacitance into voltage levels ranging from 1.2V to
a maximum of 3.0V. Crafted from corrosion-resistant materials, they offer
enduring service. Operating within 3.3V to 5.5V DC voltages, they connect
to the Arduino board’s Analog input, providing Analog output up to 3V,
convertible to a percentage value.Fig.12.(C) represents Soil moisture sensor
connected with analogy input of Arduino.[18]

Implementation of Temperature Sensing Sensor: In similar way, the tem-


perature sensor(DS18B20) which is waterproof also can be connected to the Ar-
duino board as this sensor has the ability to measure the temperature ranging
from -55°C to 125°C(-67°F to +257°F) and features a PVC jacketed cable. These
temperature sensors which are digital and 1-wired also offer high precision, with
an accuracy of approximately ±0.5°C across a wide temperature range.

Implementation of ESP32 WiFi Modules for Data Transmission

1. The IoT-based soil monitoring system relies on NRF2401 wireless transceiver


modules for establishing wireless communication between sensor nodes and
the central gateway.
2. In addition to NRF2401 modules, ESP32 WiFi modules are integrated into
the system to leverage WiFi connectivity. They enable high-speed data trans-
mission and connectivity to local WiFi networks, enhancing the overall mon-
itoring system. The data sent to the Gateway by the Sensor nodes are up-
loaded by it on the cloud-storage platforms.Fig.12.(B) representsNRF2401
wireless Transceiver module connected with ESP32 WIFI module.[18]

Overall System Implementation:

1. Hardware Setup: For Hardware setup follow these steps Start assembling
the circuit by addressing the following circuit diagram. Fig.12.(B). & Fig.13.
We have illustrated the comprehensive circuit diagram and the schematic
representation of the IoT device in Fig.14. & Fig.15. through TinkerCad
platform.
– Mount the Soil NPK Sensor, Temperature Sensor, and Capacitive Soil
Moisture Sensor on the respective sensor nodes.
– Establish connections between the sensors and Arduino Board, and be-
tween the ESP32 WiFi Module and Wireless Transceiver Module(NRF24L01)
for the central gateway.
Title Suppressed Due to Excessive Length 21

– Ensure proper power supply connections and ground connections for all
components to prevent electrical issues.
– Refer to the following connections:
• For Sensor Node: Connect NRF24L01 to Arduino Nano Board as
follows:
∗ VCC of NRF24L01 → Arduino’s input 3.3V
∗ MOSI of NRF24L01 → Arduino’s input D11
∗ CSN of NRF24L01 → Arduino’s input D10
∗ GND of NRF24L01 → Arduino’s input GND
∗ MISO of NRF24L01 → Arduino’s input D12
∗ SCK of NRF24L01 → Arduino’s input D13
∗ CE of NRF24L01 → Arduino’s input D9
• For Central Gateway: Connect NRF24L01 to ESP32 WiFi Module
as follows:
∗ VCC of NRF24L01 → ESP32’s input 3.3V
∗ MOSI of NRF24L01 → ESP32’s input D23
∗ CSN of NRF24L01 → ESP32’s input D5
∗ GND of NRF24L01 → ESP32’s input GND
∗ MISO of NRF24L01 → ESP32 input D19
∗ CE of NRF24L01 → ESP32 input D4
∗ SCK of NRF24L01 → ESP32 input D18

Fig. 13. Circuit implementation on Tinker-cad

2. Software Configuration: Follow the following steps for the Installation and
Configuration of Necessary Software Libraries to Arduino IDE:
(a) Download and install the required software libraries for Arduino and
ESP32 development environments.
(b) Include libraries for NRF24L01 Library, RH24 Library, One Wire Li-
brary, and Dallas Library.
22 V.K Patel et al.

Fig. 14. Sensors Node Circuit

Fig. 15. Schematic diagram of sensors and adruino


Title Suppressed Due to Excessive Length 23

(c) Configure library settings as per the documentation to ensure compati-


bility with the hardware setup.
3. Programming Arduino and ESP32 Modules for Sensor Data Acquisition and
Transmission:
(a) The section dedicated to monitoring, analyzing, and testing soil nutrient
levels through IoT technology comprises two distinct code segments.
(b) One segment is designated for the Transmitter/Node, necessitating code
upload to the Arduino IDE. The complementary segment pertains to the
Receiver/Gateway, necessitating code upload to the ESP32 Board.
(c) Code for Transmitter: Develop the required transmitter code for the
Sensor Node and then upload that code onto the Arduino Nano Board.
(d) Code for Receiver: For the Gateway/Receiver, upload the correspond-
ing code to the ESP32 Board. Before the upload, ensure to modify the
WiFi SSID with the Password in the designated line. Additionally, prop-
erly manage API Keys within the code; these keys are vital for estab-
lishing connections to cloud storage servers.
String apiKey = "*********";

Once the updation of the WiFi credentials is complete, proceed to upload


the code to the ESP32 WiFi Module.
(e) And with that, you can upload your data to any cloud servers, for ex-
ample, in Thingspeak. Create an account and a new channel, then copy
the API key from there and put it in the Arduino code for connection.

6 Deployment:

Subsequently, the IoT device will test the soil sample, analyze the soil, and
transfer the data to the Web platform where ML models will be available and
are harmoniously incorporated, it will receive the soil data and will analyze on
the integrated Machine Learning model and personalized crop recommendations
in real-time. User feedback and usability testing were conducted iteratively to
gauge the system’s effectiveness and user-friendliness, thereby ensuring optimal
user experience. Continuous monitoring and updates were undertaken to up-
hold the system’s reliability and accuracy, aligning with the dynamic nature of
agricultural environments and practices.

7 Conclusion:

In conclusion, SmartzAgri represents a significant advancement in agricultural


technology, leveraging the integration of Internet of Things (IoT), machine learn-
ing (ML), and web development to address key challenges faced by farmers.
Through the deployment of IoT enabled soil analysis and ML algorithms ,SmartzA-
gri facilitates real time soil health monitoring and precise crop recommenda-
tions,empowering farmers to make informed decisions and optimize crop yields.
24 V.K Patel et al.

The successful implementation of SmartzAgri demonstrates its potential to


revolutionize crop cultivation practices, enhance productivity, and promote sus-
tainability in agriculture. By harnessing the power of technology, SmartzAgri
offers a practical solution to the complex and multifaceted issues confronting
the agricultural sector.

8 Future Scope:
In the coming future, we will strive to advance SmartzAgri in various fields,
including:

1. Expansion of Crop Database: Continuously expand and update the crop


database to cover a broader range of crops and geographical regions, ensuring
the applicability of SmartzAgri across diverse agricultural settings.
2. Integration of Advanced Sensing Technologies: Incorporate advanced
sensing technologies, such as remote sensing and hyperspectral imaging, to
enhance soil analysis and crop monitoring capabilities. This will enable more
comprehensive and accurate assessments of crop health and environmental
conditions.
3. Enhancement of Machine Learning Models: Further refine and opti-
mize machine learning (ML) algorithms to improve the accuracy and robust-
ness of crop recommendation systems. This involves leveraging advancements
in deep learning and ensemble learning techniques.
4. Implementation of Precision Agriculture Techniques: Explore the in-
tegration of precision agriculture techniques, such as variable rate technology
and precision irrigation. This aims to enable targeted and efficient resource
management, leading to optimized crop production and resource utilization.
5. User Interface Enhancements: Enhance the user interface of the SmartzA-
gri platform to improve accessibility, usability, and user engagement. This
includes incorporating features such as interactive data visualization, per-
sonalized recommendations, and mobile compatibility.
6. Collaboration and Knowledge Sharing: Foster collaboration with agri-
cultural research institutions, government agencies, and industry stakehold-
ers. This collaborative effort aims to facilitate knowledge sharing, data ex-
change, and the widespread adoption of SmartzAgri technologies.

By embracing these future directions, SmartzAgri can continue to evolve as a


pioneering solution in agritech, driving innovation, sustainability, and prosperity
in the agricultural sector.

9 Acknowledgement:
We would like to express our heartfelt gratitude to the IEM Centre of Excellence
for Cloud Computing and IoT for invaluable support and resources from IEM
Grant in Aid project of Dr. Deepsubhra Guha Roy, which have enabled us to
Title Suppressed Due to Excessive Length 25

conduct this review. We are also deeply thankful to the IEDC-CSE of Institute
of Engineering & Management, Kolkata, for providing us the work space that
made this work possible. ’

10 References:
1. Babber, J.; Malik, P.; Mittal, V.; Purohit, K.C. Analyzing Supervised Learn-
ing Algorithms for Crop Prediction and Soil Quality. In Proceedings of the
6th International Conference on Computing Methodologies and Communi-
cation (ICCMC), Erode, India, 29–31 March 2022; pp. 969–973.
2. Ishak, M.; Rahaman, M.S.; Mahmud, T. FarmEasy: An Intelligent Platform
to Empower Crop Prediction and Crop Marketing. In Proceedings of the 13th
International Conference on Information & Communication Technology and
System (ICTS), Surabaya, Indonesia, 17–20 April 2021; pp. 224–229.
3. Patel, K.; Patel, H.B. A Comparative Analysis of Supervised Machine Learn-
ing Algorithm for Agriculture Crop Prediction. In Proceedings of the Fourth
International Conference on Electrical, Computer and Communication Tech-
nologies (ICECCT), Erode, India, 15–17 September 2022; pp. 1–5.
4. Yamparla, R.; Shaik, H.S.; Guntaka, N.; Marri, P.; Nallamothu, S. Crop
Yield Prediction using Random Forest Algorithm. In Proceedings of the
7th International Conference on Communication and Electronics Systems
(ICCES), Coimbatore, India, 22–24 June 2022; pp. 1538–1543.
5. Chandraprabha, M.; Dhanaraj, R.K. Soil Based Prediction for Crop Yield
using Predictive Analytics. In Proceedings of the 3rd International Confer-
ence on Advances in Computing, Communication Control and Networking
(ICAC3N), Greater Noida, India, 17–18 December 2021; pp. 265–270.
6. Elbasi, E.; Zaki, C.; Topcu, A.E.; Abdelbaki, W.; Zreikat, A.I.; Cina, E.;
Shdefat, A.; Saker, L. Crop Prediction Model Using Machine Learning Al-
gorithms. Appl. Sci. 2023, 13, 9288. https://doi.org/10.3390/app13169288
7. Vijo T Varghese, Kalyan Sasidhar, Rekha P, "A Status Quo of WSN Sys-
tems for Agriculture", International Conference on Advances in Computing,
Communications and Informatics (ICACCI), IEEE, 2015.
8. Memon, R.; Memon, M.; Malioto, N.; Raza, M.O. Identification of growth
stages of crops using mobile phone images and machine learning. In Proceed-
ings of the International Conference on Computing, Electronic and Electrical
Engineering (ICE Cube), Quetta, Pakistan, 26–27 October 2021; pp. 1–6.
9. Aruul Mozhi Varman S, Arvind Ram Baskaran, Aravindh S, Prabhu, "Deep
Learning and IoT for Smart Agriculture Using WSN”, IEEE International
Conference on Computational Intelligence and Computing Research, 2017.
10. R. Ramya, C.Sandhya, R. Shwetha, "Smart farming system using sensors",
IEEE International Conference on Technological Innovations in ICT For
Agriculture and Rural Development, 2017.
11. Giritharan Ravichandran, Koteeshwari R S, "Agricultural crop predictor
and advisor using ANN for smartphones”, IEEE International Conference
on Emerging Trends in Engineering, Technology and Science (ICETETS),
2016.
26 V.K Patel et al.

12. Thomas van Klompenburg, Ayalew Kassahun, Cagatay Catal, Crop yield
prediction using machine learning: A systematic literature review, Comput-
ers and Electronics in Agriculture, Volume 177, 2020, 105709, ISSN 0168-
1699, https://doi.org/10.1016/j.compag.2020.105709.
13. Umair Ayub, Syed Atif Moqurrab, "Predicting crop diseases using data min-
ing approaches: classification", IEEE 1st International Conference on Power,
Energy and Smart Grid (ICPESG), 2018.
14. Rekha P, Maneesha V. Ramesh, Venkata Prasanna Rangan, Nibi K V, "High
yield groundnut agronomy: An IoT based precision farming framework",
IEEE, 2017.
15. P. Kanaga Priya and N. Yuvaraj 2019 J. Phys.: Conf. Ser. 1362 012038
16. Belete, Tegegn & Yadete, Eshetu. (2023). Effect of Mono Cropping on Soil
Health and Fertility Management for Sustainable Agriculture Practices: A.
192-197, 10.11648/j.jps.20231106.13.
17. https://www.kaggle.com/datasets/atharvaingle/crop-recommendation-dataset
18. https://how2electronics.com/iot-based-soil-nutrient-monitoring-with-arduino-
esp32
19. Arduino UNO And NPK Sensor Project - Makerguides.com
20. https://arduino-tutorials.net/tutorial/capacitive-soil-moisture-sensor-arduino
21. Sinha, S. et al. (2023). Deep Learning-Based Identification of Vegetable
Species: System for Specially Abled Persons. In: Bhateja, V., Yang, XS.,
Lin, J.CW., Das, R. (eds) Evolution in Computational Intelligence. FICTA
2022. Smart Innovation, Systems and Technologies, vol 326. Springer, Sin-
gapore, https://doi.org/10.1007/978-981-19-7513-43 6.
Declaration of Interest Statement

Declaration of interests

☐The authors declare that they have no known competing financial interests or personal relationships
that could have appeared to influence the work reported in this paper.

☒The authors declare the following financial interests/personal relationships which may be considered
as potential competing interests:

Deepsubhra Guha Roy reports financial support and administrative support were provided by Institute
of Engineering & Management. Deeppsubhra Guha Roy reports a relationship with Institute of
Engineering & Mangement that includes: employment. If there are other authors, they declare that
they have no known competing financial interests or personal relationships that could have appeared
to influence the work reported in this paper.

You might also like