Sei sulla pagina 1di 30

by-

Amartya Roy(1607232)
Anirban Sen(1607234)
Gourob Nandi(1607251)
Ratul Sarkar(1607273)
Sujoy Pal(1607295)
Introduction to IoT and Machine Learning
 Introduction to the project
 Stages for the development of the Project
 Hardware Implementation
 Software implementation
• Algorithm for Machine Learning
• Algorithm for Iot
 Project as a product
 Conclusion
Introduction to IoT and Machine Learning
The entire world is going bonkers over data, IoT and
Artificial Intelligence. Tons of articles have spoken
about the amount of data we generate every single day
and numerous statistics have shown how much data
we would generate by the year 2025.
But when it comes to a complex concept like IoT,
how would Machine Learning make things better for the
Internet of Things? Every time the IoT sensors gather
data, there has to be someone at the backend to
classify the data, process them and ensure information
is sent out back to the device for decision making.
Introduction to The Project

Project Name- Crop Prediction and Automatic Irrigation


As per 2018, Agriculture employed 50% of the Indian work force
and contributed 17-18% to country's GDP and India ranks
second worldwide the farm outputs. So we decided to make
farming easier, less time consuming and of high yield by
implementing the concept of “smart farming”. We worked on the
area of crop prediction using machine learning and automatic
irrigation using Internet of Things. Our system is able to predict
the crop which need to be planted on the basis of parameters
like soil pH, temperature, soil moisture and relative humidity.
After the prediction, the system will automatically
irrigate the soil as per the requirement of the crop for higher
yield. So,our system will help the farmers to choose the right
crop for the season. The system will also help them to prevent
wastage of water, as the calculated amount of water will be
discharged which are not possible in the traditional irrigation
techniques.
At first, after the installation of our system to a specific area, values
from the sensors are collected. The values which are uploaded to the
cloud are extracted in .csv format. Then according to the values the
crop is predicted using the concept of machine learning. We had
previously collected the data set from Bidhan Chandra Krishi Viswa
Vidyalaya, West Bengal. Then we splitted the data set into training set
and testing set to calculate the accuracy and then tested our trained
system with the sensor values.Then the predicted crop is mailed to the
developer and the farmer.
After the prediction of the crop, developer will change the program
and give the necessary conditions for irrigation, according to the water
requirement of the predicted crop. This changes need to be done
every crop season. There will be a network of soil moisture sensors
spend around the whole field to detect the amount of soil moisture and
help to automatically irrigate the soil if the condition given by the
developer satisfies.
Internet of Things is the process of connecting any device to the
Internet and to other connected devices. The IoT is a large network of
connected things and people – all of which collect and share data about
the way they are used and about the environment around them.

Application of IoT
 Wearables
 Smart Home Application
 Health care
 Smart Cities
 Agriculture
 Industrial Application
AUTOMATIC IRRIGATION
Irrigation is defined as application of water to soil artificially.
Irrigation process can be used for the cultivation of
agricultural crops during the span of inadequate rainfall. And
it is also for maintaining landscapes. An automatic irrigation
system does the operation of a system without manual
involvement of persons. Every irrigation system such as drip,
sprinkler and surface can be automated with the help of
electronic appliances and detectors.For example: computer,
timers, sensors and other mechanical devices.
Materials Required:
1.Arduino UNO
2.DHT sensor
3.Soil Moisture Sensor
4.Light Emitting Diode
5.ESP8266
6.Jumper wires
7.Bread board
8.Soil sample
9.Container for keeping the soil sample
Step 1: The connections between the Arduino UNO and
soil moisture sensor were done.
Step 1.1: VCC pin of soil moisture sensor was connected
to the VCC pin of Arduino UNO using jumper wires.
Step 1.2: GND pin of soil moisture sensor was connected
to the GND pin of Arduino UNO using jumper wires.
Step 1.3: A0 pin of soil moisture sensor was connected to
the analog GPIO pin A1 of arduino UNO using jumper
wires.
Step 2:The connections between the Arduino UNO and
DHT11 sensor were done.
Step 2.1: VCC pin of DHT11 sensor was connected to
VCC pin of Arduino UNO using jumper wires.
Step 2.2: GND pin of DHT11 sensor was connected to
GND pin of Arduino UNO using jumper wires.
Step 2.3: Data pin of DHT11 sensor was connected to
analog GPIO pin A5 of Arduino UNO using jumper wires.
Step 3: A Light emitting diode was connected to the digital
GPIO pin of the Arduino UNO with jumper wires and using
a bread board.
Step 4: The soil moisture sensor is put in the soil sample
whose soil moisture need to be determined.
Step 5: Arduino UNO is reset by pressing the reset button
before the Arduino program is uploaded.
Software Required:
1.Arduino IDE
Step 1: Included the DHT directory and defined the DHT pin
and type.
Step 2: Declaration and initialisation of a global variable for
storing the value for the pH of the soil as in the project we did
not used a pH sensor to measuring the pH of the soil.
Step 3: As our system was connected to the cloud for
fetching data (which was used for crop prediction), so we
included the thinkspeak API key in the program to get access
to the cloud.
Step 4: Then in the Attention Mode of ESP8266, wifi name
and password was given to make the ESP8266 get
connected to the internet.
Step 5: In the void setup function, the input and output pins
were declared and baud rate 9600 was taken.
Step 6: In the void loop function, delay was taken 1000 and
three local float variables was taken for humidity,
temperature and soil moisture.
Step 7: Values of all the variables storing data from the
senors were printed using serial.print statement in the serial
monitor.
Step 8: Then the conditions were checked according to the
predicted crop (prediction was done by applying Machine
Learning to the available data sheet).
Step 9: If all the conditions satisfied true then the LED glow,
indicating to irrigate. If the conditions didn’t satisfy the LED
will not glow, indicating to stop irrigation.
Step 10: The steps were repeated again and again, once
the program was uploaded to the arduino UNO and would
stop when the reset button was pressed.
Machine Learning is a new trending field these days and
is an important application of artificial intelligence. Certain
statistical algorithms are used to make computers work in
a specific way without being explicitly programmed. The
algorithms receive an input value and predict an output
for this by the use of certain statistical methods. The main
aim of machine learning is to create intelligent machines
which can think and work like human beings.

Financial Services
Marketing and Sales
Government
Healthcare
Transportation
Oil and Gases
Our aim is to predict a particular Crop according to
respective parameters.For this We use Machine Learning
Algorithms.As our output consists of continous variable
,We use regression models and Xg-Boost.
Step 1: First of all we have imported all the necessary libraries
like pandas,numpy,seaborn where panda is used for
mathematical calculations,numpy is used for array
distribution,seaborn and matplotlib is used for visualisation.
Step 2: The data set is being loaded from local machine to
console.
Step 3: The data set is then split into train set and test set to
handle the model in a better way.
Step 4: Since the output is in the form of string we cannot fit it
in the machine learning model. Thats why we have used sklearn
library. From that library we have imported label encoder which
encodes the categorical value to numerical value.
Step 5: For better accesssment ,visualization of training
set crops vs testing set crops is done
Step 6: To avoid dummy variable trap we have plotted the correlation
between features and see the ratio between each features. We have
found that no feature is correlated(we keep correlation threshold value
as 0.5).
Step 7: Model Estimation
The data is ready to be fitted under a model. Our output data consists of
continuous variable hence we apply regression model(Decision tree Regression
and Random Forest Regression) and Xg-Boost.
Step 8: Calculating model accuracy,MAE,RMSE and plotting for
visualization,and doing the Grid Search for selecting the best parameters
( max_depth,min_sample_leaf , etc) for decision tree regression have been
done.
Decision Tree Regression
Step 9: For better visualization we have plotted actual vs prediction
values, and it is showing regression nature
Step 10: Plotting of Outlier is done to see whether it
affects the model or not.
Step 11: Step 8 and Step 9 have been performed again
under Random Forest Regression and We have also
repeated step 8 for Xg-Boost also.
For Xg-Boost
Step 12: We have compared between the two models i.e. Random
Forest Regression & Decision Tree Regression.
Step 13: Now we have taken a set of test value which we got from
sensors and then fitted it into our model.
Step 14: We have created a function named crop_name to print the
crop which our model predicted.
Step 15: Using smtplib we have notified the farmer and the developer
about the particular crop via email.
We will build an UI interface using ext-js and sencha on which a random
user will give the three values of soil pH, RH, temperature and based
upon these the crop will be predicted. For this, we will use flask and to
load the model in local machine we use model serialization method.

Model Serialization.
To serialize an object means to transform it in a format that can be stored, so
as to be able to deserialize it later, recreating the original object from the
serialized format. To do all these operations we will use the pickle module.
Pickling
Pickling is the name of the serialization process in Python. By pickling, we
can convert an object hierarchy to a binary format (usually not human
readable) that can be stored. To pickle an object we just need to import the
pickle module and call the dumps() function passing the object to be pickled
as a parameter.
Unpickling
The process that takes a binary array and converts it to an object hierarchy is
called unpickling.
The unpickling process is done by using the load() function of the pickle
module and returns a complete object hierarchy from a simple bytes array
We successfully completed our project on “Crop Prediction
and Automatic Irrigation” under the guidance of our project
guide- Prof. Rishi Khanna. We learned different models of
Machine Learning while doing the data pre-processing,
learned the use of different sensors and data uploading to the
cloud. So, our system is predicting the crop according to the
data recieved by the sensors and also irrigating the specific
place automatically.

Potrebbero piacerti anche