Professional Documents
Culture Documents
FinalReport IOT Agriculture
FinalReport IOT Agriculture
A PROJECT REPORT
Submitted by
ABISHA A
AKHILA S ANIL
ASWATHY S
NISHA A
of
BACHELOR OF ENGINEERING
in
APRIL 2020
ANNA UNIVERSITY::CHENNAI 600 025
BONAFIDE CERTIFICATE
Certified that this project report “AN IOT APPROACH FOR AGRICULTURE
SIGNATURE SIGNATURE
Submitted for B.E. Degree Project Work (EC6811) viva-voce examination held at
Sivaji College of Engineering and Technology, Manivila on ________.
ACKNOWLEDGEMENT
The honor be to the Lord Almighty, source of all knowledge for gracious
presence and blessings, that enabled us to complete this project in due time.
Words can never express our gratitude to fullest extent when it comes to
thanking Mr. Kiran W, M. E. (Ph. D.), Head of the Department, for his valuable
guidance, suggestions and encouragement in all aspects to complete this project
successfully.
It is our privileges to express our sincere thanks to our Project guide Ms.
Sajini S, M. E., for her valuable suggestions and guidance in preparation of the
report.
க்கம்
அைம ற .
iv
ABSTRACT
higher especially for IoT and wireless sensors, these can be integrated well with
our traditional farming practices to yield more result and enhance its quality.
known by the farmers and can control them without going directly to the
agricultural land. We propose a system which uses wireless sensors for monitoring
various parameters that affect the plant growth and for controlling the irrigation
system which is integrated with IoT connectivity. In the proposed system, sensed
information can be saved and can be used for future use with the help of webpage
service. The irritation is provided based on the soil moisture level. This system also
provides disease identification using MATLAB. This system put forward various
provision. Use of latest technology and low cost, easy to operate system make it
TABLE OF CONTENTS
ABSTRACT iv
LIST OF ABBREVIATIONS x
1 INTRODUCTION 1
1.1 GENERAL 1
1.2 OBJECTIVE 1
2 LITERATURE REVIEW 3
3 PROPOSED SYSTEM 13
3.2.1 Hardware 15
3.2.1.2 DHT11 17
3.2.1.5 Relay 23
3.2.2 Software 28
3.2.2.2 MATLAB 29
3.3.1 Module 1 29
3.3.2 Module 2 31
3.5 ALGORITHM 33
3.6 FLOWCHART 34
4.1 CONCLUSION 40
APPENDIX 41
REFERENCES 54
vii
LIST OF TABLES
Arduino UNO
DHT11
Soil pH meter
Relay
Node MCU
viii
LIST OF FIGURES
3.15 Flowchart 34
LIST OF ABBREVIATIONS
ABBREVIATIONS EXPANSION
CHAPTER 1
INTRODUCTION
1.1 GENERAL
Smart agriculture is a combination of Big data, Cloud, IoT which
does tracking, automating, monitoring and analyzing. Trend of urbanization
lead to high food demand and decreasing farmland lead to production of
food in smaller area with few labors. Digitization of agriculture made that
easier by services such as connectivity network, data acquisition, Cloud-
based intelligent information analysis and user interfacing. Combination of
advanced and traditional methods enables to produce food of high quality
and quantity. Smart agriculture forms a network called Farm Area Network
(fan).
Recent sensing and communication technologies are like ‘eye in
the field’. This system provides real time monitoring, disease forecasting by
leaf analysis, automatic controlling, Cloud storage, Wi-Fi connection to
farm. It can cope with climate change effects by use of humidity,
temperature sensor and environmental pollution, salinization, acidification,
drought by use of pH and soil moisture sensor.
1.2 OBJECTIVE
The main objective of this project is to monitor the
environmental conditions, controlling irrigation and identifying the plant
diseases at its early stage even without directly going to farmland.
2
CHAPTER 2
LITERATURE REVIEW
WSNs are used to collect the interest data in the farm field and
send the obtained data to the servers via wireless communication. Since the
WSNs usually operate in the unlicensed spectrum, the available resource
elements (REs) are scarce especially when a large number of sensor nodes
are deployed in the farm field. To accommodate more sensor nodes and
prolong the lifetime of the WSNs in agriculture, relay-aided non-orthogonal
multiple access is introduced into the uplink transmission stage of the direct
transmission from the sender nodes to the sink node.
It introduced relay aided NOMA into the uplink transmission in
WSNs in agriculture. For periodic and busty short -range uplink
transmission, NOMA technique is able to accommodate more sensor nodes
with the same number of the REs. A mixed transmission scheme including
both uplink and downlink transmission has been proposed for WSNs in
agriculture, in which OMA is applied in downlink transmission and relay-
aided MONA scheme is employed in uplink transmission. Numerical
simulation results have shown that WSNs with relay-aided NOMA achieves
lower outage probability, higher sum data rate, reduce the power
consumption and prolong the lifetime of the networks, which shows that
NOMA technique can be competitive candidate in both uplink and downlink
transmission for WSNs in agriculture.
5
The paper aims at making use of evolving technology that is, IoT
and smart agriculture using automation. Monitoring environmental
conditions is the major factor to improve yield of the efficient crops. The
feature of this system is to monitor temperature, humidity, moisture and
even the movement of animals which may destroy the crops in agricultural
field through sensors using Arduino board and in case of any discrepancy
send a SMS notification as well as notification on the application developed
for the same to the farmer’s Smartphone using Wi-Fi or 3G or 4G.
The system has a duplex communication link based on a
Cellular – Internet interface that allows for data inspection and irrigation
scheduling to be programmed through an Android application. Because of its
energy autonomy and low cost, the system has the potential to be useful in
water limited geographically isolated areas.
Threshold values for climatic conditions like humidity,
temperature, moisture can be fixed based on the environmental conditions of
that particular region. They generates irrigation schedule based on the sensed
real time data from field and data from the weather repository.
9
Smart farm system using low power Bluetooth and Low Power
Wide Area Networks (LPWAN) communication modules including the
wired communication network used in the existing farm was constructed. In
addition, the system implements the monitoring and control functions using
the MQ Telemetry Transport (MQTT) communication method, which is a
IoT dedicated protocol, thereby enhancing the possibility of development of
agricultural IoT.
This system solves the power problem and space limitation of
wired system. By applying a solution of selecting the most received words
for each word by cutting the message to word size, reduced the bit loss that
occur in wireless communication.
Environmental data are collected through the sensors on the
node. The gateways responsible for each communication network are
connected to the Internet and relay the communication between the server
and the nodes. The communication module supports Ipv6 address system
and Bluetooth communication. RS485 is used as wired serial communication
module. Thus implementing a hybrid wired or wireless system with node –
server – database and external control system.
13
CHAPTER 3
PROPOSED SYSTEM
3.2.1 Hardware
Microcontroller : ATmega328p
Operating voltage : 5V
Input voltage : 7-12V (recommended), 6-20V (limits)
DC current per I/O pin : 40mA
DC current for 3.3V : 50mA
Storage : Flash (32KB), EEPROM (1KB)
Memory : SRAM (2KB)
Clock speed : 16MHz
16
3.2.1.2 DHT11
Features of DHT11
The pork shaped probe with two exposed conductors, act as a variable
resistor whose resistance varies according to the water content in the soil. Two
probes allow current to pass through soil, gets resistance value to measure
moisture. This resistance is inversely proportional to the soil moisture. The more
water in the soil, means better conductivity and will result in a lower resistance.
The less water in the soil means poor conductivity and will result in a higher
resistance.
The sensor also contains a control board that connects the probe to the
Arduino. The module produces an output voltage according to the resistance of the
probe and is made available at an analog output (A0) pin. The signal is fed to
LM393 high precision comparator to digitize it and is made available at an digital
output (D0) pin. We can set threshold by using a potentiometer, so that when the
moisture level exceeds the threshold value, the module will output LOW otherwise
20
HIGH. The Power LED will light up when the module is powered. The Status LED
will light up when the digital output goes low.
3.2.1.5 Relay
Features of Relay
1 IN Carries the trigger signal from Arduino that A digital I/O pin
activates the relay
4 +V Supplies power 5V
26
3.2.2 Software
3.2.2.2 MATLAB
3.3.1 Module 1
proper contact with the atmosphere. The pH and soil moisture sensor are used for
monitoring pH and moisture content of the soil and are placed in contact with soil.
Water content in the soil is important factor because for the plants
excess of water can produce a fungal infection at the same time, plants with less
water becomes dry or sometimes they may get damaged. Soil moisture changes
with temperature, soil type and electrical conductivity. Soil pH readings can help
us find the efficiency or deficiency of pesticide or fertilizers thus avoiding
unnecessary usage of fertilizers.
behind this is that the data needs to be monitored by visiting a website or URL.
Whereas, in GSM based system, the parameters are sent using GSM via SMS.
3.3.2 Module 2
1. Image Acquisition
2. Image Pre-Processing
The acquired image is pre-processed to enhance the quality of
the image for efficient segmentation. In the pre-processing phase, the image is
resized and the contrast of the image is enhanced. The RGB to HSI (Hue
Saturation Intensity) transformation is carried out on the enhanced image as it can
be easily segmented from the HSI transformed image rather than the RGB image.
3. Image Segmentation
Image segmentation is the third step in our proposed method.
The segmented images are clustered into different sectors using k-mean clustering
algorithm. Before clustering the images, the RGB color model is transformed into
Lab color model.
K-means Clustering Algorithm:-
a) Load the input images.
32
4. Feature Extraction
In the proposed DDS feature extraction is carried out based on
the texture analysis. The gray level co-occurrence matrix (GLCM) is used to obtain
the statistical texture features. Contrast, energy, homogeneity, entropy and
correlation are some of the texture based features extracted from the segmented
image.
5. Classification of Disease
The features based on texture are analyzed and the classification
is carried out using the SVM classifier. SVM is commonly used for classification
process and belongs to the group of supervised learning. Supervised learning
makes use of the training dataset to predict the testing dataset. SVM yields high
accuracy when used with texture features. SVM makes use of the linear kernel
function to classify the healthy leaves and diseased leaves.
From the database, the images of leaves are taken, converted
to MDL file and are analyzed using MATLAB software by use of image
processing. Thus the output whether leaves are affected with a disease is found.
Here the disease name and its percentage of affected area are also shown. The
disease is shown via webpage for monitoring purpose.
33
3.5 ALGORITHM
The working of the “An IoT approach for agriculture management based
on controlling and monitoring system” can be explained with the following steps:
1. START
2. Detect the environmental parameters
3. Check the conditions
34
3.6 FLOWCHART
1. As all the data are continuously saved on the webpage, the new
agriculture methods have become data centered, precise and a
smarter method.
35
CHAPTER 4
Fig 3.19 Input test image, Preprocessed image and Segmented image of the
diseased pomegranate leaves
SVM classifier is used which has the database with trained images for
classification.
4.1 CONCLUSION
APPENDIX
#include<dht.h>
dht DHT;
#define DHT11_PIN 2
int soilpin(A0);
int d[5];
String link_dat;
int relay1=9;
int relay2=8;
int i=0;
void setup (){
Serial.begin(9600); }
void loop(){
int soilvalue=analogRead(soilpin);
int chk = DHT.read11(DHT11_PIN);
int temp =DHT.temperature;
int hum =DHT.humidity;
if(DHT.temperature>30&&DHT.temperature<40){
digitalWrite(relay2,LOW); }
else{
digitalWrite(relay2,HIGH);}
if(soilvalue>500&&soilvalue<800){
digitalWrite(relay1,LOW);}
else{
digitalWrite(relay1,HIGH);}
42
if (Serial.available()>0){
for(i=0;i<5;i++) {
d[i]=Serial.parseInt(); }}
link_dat =String(temp)+','+String (hum)+','+String(soilvalue)+','+String(d[0]);
delay(1000);
Serial.println( link_dat);}
#include "ESP8266WiFi.h"
const char* ssid = "iotdata" ;
const char* password = "123456789";
const char* host = "www.iotwebdata.com";
String line="";
int l1 = 16;
int l2 = 5;
int Sensor_1_value;
int Sensor_2_value;
int Sensor_3_value;
int Sensor_4_value;
void setup(){
pinMode(16, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(16,HIGH);
digitalWrite(5, HIGH);
Serial.begin(9600);
Serial.println();
Serial.print("Connecting to ");
43
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.print("."); }
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP()); }
void loop(){
readbutton();
if (Serial.available()>1) {
String message=Serial.readString();
int v=message.length();
int cindex=message.indexOf(',');
String svalue=message.substring(0,cindex);
Sensor_1_value=svalue.toInt();
Serial.println(Sensor_1_value);
message=message.substring(cindex+1,v);
cindex=message.indexOf(',');
svalue=message.substring(0,cindex);
Sensor_2_value=svalue.toInt();
Serial.println(Sensor_2_value);
message=message.substring(cindex+1,v);
cindex=message.indexOf(',');
svalue=message.substring(0,cindex);
Sensor_3_value=svalue.toInt();
44
Serial.println(Sensor_3_value);
svalue=message.substring(cindex+1,v);
Sensor_4_value=svalue.toInt();
Serial.println(Sensor_4_value);
message=" ,";
delay(3000);
post(); }}
void post() {
Serial.print("connecting to ");
Serial.println(host);
WiFiClient client;
const int httpPort = 80; if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return; }
String url = "/upload.php?id=nt1lrihe";
url +="&data1=";
url += String(Sensor_1_value);
url +="&data2=";
url += String(Sensor_2_value);
url +="&data3=";
url += String(Sensor_3_value);
url +="&data4=";
url += String(Sensor_4_value);
Serial.print("Requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
45
nColors = 3;
[cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...
'Replicates',3);
%[cluster_idxcluster_center]=kmeans(ab,nColors,'distance','sqEuclidean','Replicat
es',3);
% Label every pixel in tha image using results from K means
pixel_labels = reshape(cluster_idx,nrows,ncols);
%figure,imshow(pixel_labels,[]), title('Image Labeled by Cluster Index');
% Create a blank cell array to store the results of clustering
segmented_images = cell(1,3);
% Create RGB label using pixel_labels
rgb_label = repmat(pixel_labels,[1,1,3]);
for k = 1:nColors
colors = I;
colors(rgb_label ~= k) = 0;
segmented_images{k} = colors;
end
figure,subplot(3,1,1);imshow(segmented_images{1});title('Cluster1');
subplot(3,1,2);imshow(segmented_images{2});title('Cluster 2');
subplot(3,1,3);imshow(segmented_images{3});title('Cluster 3');
set(gcf, 'Position', get(0,'Screensize'));
% Feature Extraction
x = inputdlg('Enter the cluster no. containing the ROI only:');
i = str2double(x);
% Extract the features from the segmented image
seg_img = segmented_images{i};
% Convert to grayscale if image is RGB
49
if ndims(seg_img) == 3
img = rgb2gray(seg_img);
end
%figure, imshow(img); title('Gray Scale Image');
% Evaluate the disease affected area
black = im2bw(seg_img,graythresh(seg_img));
%figure, imshow(black);title('Black & White Image');
m = size(seg_img,1);
n = size(seg_img,2);
zero_image = zeros(m,n);
%G = imoverlay(zero_image,seg_img,[1 0 0]);
cc = bwconncomp(seg_img,6);
diseasedata = regionprops(cc,'basic');
A1 = diseasedata.Area;
sprintf('Area of the disease affected region is : %g%',A1);
I_black = im2bw(I,graythresh(I));
kk = bwconncomp(I,6);
leafdata = regionprops(kk,'basic');
A2 = leafdata.Area;
sprintf(' Total leaf area is : %g%',A2);
%Affected_Area = 1-(A1/A2);
Affected_Area = (A1/A2);
if Affected_Area < 0.1
Affected_Area = Affected_Area+0.15;
end
sprintf('Affected Area is: %g%%',(Affected_Area*100))
% Create the Gray Level Cooccurance Matrices (GLCMs)
50
glcms = graycomatrix(img);
% Derive Statistics from GLCM
stats = graycoprops(glcms,'Contrast Correlation Energy Homogeneity');
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
Mean = mean2(seg_img);
Standard_Deviation = std2(seg_img);
Entropy = entropy(seg_img);
RMS = mean2(rms(seg_img));
%Skewness = skewness(img)
Variance = mean2(var(double(seg_img)));
a = sum(double(seg_img(:)));
Smoothness = 1-(1/(1+a));
Kurtosis = kurtosis(double(seg_img(:)));
Skewness = skewness(double(seg_img(:)));
% Inverse Difference Movement
m = size(seg_img,1);
n = size(seg_img,2);
in_diff = 0;
for i = 1:m
for j = 1:n
temp = seg_img(i,j)./(1+(i-j).^2);
in_diff = in_diff+temp;
end
end
51
IDM = double(in_diff);
feat_disease=[Contrast,Correlation,Energy,Homogeneity,Mean,Standard_Deviatio
n, Entropy, RMS, Variance, Smoothness, Kurtosis, Skewness, IDM];
%%
% Load All The Features
load('Training_Data.mat')
% Put the test features into variable 'test'
test = feat_disease;
result = multisvm(Train_Feat,Train_Label,test);
%disp(result);
% Visualize Results
if result == 0
helpdlg(' Alternaria Alternata ');
disp(' Alternaria Alternata ');
data=strcat('http://www.iotwebdata.com/upload.php?id=nt1lrihe&data1=&data2=
&data3=&data4=&data5=','Alternaria_Alternata');
res=urlread(data);
elseif result == 1
helpdlg(' Anthracnose ');
disp('Anthracnose');
data=strcat('http://www.iotwebdata.com/upload.php?id=nt1lrihe&data1=&data2=
&data3=&data4=&data5=','Anthracnos');
res=urlread(data);
elseif result == 2
helpdlg(' Bacterial Blight ');
disp(' Bacterial Blight ');
52
data=strcat('http://www.iotwebdata.com/upload.php?id=nt1lrihe&data1=&data2=
&data3=&data4=&data5=','Bacterial_Blight');
res=urlread(data);
elseif result == 3
helpdlg(' Cercospora Leaf Spot ');
disp('Cercospora Leaf Spot');
data=strcat('http://www.iotwebdata.com/upload.php?id=nt1lrihe&data1=&data2=
&data3=&data4=&data5=','Cercospora_Leaf_Spot');
res=urlread(data);
elseif result == 4
helpdlg(' Healthy Leaf ');
disp('Healthy Leaf ');
data=strcat('http://www.iotwebdata.com/upload.php?id=nt1lrihe&data1=&data2=
&data3=&data4=&data5=','Healthy_Leaf');
res=urlread(data);
end
%% Evaluate Accuracy
load('Accuracy_Data.mat')
Accuracy_Percent= zeros(200,1);
for i = 1:500
data = Train_Feat;
%groups = ismember(Train_Label,1);
groups = ismember(Train_Label,0);
[train,test] = crossvalind('HoldOut',groups);
cp = classperf(groups);
svmStruct =
svmtrain(data(train,:),groups(train),'showplot',false,'kernel_function','linear');
53
classes = svmclassify(svmStruct,data(test,:),'showplot',false);
classperf(cp,classes,test);
Accuracy = cp.CorrectRate;
Accuracy_Percent(i) = Accuracy.*100;
end
Max_Accuracy = max(Accuracy_Percent);
sprintf('Accuracy of Linear Kernel with 500 iterations is: %g%%',Max_Accuracy)
54
REFERENCES