Dahane 2020

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

An IoT Based Smart Farming System Using

Machine Learning
A.Dahane 1,2,3, R.Benameur 2,3 B.Kechar 2,3, A.Benyamina 3,4
1Institute
of Applied Science and Technology ISTA 2Research Laboratory in Industrial Computing and Networks (RIIR)
2Research Laboratory in Industrial Computing and Networks (RIIR) 3University of Oran 1, Algeria
3University of Oran 1, Algeria 4LAPECI Laboratory, University of Oran1
E-mail: dahane.amine@univ-oran1.dz E-mail: kechar.bouabdellah@univ-oran1.dz

Abstract— Smart farming allows to analyze the growth of sustainability as the world's population demands a significant
plants and to influence the parameters of our system in real time increase in food production must be achieved while now
in order to optimize plant growth and support the farmer in his availability and high nutritional quality worldwide [14,16 and
activity. Internet of Things (IoT) arrangements, based on the 18]. Due to the recent advances in sensor technology for the
application particular sensors data measurements and intelligent
implementation of irrigation systems in agriculture especially
processing, are bridging the holes between the cyber and physical
worlds. In this paper, we propose the design and the experiment smart farming [13, 15 and 17] and the evolution of IoT
of a smart farming system based on an intelligent platform which technologies that can be applied in the development of these
enables prediction capabilities using artificial intelligence (AI) systems. IoT takes a major role in the revolutions of digital
techniques. This system is based on the technology of wireless transformations, and today we will discuss the applications of
sensor networks and its implementation requires three main ‘IoT in Agriculture’. We anticipate the proposal of IoT-based
phases, i) data collection phase using sensors deployed in an intelligent irrigation architecture with a machine learning
agricultural field, ii) data cleaning and storage phase, and iii) approach to predict soil moisture to reach more convincing
predictive processing using some AI methods. conclusions. In this paper, we propose an IoT based smart
Keywords—Smart farming; IoT; Machine learning; Sensing;
farming architecture founded on new EDGE-Fog-IoT-Cloud
Precision agriculture. platform. After giving the design of the overall architecture,
we detail the implementation part (hardware and software
I. INTRODUCTION components). The aim of this platform is to demonstrate the
effectiveness of AI techniques to help in making effective
Agriculture uses 85% of available freshwater resources irrigation decisions with optimum water usage in smart
worldwide, and this percentage will continue to be dominant farming. The rest of the paper is organized as follows. Section
in water consumption because of population growth and II briefly surveys the related works. Section III presents our
increased food demand. There is an urgent need to develop proposed smart farming platform in agriculture of precision
strategies based on the science and the technology [1]. The specially irrigation. Section VI introduces and explains the
need of using IoT in agriculture applications becomes tool developed and illustrates the use of AI techniques.
nowadays a reality after the success of theoretical research Section V concludes the paper and outline directions of future
contributions in the previous decade [2,6]. IoT have recently work.
motivated adoption of information technology solutions in
crop fields within precision agriculture approaches which II. RELATED WORKS
contribute for rational use of water, including technical,
We present in this section recent research work aimed at the
agronomic, managerial,…etc. Several research studies were
implementation of irrigation systems in agriculture. Some of
conducted on irrigation systems to achieve water savings in
them have used AI techniques to enhance the prediction
diverse crops from basic ones to more technologically
aspect. Researchers in [3] developed irrigation sensor based on
advanced ones [4,5,7,8,9 and 21]. To achieve water saving,
smart phone. For sensing soil moisture, the digital camera of
irrigation system frameworks have been proposed based on
smart phone is used to process RGB to gray for estimation of
various techniques, e.g., thermal imaging, Crop Water Stress
ratio between wet and dry area of soil. The ratio of wetness
Index (CWSI), direct soil water measurements, etc. Precision
and dryness is transmitted via gateway to water motor
farming is a principle that aims to optimize yields and
controller. A Mobile Application (APP) is developed to
investments, while seeking to better take into account the
control sensor activity (like wakeup) and to set sensor in sleep
variability of the environment. This concept appeared in the
mode. Majority of the earlier irrigation systems do not
context of the race for progress in agricultural yields. It
consider the weather forecasting information (e.g.,
notably influenced: tillage, sowing, fertilization, irrigation,
precipitation) while making irrigation decisions. It leads to a
spraying of pesticides. Precision agriculture is essential to
wastage of fresh water, energy and loss of crop growth (due to
meet the challenges of agricultural production in terms of
productivity, environmental impact, food security and

978-1-7281-5628-6/20/$31.00 ©2020 IEEE

Authorized licensed use limited to: Cornell University Library. Downloaded on May 24,2021 at 15:31:06 UTC from IEEE Xplore. Restrictions apply.
excess water) when a rain is followed immediately by the the weather forecast information to manage the irrigation
watering of the crop. efficiently. The system architecture is designed in three layers:
To handle such cases, WSNs based solutions can provide a data layer which is depicted in Fig. 1, data processing layer
better decision support for irrigation by utilizing weather and application layer. This distributed architecture is shown in
forecasting information (e.g., precipitation) from the Network. Fig. 2 and Fig. 3 which represents a major extension of our
Irrigated agriculture represents the bulk of the demand for previous works [20,21] on agriculture of precision where we
water, being the first sector affected by water shortage, calculated the useful reserve of water (RU) according to the
resulting in a decreased capacity to maintain per capita food texture of the soil (Clay, Limon, Sand, Organic Matter), and
production. Therefore, the efficient use of water in agriculture for the second method we used the (Rawls and Turq
is one of the most important agricultural challenges that formulas) equations. The operational architecture shows
modern technologies are helping to resolve [11]. The objective information regarding soil moisture of the upcoming days, it
of authors in [10] was to develop understanding on site- also provides irrigation suggestions, based on the defined level
specific suitability of the Mid Elevation Spray Application of soil moisture and predicted precipitation, to save water and
(MESA) and Low Elevation Spray Application (LESA) energy the generated information by algorithm and device is
sprinkler systems in irrigating corn crop and potential water as stored in MySQL database at the server (see Fig. 2). A web
well as energy savings. The automated irrigation system put in service based on NodeJS process data before sending them
place has proven to be feasible and cost-effective to optimize periodically to the cloud architecture. All streams of data are
water resources for agricultural production [1,5 and 21]. stored in Google drive before they are transmitted to Google
Authors in [8] propose an intelligent irrigation architecture Colab to execute artificial intelligence techniques (AI) used
based on IoT as well as a hybrid approach based on deep for training, testing and prediction. The EDGE is placed
learning to predict soil moisture. The proposed algorithm uses between IoT sensors Network and the Cloud as an
sensor data from the recent past and weather forecasts to intermediate layer. EDGE comprises three primary modules:
predict soil moisture for the next few days. The disadvantage data acquisition, prediction, and visualization. Data sent by
of these approaches [1,5] is that they set the maximum sensors network by means of different transmission
humidity and do not take into account the need for water network protocols. Data is stored closely to the EDGE to
exactly needed. They plan to save water. Unlike this state-of- provide quick access to data for farmer during interventions.
the-art work, we propose in this paper an automated irrigation Moreover, farming data remains available even if the internet
management platform using a WSN by making the following connection is temporarily interrupted. Processing and
contributions: i) Design and implementation of a new EDGE- validating data at EDGE level reduce the amount of data
Fog-IoT-Cloud based architecture dedicated to the smart transmitted to the cloud and conserving global energy of the
farming, and ii) We show clearly the interest of our system in architecture and network bandwidth. Each sensor in our IoT
saving water and preserving this natural resource by using AI system has a range of measurement which must be evaluated
techniques to predict soil moisture of the upcoming days. in the level of EDGE to serve as a baseline for the detection of
abnormal behavior. For example, we have temperature
III. SMART FARMING SYSTEM measuring range -40 to +80 °C for the DHT22 sensor. These
The smart farming platform architecture (Fig. 2, Fig. 3) has not clean data must also be corrected according to the
been proposed to collect, transmit and process the physical behavior of each sensor and also take into account historical
parameters (Soil-Moisture, Air-Temperature, Air-Humidity, data to avoid triggering unnecessary alerts and adapt the
Water-level, Water-flow, Luminous intensity, Combustible frequency of collecting sensing data in order to obtain clean
Gas (vapors) for security of crops) of farming land along with data.

Fig. 1: Hardware components involved on the Field experiment. [Legends 1: DHT22 Sensor, 2: LDR Sensor, 3: Water level Sensor, 4: Relay Switch, 5: Water
pump, 6: Power supply 9 V, 7: Water flow sensor, 8: Soil moisture sensor, 9: LCD display, 10: MQ2 sensor, 11: LEDs, 12: Jumpers]. The mega arduino card
and NRF module are in the Box.

Authorized licensed use limited to: Cornell University Library. Downloaded on May 24,2021 at 15:31:06 UTC from IEEE Xplore. Restrictions apply.
Fig. 2: Global View of our proposed operational architecture.

Fig. 3: Proposed layered architecture of smart farming with the technical choices of implementation.

Fig. 4: Main steps in the proposed architecture based on IA techniques.

Authorized licensed use limited to: Cornell University Library. Downloaded on May 24,2021 at 15:31:06 UTC from IEEE Xplore. Restrictions apply.
The designed platform is based on the ideas proposed by Intel Core i5-6300U @ 2.40GHz, Memory: 8GO RAM, Disk:
[1, 5, 8 and 19] with modifications made for our application. 256 GO SSD.
As we can see in Fig. 2, Fig. 3, the devices of our platform in
B. Discussion and Results
the first layer aim to collect field data and transmit them using
NRFL01 radio module. These data can be stored in private In addition, the comparison between the performances of
database so that the user (farmer) has a possibility to analyze the LSTM-based models and GRU-based models over the two
them and monitor the crops in real time. In order to start test sets together is depicted in figures 5, 6 and 7, by
irrigation planning we need to calculate the UR parameter in comparing results on both training and validation datasets,
mm. respectively. The analysis of the obtained results has revealed
the following key insights: (1) the training time can be
IV. EXPERIMENTATION shortened by reducing the model size and increasing the batch
This section presents the implementation of the new size; (2) CPU outperforms GPU in speeding-up the training
EDGE-Fog-IoT-Cloud based architecture dedicated to smart time of small-sized models. This is explained by the fact that
farming and the analysis of the obtained results. with small models, the CPU-GPU data transfer overhead
exceeds the computation acceleration benefit; (3) LSTM-
A. Implementation and results analysis based models exhibit long training time compared to GRU-
The main objective of these experiments is to show how to based models.
create our own wireless network under Arduino environment Even LSTM (Long Short-Term Memory Recurrent
to transmit data from one or more sensors at any time of the Networks) and GRU involve 1 input layer and 2 hidden layers
day. Along with weather forecast information for with 128 neurons for the first and 64 neurons for the second.
developing an algorithm for prediction of soil moisture of From the plot of loss, we can see that the model has
the upcoming days. The system was first tested in our comparable performance on both training and validation
laboratory and we plan to test it in a farm of vine near to El- datasets. If these parallel plots start to depart consistently, it
Malah city, located in western Algeria. Figure 3 shows might be a sign to stop training at an earlier epoch (See figures
schematic of ML sub-process blocks for the execution of the 5, 6 and 7). We discovered also the importance of collecting
models. An operational architecture has been developed (see and reviewing metrics during the training of our deep learning
Fig. 2) within the level of EDGE to predict the soil moisture models. Indeed, we observe that the training time for each
based on field sensors data, and also weather forecasting data epoch with LSTM-based models is 200 sec, however it is
using LSTM-based models and GRU-based models. about 300 sec with GRU-based models. According to the
In this paper, two different sources of information are recent research results, it even surpasses LSTM-based models
considered, each of them featuring complementary and in many applications. The experiments were conducted for the
characteristic features useful to design and test LSTM and prediction of the (Air-Temperature, Air-Humidity and Soil-
GRU approaches: Historical hourly weather data 2012-2017 Moisture) to predict these parameters of the upcoming days.
[24]: the data have been collected from 30 US and Canadian Figures 5(a) and 5(b) illustrate that the model has comparable
Cities, as well as 6 Palestine cities. The dataset contains ~5 performance for Air-temperature and gives best results on
years of high temporal resolution (hourly measurements) data both training and validation especially with LSTM-based
of various weather attributes, such as temperature, humidity models even the Mean Squared Error (MSE) is higher
what concerns us of our study. Detailed hydro meteorological compared to GRU-based models. Figures 6(a) and 6(b) depict
data from the mountain rain-to-snow transition zone are that the model with GRU-based models outperforms slightly
present for water years 2004 through 2014 [23]: we interested LSTM-based models. Figures 7(a) and 7(b) show that the
only to the soil moisture measurements. This version of the parallel plots start to depart consistently after 10 epochs
data set fixes errors in all data files and supersedes the earlier approximately at the start of 60th epoch, it might be a sign
datasets. In this study, the LSTM cell architecture described to stop training at an earlier epoch.
by Zaremba et al. [22] implemented in TensorFlow 2.0 has Despite all this, the model well mannered on both training
been used for the experiments. Many factors may contribute to and validation datasets knowing that the scale of the graph is
speeding up the training time, including the dataset size, the too small. To avoid local minima problems in neural networks
development platform (e.g., Tensorflow, Pytorch, Keras, using ReLU as the inner activation function, the experiments
Caffe, MXNet), the hard-ware platform (e.g., CPU, GPU, are repeated 5 times and the median Mean Absolute Error
TPU) and the AI/ML model’s hyper-parameters (e.g., the (MAE), the (MSE) and Root Mean Squared Error (RMSE) on
number of hidden layers, the number of neurons in each layer, both test sets are presented in Table 1. According to the
the learning rate, the batch size, the number of epochs). results, GRU-based models can result better performance for
Google Colab (GC) is an awesome place provided by Google Soil-Moisture and Air-Temperature predictions. However,
for training models. We was training our model but the Google LSTM-based model outperforms GRU-based models for Air-
Colab keeps disconnecting after 2 hours automatically if we do Humidity predictions.
not respond the data is lost.
In time of prevent GC from disconnecting that's why in all
the experiments, we use a Laptop (Laptop PC) with processor:

Authorized licensed use limited to: Cornell University Library. Downloaded on May 24,2021 at 15:31:06 UTC from IEEE Xplore. Restrictions apply.
(a) (b)
Fig. 5: (a) Plot of Model Loss on Training and Validation of Air-Temperature using LSTM-based models. (b) Plot of Model Loss on Training and Validation
of Air-Temperature using GRU-based models.

(a) (b)
Fig. 6: (a) Plot of Model Loss on Training and Validation of Soil-Moisture using LSTM-based models. (b) Plot of Model Loss on Training and Validation
of Soil-Moisture using GRU-based models.

(a) (b)
Fig. 7: (a) Plot of Model Loss on Training and Validation of Air-Humidity using LSTM-based models. (b) Plot of Model Loss on Training and Validation
of Air-Humidity using GRU-based models.

Table. 1: RMSE, MSE, MAE of the LSTM and GRU based models for (Air-Temperature, Soil-Moisture, Air-Humidity) Training and Validation.

Parameters LSTM GRU


RMSE MSE MAE RMSE MSE MAE

Soil-Moisture 0.0268 0,00072 0.0114 0.0220 0,00048 0.0101

Air-Humidity 11.7550 138,18 8.1946 12.9778 168.4255 8.4585

Air-Temperature 1.4090 1.9855 1.0777 1.3331 1.7771 1.0167

Authorized licensed use limited to: Cornell University Library. Downloaded on May 24,2021 at 15:31:06 UTC from IEEE Xplore. Restrictions apply.
[11] A. Bonfante, et al. LCIS DSS—an irrigation supporting system for water
V. CONCLUSION AND PERSPECTIVES use efficiency improvement in precision agriculture: A maize case
The implemented smart farming system was found to be study, Network Protocols & Algorithms vol.176, 102646. 2019.
feasible and cost effective for optimizing water resources for [12] M. Mekki, O. Abdallah, M. B. M. Amin, M. Eltayeb, T. Abdalfatah, and
agriculture of precision. The main objective of this paper was A. Babiker, Greenhouse monitoring and control system based on
wireless Sensor Network, Proc. - 2015 Int. Conf. Comput. Control.
to design a new EDGE-Fog-IoT-Cloud based architecture Networking, Electron. Embed. Syst. Eng. ICCNEEE 2015, pp. 384–
dedicated to the smart farming. We showed that AI techniques 387, 2016.
play a pivotal role in agriculture of precision by using machine [13] A. Patil, M. Beldar, A. Naik, and S. Deshpande, Smart farming using
learning and open sources technologies. One of future research Arduino and data mining, Proc. 10th INDIACom; 2016 3rd Int.
directions related to experiments is to collect the physical Conf. Comput. Sustain. Glob. Dev. INDIACom 2016, pp. 1913–
parameters of our own farming system in order to collect our 1917, 2016.
dataset and the use of these sensors data along with weather [14] X. Wang and Q. Qi, Design and realization of precision agriculture
forecast information for developing an algorithm for information system based on 5S, Proc. - 2011 19th Int. Conf.
prediction of soil moisture of the upcoming days. There is also Geoinformatics, Geoinformatics 2011, pp. 2–5, 2011.
the need to measure the hardware performance at the server [15] S. R. Prathibha, A. Hongal, and M. P. Jyothi, IoT Based Monitoring
level when ingesting data. Meanwhile, we spotlighted the System in Smart Agriculture, Proc. - 2017 Int. Conf. Recent Adv.
Electron. Commun. Technol. ICRAECT 2017, pp. 81–84, 2017.
limitations of AI techniques especially in training speed and
[16] H. S. Kumar and S. Kusuma, Automated Irrigation System Based on
accuracy balance that may hamper the integration of ML.
Wireless Sensor Network and GPRS Module, Int. Res. J. Eng.
Thus, more research efforts in this direction are required to Technol., vol. 3, no. 4, pp. 148–151, 2016.
fulfil the potential of transfer learning. [17] P. Singh and S. Saikia, Arduino-based smart irrigation using water flow
sensor, soil moisture sensor, temperature sensor and ESP8266 WiFi
module, IEEE Reg. 10 Humanit. Technol. Conf. 2016, R10-HTC
ACKNOWLEDGMENT 2016 - Proc., 2017.
This work has been supported scientifically by RIIR [18] M. Rahman, Precision agriculture in the World and its prospect in
laboratory/LAPECI laboratory. This paper is supported by the Bangladesh Research in Agriculture , Livestock and FISHERIES,
PRIMA programme under grant agreement No 1821, project An open access peer Rev. J., vol. 3, no. April, pp. 1–14, 2016.
WATERMED4.0. The PRIMA programme is supported by the [19] L Parra, J Rocher, L García, et al. Design of a WSN for smart irrigation
European Union. in citrus plots with fault-tolerance and energy-saving algorithms,
Network Protocols & Algorithms vol.10, no. 2, pp. 95-115. 2018.
[20] A. Dahane, B. Kechar, ‘Remote Sensing Data: Automated Irrigation
REFERENCES Management Platform Using a WSNs’,International Conference on
[1] J. Gutiérrez, J. F. Villa-Medina, A. Nieto-Garibay and M. Á. Porta- Embedded Systems in Telecommunications and Instrumentation
Gándara, ‘Automated Irrigation System Based on Wireless Sensor (ICESTI'19), Annaba, Algeria, October, 28-30, 2019.
Network and GPRS Module’, vol. 63, no. 1, pp. 166–176, 2014. [21] A. Dahane, B. Kechar, Y. Meddah and O. Benabdellah, Automated
[2] I. F. Akyildiz, W. Su, Y. Sankarasubramaniam, and E. Cayirci, “Wireless Irrigation Management Platform using a Wireless Sensor
sensor networks: a survey,” Computer Networks ,vol.38 , No.4, Network, 2019 Sixth International Conference on Internet of
pp.393–422, 2002. Things: Systems, Management and Security (IOTSMS), Granada,
Spain, pp. 610-615, 2019.
[3] X. Wang, W. Yang, A. Wheaton, N. Cooley, and B. Moran, Efficient
registration of optical and IR images for automatic plant water stress [22] W. Zaremba, I. Sutskever and O.Vinyals, Recurrent neural network
assessment, Comput. Electron. Agric., 2010. regularization. Preprint arXiv: 1409.2329, 2014.
[4] K. S. Nemali and M. W. van Iersel, An automated system for controlling [23] C.L. Enslin, S. E. Godsey, D.Marks,P.R, Kormos,M.S.Seyfried, J. P.
drought stress and irrigation in potted plants, Sci. Hortic. McNamara, and T. E.Link,: Hydro meteorological observations from
(Amsterdam)., 2006. the rain-to-snow transition zone: a dataset from the Johnston Draw
catchment, Reynolds Creek Experimental Watershed, Idaho, USA
[5] A. Goap, D. Sharma, A. K. Shukla, and C. Rama Krishna, An IoT based V1.1, Earth Syst. Sci. Data Discuss., [Online]. Available:
smart irrigation management system using Machine learning and https://doi.org/10.5194/essd-2016-44, 2016.
open source technologies, Comput. Electron. Agric., vol. 155, no. [24] Historical Hourly Weather Data 2012-2017, [Online]. Available:
May, pp. 41–49, 2018. https://www.kaggle.com/selfishgene/historical-hourly-weather-
[6] A. Dahane and N. E. Berrached, Mobile wireless and sensor, A clustering data/metadata (accessed: 27 April, 2020) .
algorithm for energy efficiency and safety, Apple Academic Press,
ISBN 9781771886796, July 2019.
[7] L. García, L. Parra, J. M. Jimenez, J. Lioret and P. Lorenz , IoT-Based
Smart Irrigation Systems: An Overview on the Recent Trends on
Sensors and IoT Systems for Irrigation in Precision
Agriculture, Sensors,Vol.20, No.4, pp.1042, 2020.
[8] M. C. Vuran, A. Salam, R. Wong, and S. Irmak, ‘Internet of underground
things in precision agriculture: Architecture and technology
aspects’, Ad Hoc Networks, vol. 81, pp. 160–173, 2018.
[9] S. Hwang, Monitoring and Controlling System for an IoT Based Smart
Home, Int. J. Control Autom., vol. 10, no. 2, pp. 339–348, 2017.
[10] M. Chakrabor ty, L. R. Khot and R. T. Pete rs, Assessing suitability of
modified center pivot irrigation systems in corn production using
low altitud e aerial imaging techniques, Information Processing In
Agriculture, In press, 2019.

Authorized licensed use limited to: Cornell University Library. Downloaded on May 24,2021 at 15:31:06 UTC from IEEE Xplore. Restrictions apply.

You might also like