CHAPTER 1
INTRODUCTION
Precision agriculture is a farming management concept based on observing, measuring
and responding to interand intra-field variability in crops. The goal of precision
agriculture research is to define a decision support system (DSS) for whole farm
management with the goal of optimizing returns on input while preserving resources. The
farmers and researchers ability to locate their precise position in a field allows for the
creationof maps of the spatial variability of as many variables as can be measured(e.g.
crop yield, terrain features/ topography, organic matter content, moisture levels, nitrogen
levels, pH, EC, Mg, K and others)
The Internet of Things is the network of physical objects outfitted with electronics that
enables data collection and aggregation. IoT comes into play with the development of
senor and farm-management software. Farmers can measure phosphorous, potassium, and
nitrogen by using sensors or spectroscopically. Moisture sensor in he soil determines the
best times to remotely water plants.
Linear Regression is a supervised machine learning algorithm where the predicted
continuous and has a constant slope. It is used to predict the values within a continuous
range, rather than trying to classify them into categories. Linear Regression uses
traditional slope-intercept form. Electrical Conductivity (EC) can be an indirect indicator
of soil nutrient concentration, and strong relationships between EC and nutrients may
help fertility management zones.
1
Deep Learning is class of Machine Learning algorithms that use multiple layers to
progressively extract higher level features from raw input. Deep learning is part of a
border family of machine learning methods based on artificial neural networks. Learning
can be supervised, semi-supervised or unsupervised. In deep learning a computer model
learns to perform classification tasks directly from images, text, or sound. Deep learning
models can achieve state-of-the-art accuracy, sometimes exceeding human-level
performance. Models are trained by using a large set of labelled data and neural network
architectures that contain many layers.
ANN is a layered approach to processing information and making decisions that ANNs
are trying to simulate. In its simplest form, an ANN can have only three layers of
neurons: the input layer (where the data enters the system), the hidden layer (where the
information is processed) and the output layer (where the system decides what to do
based on the data). But ANNs can get much more complex than that, and include multiple
hidden layers.
Deep learning represents the very cutting edge of artificial intelligence. Instead of
teaching computers to process and learn from data (which is how machine learning
works), with deep learning, the computer trains itself to process and learn from data. A
deep learning system is self-teaching, learning as it goes by filtering information through
multiple hidden layers, in a similar way to humans. Massively parallel computation
through the use of GPU scalable for large volume of data.
2
CHAPTER 2
SOFTWARE PROJECT PLAN
S.No Phases Description Time Bound Deliverables Remarks
1. Project Identification of July 2019 Abstract Identification
Initialization Project activity of project
and responsible mentor, chief
person architect and
technology
familiarization
2. Hardware Hardware July 2019 Resource Got the
Requirement Requirements are estimation hardware
documented resources.
Estimation
3. Software Software August 2019 Sensor values IoT is treated as
Requirement requirements are are measured baseline
documented
Estimation
4. Software Convert analysis August 2019 Phosphorous Activities
Development model into design estimation carried out by
model using Deep
Learning all team
members
5. Software Software is September Product Development
Deployment implemented 2019 installation carried out
3
6. Prediction Time series September Phosphorous Further
Forecasting is 2019 content is developed for
used for measured for future
Prediction future enhancement
7. Software Risk management October 2019 Risk Identification of
configuration associated potential risk
and Risk
management
8. Software Formation of October 2019 Solution for Update is done
Maintenance maintenance team the problems
and plans identified
Table 2.1 software project plan
4
CHAPTER 3
PROBLEM STATEMENT
Precision agriculture is an emerging farm management strategy that is changing the way
people farm. The key factor of soil is Phosphorous. Phosphorous is an essential nutrient
both as a part of several key plant structure compounds and as a catalysis in the
conversion of numerous key biochemical reactions in plants. Phosphorous deficiency is
more difficult to diagnose than a deficiency of nitrogen or potassium. A wide range of IoT
and Deep Learning technique is used to build a more accurate system. To measure the
phosphorus, methods available only based on lab assisted techniques and time
consuming.So we need to develop a handy method for assess the phosphorus value based
other soil parameters such as,Soil temperature, Soil humidity, Soil moisture. The deep
learning platform reads the data and predict the phosphorous content.
5
CHAPTER 4
SOFTWARE REQUIRMENTS SPECIFICATION
4.1 INTRODUCTION
4.1.1 PURPOSE
To estimate the phosphorous content in the soil
4.1.2 DOCUMENT CONVENTIONS
This document is written in the following style
Font style : Times New Roman
Chapter Headings : 14 pts
Sub-Heading : 12 pts
Sub-Section Heading : 12 pts
Description : 12 pts
4.1.3 INTENDED AUDIENCE AND READING SUGGESTION
This document is intended for the developers. This SRS contains the purpose of the
proposed method and the diagrams explained for reference. The table also included to
clearly explain the use cases and sequence of the proposed method. And also it explains
about the merits and future enhancement of the propose method
6
4.1.4 PROJECT SCOPE
The scope of the proposed system method is to estimate the phosphorous content present
in the soil using Deep Learning
4.2 OVERALL DESCRIPTION
4.2.1 PRODUCT PERSPECTIVE
A method is proposed that uses deep learning based technique to measure the
phosphorous content in the soil. Linear Regression is used to measure Electrical
Conductivity. Deep Learning (Back Propagation) is used for training and testing purpose.
Using the state of the art considerable efficiency upto 90 percentage can be achieved.
4.2.2 PRODUCT FUNCTIONS
NodeMCU Development board
DHT11 Sensor
Soil Moisture Sensor
4.2.3 OPERATING ENVIRONMENT
It is created with the help of GOOGLE COLAB . This product can be changed with this
IDE and updated version using windows OS 7, 8, 10 by any personal computer, and has
been tested for compliance with higher versions.
4.3 OTHER FUNCTIONAL REQUIREMENTS
4.3.1 Software Quality Attributes
Maintainability
It does not require maintenance.
7
Usability
Goals are easy to accomplish quickly and no user error.
Availability
There is no downtime acceptable in this proposed
method
Hardware Requirements:
•
Processor - Intel Pentium
Speed - 2.1 GHz
RAM - 4GB(min)
Hard Disk - 40 GB
Key Board - Standard Windows
Keyboard
Mouse - Two or Three
Button Mouse
Monitor - SVGA
4.3.2 HARDWARE REQUIREMENTS
4.3.2.1NodeMCU Development Board
NodeMCU is an open source IoT based firmware developed for ESP8266 Wi-Fi chip. By
exploring functionality with ESP8266 chip, NodeMCU firmware comes with ESP8266
8
Development board/kiti.e. NodeMCU Development board. Since NodeMCU is open
source platform, their hardware design is open for edit / modify / build. NodeMCU Dev
Kit/board consist of ESP8266 Wi-Fi enabled chip. The ESP8266 is a low-cost Wi-Fi chip
developed by Espressif Systems with TCP/IP protocol. For more information about
ESP8266, you can refer ESP8266 Wi-Fi Module. There is Version2 (V2) available for
NodeMCU Dev Kit i.e. NodeMCU Development Board .
Fig 4.1 NodeMCU Development Board
4.3.2.2 DHT11 Sensor
The digital temperature and humidity sensor DHT11 is a composite sensor that contains a
calibrated digital signal output of temperature and humidity. The technology of a
dedicated digital modules collection and thetemperature and humidity sensing technology
9
are applied to ensure that the product has high reliability and excellent long-term stability.
The sensor includes a resistive sense of wet component and an NTC
temperaturemeasurement device, and is connected with a high-performance 8-bit
microcontroller. DHT11 is a low-costdigital sensor. This sensor can be easily interfaced
with any micro-controller such as Arduino, Raspberry Pietc.,The temperature range of
DHT11 is from 0 to 50 degree Celsius with a 2-degree accuracy.Humidity range of this
sensor is from 20 to 80% with 5% accuracy.
Fig 4.2 DHT11 Sensor
4.3.2.3 Soil Moisture Sensor
Soil moisture is basically the content of water present in the soil. This can be measured
using a soilmoisturesensor which consists of two conducting probes that act as a probe. It
can measure the moisture content in the soil based on the change in resistance between
10
the two conducting plates.When there is more water,the soil will conduct more electricity
which means that there will be less resistance. Therefore, the moisture levelwill be higher.
Dry soil conducts electricity poorly, so when there will be less water, then the soil will
conductless electricity which means that there will be more resistance. Therefore, the
moisture level will be lower. This sensor reminds the user to water their plants and also
monitors the moisture content of soil. It has been widely used in agriculture, land
irrigation and botanical gardening.
Fig 4.3 Soil Moisture Sensor
11
CHAPTER 5
SYSTEM ANALYSIS
5.1 DATA FLOW
Fig 5.1 Data Flow Diagram
12
5.2 USECASE DIAGRAM
Fig 5.2 Usecase diagram.
13
5.3 ARCHITECTURE DIAGRAM
Fig 5.3 Architecture diagram
14
CHAPTER 6
CODING
6.1 ALGORITHM
//LINEAR REGRESSION
Step 1: Start
Step 2: Declare arrays x, y
Step3: Initialize array xx1, x2, x3,….,xn
Initializearray yy1, y2, y3,…, yn
Step 4: Plot x and y values as scatter plot
Step 5: Calculate intercept
step 6: calculate co-efficient of slope
mmean(y)-b*mean(x)
step7: calculate predicted y values
ypredmx+b
step 8: calculate error between actual y values Vs predicted y values
15
Step 9: adjust the slope coefficient to minimize RMSE error
Step 10: again find the new y predicted values
Step 11: plot the line with new predicted y values against x values
Step 12: Stop
16
6.2 PROGRAMS
6.2.1 ARDUINO
#include <dht.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiType.h>
#include <WiFiClient.h>
#include <WiFiClientSecureBearSSL.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include "ThingSpeak.h"
#include "secrets.h"
#include <ESP8266WiFi.h>
Initialize your network SSID (name)
Initialize your network password
Your network key Index number (needed only for WEP)
WiFiClient client;
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
dht DHT;
17
#define DHT11PIN 5
Initialize our values
void setup() {
Initialize serial
WiFi.mode(WIFI_STA);
Initialize ThingSpeak
void loop() {
Connect or reconnect to WiFi
If Wi-Fi is connected
Print the SSID
If it is not connected
Connect to WPA/WPA2 network. Change this line if using open or WEP network
delay(5000);
Print connected
intchk = DHT.read11(DHT11PIN);
readsoil_moisture frompin A0
read the temperature value
readthe.humidity value
18
Print the temperature
Print the humidity
Print the soil moisture
delay(1000);
set the fields with the values
write to the ThingSpeak channel
if (x == 200) {
print channel is updated successfully
else {
print there is an error
Wait 20 seconds to update the channel again
SECRET FILE
replaceMySSID with your WiFi network name
replaceMyPassword with your WiFi password
replace 0000000 with your channel number
replace XYZ with your channel write API Key
19
6.2.2 LINEAR REGRESSION
fromsklearn.linear_model import LinearRegression
fromsklearn.model_selection import train_test_split
import pandas as pd
importmatplotlib.pyplot as plt
read moisture.csv file
print the values
sample=df['SAMPLES'].values
sample=sample.reshape(-1,1)
print sample
digital=df['DIGI'].values
digital=digital.reshape(-1,1)
print digital
spilt the data into train and test data
call the regression function
model = regression.fit(sample,digital)
print the model.intercept
print the model.coef
y_pred = regression.predict(X_test)
find the absolute of the predicted value
plot the values in graph
plt.show()
20
Fig 6.1 Output of Linear Regression
21
6.2.3 DEEP LEARNING
importmatplotlib.pyplot as plt
importnumpy as np
import pandas as pd
fromsklearn.model_selection import train_test_split
fromsklearn.preprocessing import MinMaxScaler
fromtensorflow.python.keras.models import Sequential
fromtensorflow.python.keras.layers import Dense
read the'P_EST.csv an initialize it to data variable
x=dataset.iloc[:,:-1].values
y=dataset.iloc[:,-1].values
print the dataset
print(x)
y=y.reshape(-1,1)
scaler_x = MinMaxScaler()
scaler_y = MinMaxScaler()
print(scaler_x.fit(x))
xscale=scaler_x.transform(x)
print(scaler_y.fit(y))
yscale=scaler_y.transform(y)
X_train, X_test, y_train, y_test = train_test_split(xscale, yscale)
model = Sequential()
model.add(Dense(12, input_dim=3, kernel_initializer='normal', activation='relu'))
22
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='linear'))
model.summary()
model.compile(loss='mse', optimizer='adam', metrics=['mse','mae'])
history = model.fit(X_train, y_train, epochs=500, batch_size=50,
verbose=1,validation_split=0.25)
print(history.history.keys())
# "Loss"
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'validation'], loc='upper left')
plt.show()
Xnew =
np.array([[0.3000,16.0000,12.0000],[0.3181,16.3289,12.5570],[0.3362,16.6577,13.1141],
[0.3544,16.9866,13.6711],[0.3725,17.3154,14.2282],[0.3906,17.6443,14.7852],[0.4087,1
7.9732,15.3423],[0.4268,18.3020,15.8993],[0.4450,18.6309,16.4564],[0.4631,18.9597,17
.0134],[2.2752,51.8456,72.7181], [3,65,95]])
ynew = (model.predict(Xnew))
ynew=ynew/2.0
print(ynew)
23
fig 6.2 Output of Deep Learning
24
6.2.4 TIME SERIES FORECASTING
import pandas as pd
importseaborn as sns
importmatplotlib.pyplot as plt
fromstatsmodels.tsa.arima_model import ARIMA
fore = pd.read_csv('forcast.csv',
parse_dates=['Month'],
index_col='Month',
date_parser=lambda d: \
pd.datetime.strptime(d, '%Y-%m'))
print(fore)
fromstatsmodels.tsa.seasonal import seasonal_decompose
fore_decomp = seasonal_decompose(fore, freq=12)
fore_trend = fore_decomp.trend
fore_seasonal = fore_decomp.seasonal
fore_residual = fore_decomp.resid
ts = fore-fore_seasonal
tsdiff = ts.diff(1)
model = ARIMA(ts, order=(1, 1, 0))
mares = model.fit()
mares.plot_predict(start='2011-12-01', end='2050-01-01',alpha=0.10)
plt.legend(loc='upper left')
sns.despine(ax=plt.gca())
plt.xlabel('Year')print(mares.aic, mares.bic)
25
Fig 6.3 Output of Time Series Casting
26
CHAPTER 7
TESTING
7.1 UNIT TESTING
Unit testing involves the design of test cases that validate that the internal program logic
is functioning properly, and that program inputs produce valid outputs. All decision
branches and internal code flow should be validated. It is the testing of individual
software units of the application .it is done after the completion of an individual unit
before integration. This is a structural testing, that relies on knowledge of its construction
and is invasive. Unit tests perform basic tests at component level and test a specific
business process, application, and/or system configuration. Unit tests ensure that each
unique path of all business process
performs accurately to the documented specifications and contains clearly defined inputs
and expected results.
TEST ID UTST-01
UNIT TESTED Input values (EC, temperature, humidity)
PURPOSE To identify the Phosphorous content
PRE-REQUIREMENTS Should be in .csv format
TEST DATA Set of sensor values and EC
TEST STATUS Pass
TEST RESULT Phosphorous content has successfully
measured
Table 7.1 Unit Testing
27
7.2 INTEGRATION TESTING
Integration tests are designed to test integrated software components to determine if
theyactually run as one program. Testing is event driven and is more concerned with the
basic outcomeof screens or fields. Integration tests demonstrate that although the
components were individuallysatisfaction, as shown by successfully unit testing, the
combination of components is correct andconsistent. Integration testing is specifically
aimed at exposing the problems that arise from thecombination of components.
7.3 FUNCTIONAL TESTING
Functional tests provide systematic demonstrations that functions tested are available as
specified by the business and technical requirements, system documentation, and user
manuals.
Functional testing is centred on the following items:
Valid Input: identified classes of valid input must be accepted.
Invalid Input: identified classes of invalid input must be rejected.
Functions: identified functions must be exercised.
Output: identified classes of application outputs must be exercised.
Systems/Procedures: interfacing systems or procedures must be invoked.
Organization and preparation of functional tests is focused on requirements, key
functions, orspecial test cases. In addition, systematic coverage pertaining to identify
Business process flows;data fields, predefined processes, and successive processes must
be considered for testing. Beforefunctional testing is complete, additional tests are
identified and the effective value of current tests is determined.
28
CHAPTER 8
CONCLUSION AND FUTURE WORK
The proposed method uses Deep Learning techniques which gives improved efficiency
and accuracy.The efficiency and accuracy in predicting the PHOSPHOROUS CONTENT
is very much effective in this architecture.The technology growth paves a major role in
this area. This strategy considers that soil respiration rates during the day are affected by
temperature, humidity and conductivity changes, and are therefore linked to P
sorption/desorption, in addition to other biological activities. Using time series
forecasting method the feature phosphorus also planned to predict. Cost wise low priced
sensors are used to sense the soil parameters.
29
CHAPTER 9
REFERENCES
1. P. McLoud, R. Gronwald, and H. Kuykendall, “Precision Agriculture:NRCS Support
for Emerging Technologies,” Natural Resources Conservation Service (NCRS),
Greensboro, NC, Tech. Rep. Agronomy Tech. Note 1, Jun. 2007.
2. R. ongiovanni and J. Lowenberg-Deboer, “Precision Agriculture and Sustainability,”
Precision Agriculture, vol. 5, no. 4, pp. 358–387, Aug. 2004.
3. J. I. Huircán, C. Muñoz, H. Young, L. Von Dossow, J. Bustos, G. Vivallo, and M.
Toneatti, “Zigbee-based wireless sensor network localization for cattle monitoring in
grazing fields,” Computers and Electronics in Agriculture, vol. 74, no. 2, pp. 258–264,
2010.
4. R. W. Coates, M. J. Delwiche, A. Broad, and M. Holler, “Wireless Sensor Network
with Irrigation Valve Control,” Computers and electronics in agriculture, vol. 96, pp. 13–
22, 2013.
5. J. Gutiérrez, J. F. Villa-Medina, A. Nieto-Garibay, and M. A. PortaGándara,
“Automated irrigation system using a wireless sensor network and GPRS module,” IEEE
Trans. Instrum. Meas., vol. 63, no. 1, pp.166–176, Jan. 2014.
6. F. Viani, M. Bertolli, M. Salucci, and A. Polo, “Low-cost wireless monitoring and
decision support for water saving in agriculture,” IEEE Sensors J., vol. 17, no. 13, pp.
4299–4309, Jul. 2017.
30
7. R. G. Vieira, A. M. da Cunha, L. B. Ruiz, and A. P. de Camargo, “On the design of a
long range WSN for precision irrigation,” IEEE Sensors J,, vol. 18, no. 2, pp. 773–780,
Jan. 2018.
8. D. García-Lesta, D. Cabello, E. Ferro, P. López, and V. M. Brea,
“Wireless sensor network with perpetual motes for terrestrial snail activity monitoring,”
IEEE Sensors J., vol. 17, no. 15, pp. 5008–5015, Aug. 2017.
9. F. Viani, M. Bertolli, and A. Polo, “Low-cost wireless system for agrochemical dosage
reduction in precision farming,” IEEE Sensors J., vol.17, no. 1, pp. 5–6, Jan. 2017.
10. T. Ruan, Z. J. Chew, and M. Zhu, “Energy-aware approaches for energy harvesting
powered wireless sensor nodes,” IEEE Sensors Journal,vol. 17, no. 7, pp. 2165–2173,
April 2017.
31
32