1. Introduction
As the world population increases uncontrollably, two critical resources are becoming a severe problem: water and food. The technical report published in [
1] estimates that the world population will reach 9.15 billion in 2050. This trend motivates a growing food production to accommodate the large global population with the consequent limitation in farmlands and a decreasing number of farmers as fewer people are willing to work in farming. For example, a Virginia winery applied to hire foreign workers to pick grapes after the company could not find American citizens who wanted the job [
2].
Agriculture provides the required food but consumes most of the Earth’s available fresh water. In Europe, the agricultural sector consumes a third of the total water supplies, affecting the quantity and quality of open water for other uses [
3]. In Mexico, 75.72% of water is used in agriculture [
4]. For example, about 240 gallons of water are required to produce a loaf of bread, and a pound of cheese takes about 382 gallons. So, a simple cheese sandwich takes about 56 gallons of water [
5].
Several governments have made investing in the agricultural sector a priority. In Mexico, the Federal Government defined agricultural technification as a goal of 520 thousand hectares, representing 10 percent of the ground with irrigation systems [
6]. In a global world, it is critical to efficiently monitor crops to significantly increase production and rationalize the use of consumables, materials, and supplies, as well as regulate, more precisely, the crop needs regarding irrigation water, fertilizers, fumigants, and pesticides. Preserving the water is an essential factor that considerably affects agriculture and requires the development of automated mechanisms to use it efficiently. Fertilizers, fumigants, and pesticides help grow vital crops and produce better harvests. However, when misused, they could be detrimental to plants and render them inedible for human consumption. The use of technology will improve the proper use of resources applied to agriculture. The purpose of applying technology is to improve labor and land yields while optimizing the use of resources. However, agriculture automation is complex, as several problems must be solved. Applying technology to automate the agricultural environment will demand more technically savvy farmers who can manage data. That is why it is necessary to modernize the process and train the farmer to develop his technological skills. That is why it is necessary to generate simple mechanisms that thoroughly explain the data obtained. However, the system must be considered an assistant adapted to the needs and knowledge of the farmer.
Agricultural production can be affected by different circumstances, such as plant diseases and pests, which, according to the FAO, are responsible for 20 to 40% of production losses [
7].
However, manually monitoring all supplies, soil variables, environmental conditions, and crop health is a challenge that demands a lot of effort. An easy way to monitor and gather ecological information over long periods is required [
8]. Therefore, the development and deployment of new technological solutions and methods to improve and automatize water use and detect crop diseases, considering not only the experience of farmers but also soil conditions and characteristics, types of plants, and climatic information, are needed.
Technology in agriculture evolved into the precision agriculture concept, which focuses on ensuring that the crops and soil perform optimally. Precision agriculture provides profitability, sustainability, and environmental protection [
9] based on field information such as temperature, humidity, wind speed and direction, and pH level, among others. Farmers can make informed decisions about consumable resources and supplies (water, fertilizers, and pesticides) to maximize crop yield and protect the environment and their product consumers using precision agriculture. In [
10], authors defined three essential tasks for precision control of the production environment: (I) monitoring parameters that influence the product yield and quality, (II) performing an in-depth analysis of collected data for making decisions, and (III) applying the best actions and mechanisms based on those decisions.
Several technology-based solutions for gathering and processing information (such as [
11,
12,
13,
14,
15]) to support agriculture, facilitate decision making, and enhance productivity have been proposed in the literature. Moreover, recent advances in electronic technology enabled the creation of new, smaller, and cheaper devices for gathering environmental data to support ubiquitous computing, ad-hoc and sensor networks, cloud computing, and the Internet of Things [
10,
16].
IoT helps cultivate the soil using cheap, easy-to-install devices to increase farm productions to meet the world’s food demands based on precision agriculture [
17,
18,
19], intelligent irrigation control [
20,
21,
22], and greenhouse monitoring [
23,
24,
25]. This technology can be applied in open and closed spaces to optimize consumables and supplies (fertilizers, pesticides, soil, and water) by setting automated alarms and threshold values for each resource. Suppose one collected data is out of the threshold value. In that case, a warning will be triggered, thus detecting problems affecting production and reducing the excessive consumption of supplies shortage risk.
On the other hand, plant monitoring is imperative to detect diseases early and implement mechanisms to prevent their spread and production losses [
26]. Traditional methods focus on either I) expert visual estimation or II) laboratory studies [
27]. The first method is subjective and therefore has low accuracy. The second method identifies morphological characteristics to detect the disease. The main problem with these methods is that they are expensive, time consuming to process, and their detection efficiency is low. In recent years, plant disease detection automatization has integrated technologies such as image processing [
28,
29], pattern recognition [
30,
31], and computer vision [
32,
33].
This paper presents SAgric-IoT, a technology platform based on IoT and CNN for monitoring physical variables and plant disease detection for precision farming. The platform uses communication algorithms for data monitoring and analysis for precision control of the production environment. In addition, it uses convolutional neural networks for plant disease identification and classification. We aim to develop a robust, low-maintenance, and low-cost IoT platform to control and optimize crop production. The remaining paper sections are as follows.
Section 2 reviews IoT and precision agriculture.
Section 3 describes the proposed technological platform in detail.
Section 4 explains the system evaluation, describes the scenario, assessment, and results obtained from a small-scale network, and
Section 5 summarizes our work and proposes future research.
2. Related Work
IoT has had a strong impetus in the last few years. In the literature, several works propose IoT architectures and platforms suited for applications such as agriculture [
19,
34,
35], traffic control [
36,
37,
38], smart cities [
39,
40,
41], education [
42,
43,
44], marine environments [
45,
46,
47], and health care [
48,
49,
50,
51,
52].
Technology and IoT-based agricultural applications for control and automatization of physical variables monitoring (such as soil temperature and moisture, leaf wetness) for precision agriculture have been published in the literature [
53,
54,
55,
56,
57,
58]. The results obtained in this work were the nodes’ design, the simple node interconnection architectures based on IoT or wireless sensor networks design, and a combination to create a communication network of nodes for crop monitoring. Other IoT-based platforms control water consumption using cellular technologies and cloud services [
59,
60,
61]. However, the main problem of these works is that they only show prototype nodes that control or monitor water usage but only evaluate their performance without showing concrete results.
In [
62], the authors present a collaboration between process control and remote sensors. However, the authors did not explain the data acquisition and delivery process from different sources (sensors, actuators, coordinators). Most of these applications use proprietary systems to generate and process vast amounts of data, sometimes only at the research level [
63]. The main problem with these works is that they only remain in architecture proposals without developing prototype nodes to test in real scenarios. Authors in [
64,
65] focused on minimizing production risk using wireless sensor networks for real-time monitoring and studying the inter-temporal environmental variability. Their results showed the importance of measuring and recording inter-temporal conditions that contribute to making decisions that improve productivity in agriculture, reinforcing the rationale for how IoT technology contributes to and facilitates the data collection process. In [
66,
67], authors studied the effects of energy balance in greenhouse production and the optimization of energy consumption in grape production to increase energy efficiency. The results show an improvement of up to 31% in energy consumption in greenhouses compared to those that do not use IoT technologies. In reference [
68], the authors argue that cleaner crop production procedures would improve energy efficiency in agriculture. However, authors in [
69] argued that technology is not the unique factor influencing modern agriculture. The key to a smooth transition toward sustainable agriculture requires the collaboration of technology, farmers, industries, financial institutions, and policy and decision-makers, among others. This collaboration would resolve conflicts and reduce deficiencies to promote sustainable development [
70].
For disease detection, convolutional neural networks have become one of the most widely used tools for this activity [
71,
72,
73,
74]. In [
75], CNNs have been combined with learning vector quantization (LVQ) to detect and classify tomato leaf diseases. In another work, the authors combined four CNN models (Inception, Resnet, Inception Resnet, and Densenet) for plant disease detection, achieving an accuracy of 87% [
76]. Other authors have focused on creating real-time models for rapidly detecting plant diseases [
77,
78,
79,
80] and evaluated the performance of models such as LeNet, VGG16, ResNet, and Xception in plant disease detection, obtaining accuracy levels of around 95%. Finally, some authors have proposed their models, getting results with accuracy levels of up to 98% [
81,
82,
83,
84].
3. SAgric-IoT Platform Description
SAgric-IoT is an easy-to-deploy, use, maintain, and upgrade platform for monitoring and controlling IoT for agricultural production. SAgric-IoT is based on low-cost and low-powered components which would be adapted to the farmer’s requirements. SAgric-IoT is focused on monitoring, data gathering, data processing, and data analysis to improve the efficiency of open and closed fields, reducing human interactions and rationalizing the use of water and other resources.
In this section, we first describe the general scenario used in SAgric-IoT. Next, we provide a review of the logical architecture of SAgric-IoT. Then, we explain in detail the designed hardware for our platform. We describe the dissemination protocol used in SAgric-IoT. Finally, we describe the convolutional neural network model implemented for plant disease detection.
3.1. General Scenario
Figure 1 shows the IoT on-site scenario for the SAgric-IoT platform. The architecture consists of four main nodes: the sensor nodes, the camera nodes, the gateway node, and the processing and storage node. Sensor nodes gather data from all sensors and periodically send it to the gateway node via other sensor nodes or directly, depending on the node’s distance from the gateway node. They are deployed on the greenhouses and establish a wireless network (based on 802.15.4) to communicate among themselves using radio-frequency links. The camera nodes send the images via Wi-Fi to the gateway node, where the trained CNN model for plant disease detection is stored. When the model identifies a possible disease situation in the crop area, a notification indicates the camera’s location and the detection image. A gateway node is also deployed along with the sensor nodes to enable a connection between the SAgric-IoT platform and the Internet (cloud server). The gateway node supports three communication interfaces: ZigBee to maintain communication with the sensor nodes, Wi-Fi to connect to the camera nodes, and a cellular interface to transmit data to the storage and processing node. A farmer has remote access to the gathering data to know the greenhouse conditions and control the different sensor and actuator devices and alert notifications when the CNN model detects a crop health problem situation. The gateway node includes a cellular network interface to transmit all gathered data to the cloud server. A web and mobile application were created as a cloud service to consult data information, receive alert notifications, and decide about control systems.
3.2. Layered IoT Architecture
The SAgric-IoT design complies with the remote monitoring needs, contributing to reducing human resource investment. SAgric-IoT defines a five-layered model (as shown in
Figure 2) with a transparent interconnection of all platform components and data dissemination in the agriculture precision area. The defined architecture covers all seven OSI model layers, as described in the following sentences. The gathering layer comprises the data link and physical layers. The communication layer is integrated with the data link and network layers. Finally, the processing and end-user layers are directly related to the four upper layers (transport, session, presentation, and application). The security layer is a transversal layer that interacts with the other layers of the architecture to obtain an end-to-end security level.
3.2.1. Gathering Layer
The gathering layer collects data relevant to physical environmental parameters from a given area of interest from all the sources on farmland and sensor nodes on the fields (such as air temperature and humidity, soil temperature and moisture, and pH, among others). It also captures images through the cameras distributed in the monitoring region.
In the last decade, several efforts have developed and defined low-power D2D standards and solutions [
85,
86,
87], generating many promising radio technologies for D2D connectivity for local and wide area networks.
One of the key challenges is determining the best data-transmission networking technology based on: transmission time, range, network size, and so on [
88,
89,
90].
Table 1 summarizes some of the results of these past studies.
3.2.2. Communication Layer
The communication layer transmits all data collected by sensor nodes to the gateway. This layer defines the communication protocol for data transmission. As sensors are stationary, the network topology does not change. Additionally, data transmission requires low latency, high reliability, and a high level of security to protect the collected data. The gateway node is powered by both ZigBee and Wi-Fi interfaces. This layer selects the best route to send the information by using several selection parameters, such as RSSI and the number of hops.
3.2.3. Processing Layer
This layer processes large amounts of information using policy-based management to trigger alarms and improve production. Additionally, government agencies use processed results (such as SAGARPA in México) to develop production maps to help farmers define the best crops, the best fertilizers, and the quantity of water required for each season or production phase. Each crop type has its own value range for each physical parameter (such as soil temperature and humidity, pH level, environmental temperature, and moisture). These values are recorded on the platform.
Table 2 shows an example of ideal physical parameters for tomatoes. Data are evaluated in real time to detect atypical values from the different physical parameters (values outside the defined range) that can represent abnormal conditions. Based on the data, the system can activate other systems (such as irrigation systems).
The processing layer supports an extensive database that can accommodate massive amounts of data from the sensor nodes relayed through the communication layer. The database is interfaced with data analysis algorithms and real-time scripts for data visualization and evaluation (
Figure 3).
The gateway node also implements the processing layer, where the CNN model is stored and processed to identify and classify diseases in the crop.
3.2.4. End User Layer
This layer is responsible for facilitating the farmer’s access to the data through a web service and software tools using a web and mobile application.
3.2.5. Security Layer
Security in the sensor nodes’ communication is essential within the SAgric-IoT system. The nodes provide mechanisms for devices’ access control to the network, encryption (using symmetric key cryptography), and integrity to verify that the received frames were not altered, following the security schemes defined in the 802.15.4 standard. The data are encrypted before being sent (128-bit AES encryption) and then decrypted at the receiver for use. The following parameters were configured in each Xbee node: first, E.E. = 1: AES encryption enable, and the parameter KY: AES encryption key with a string of 32 hexadecimal characters. Second, the camera nodes’ security with WPA2. The service provider controls the security of the processing and storage layers. Finally, the end-user accesses the system using a specific username and password and the secure HTTP protocol for connection to the system.
3.3. Electronical Board
The main challenge of the design of the SAgric-IoT was to build low-cost and energy-efficient hardware capable of monitoring, gathering, and controlling physical parameters. The hardware board comprises four modules: microcontroller, sensors and actuators, energy, and a wireless communication module, as shown in
Figure 4.
The microcontroller module gathers information from the attached sensors and relays such data to the gateway node. Depending on the application, the microcontroller can be battery-powered, solar-powered, or backup battery-powered. We used the Microchip PIC18LF46K22 microcontroller that executes up to 16 MIPS (millions of instructions per second); an input voltage of 3.3 V is required, and its CPU max current is 9.0 mA due to its specifications and low cost. The microcontroller has 64 K bytes for program memory, 3896 bytes for RAM, and 1024 bytes for EEPROM memory. An onboard 10-bit analog-to-digital converter (ADC) with 28 analog input channels and 35 I/O pins.
Sensors and actuators are used in precision agriculture to measure different environmental parameters. We use the sensor shown in
Table 3.
AM2315 is an I2C-interface temperature and humidity sensor (
Figure 5a). This sensor contains a DS18B20 temperature sensor and a capacitive humidity sensor. It has 3.5 to 5.5 V power and I/O and uses 10 mA max current during conversion. On the other hand, the AM2302 is a basic, low-cost digital temperature and humidity sensor (
Figure 5b). It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and outpost a digital signal on the data pin. The SHT-10 sensor includes a temperature/humidity sensor module (
Figure 5c). The casing is weatherproof and will keep water from seeping into the sensor’s body and damaging it, but it allows air to pass through so it can measure the soil’s humidity (moisture). Humidity and temperature have 4.5% and 0.5% precision readings, respectively.
We use XBee S2C radios connected to a microcontroller through a UART (universal asynchronous receiver-transmitter). This module operates on the 2.4 GHz ISM band, which significantly reduces the power consumption of our design. In addition, the module has a coverage area of up to 60 m in indoor spaces and 1200 m in outdoor locations with a line-of-sight range. It has a transmit power output of 3.1 mW. XBee modules provide wireless connectivity to end-point devices in ZigBee mesh networks.
The gateway nodes use Raspberry Pi 3 Model B, which has a 1.2 GHz 64-bit quad-core ARMv8 CPU, an integrated 802.11n wireless LAN and Bluetooth 4.1, Bluetooth Low Energy (BLE), 4 USB ports, a display interface (DSI), and a micro-SD card slot.
The camera nodes consist of an ESP32-CAM board with Wi-Fi and Bluetooth and an OV2640 camera (
Figure 6). This module contains a microSD card slot that serves as a support for the storage of images captured with the camera.
3.4. Proposed Dissemination Protocol
For the design of the dissemination protocol, we considered two critical issues: energy and reliability. Energy is the most important issue when designing dissemination protocols for IoT, where the application demands continuous information from the network field. For the design of the dissemination protocol: (I) we defined a static network architecture based on clusters; (II) the gateway node has no energy constraints; (III) the gateway node is not within the range of each sensor node, so a multi-hop transmission is needed; and (IV) heterogeneous sensors are implemented in each node.
Our protocol defines three types of nodes: end-node, routing, and gateway. End-node nodes gather data from the sensors but cannot retransmit data to other sensor nodes. Routing nodes are responsible for collecting and retransmitting data from different sensor nodes. They also maintain a routing table that allows nodes to choose the best route for data transmission. Finally, the gateway node is the central node that receives all the gathered data from different sensor nodes and sends it to the Internet.
Figure 7 shows the state diagram for the protocol.
Our protocol defines data and controls messages. The protocol starts when a sensor node switches on. Each sensor node starts in the gateway node and sends a control message (
Register.request) requesting its inclusion on the IoT network. The gateway node registers the new node and sends it the response (
Register.response), where indicated, the type of node in the network (sensor or routing node), according to the number of hops the message takes to reach the gateway node. If the sensor node is an end node, it gathers data from different sensors, sends them to the gateway node, and changes its status to sleep to save energy. If the sensor node is a routing node, the node is also responsible for retransmitting the data from other sensors, so the sensor nodes wake up using a timer or a routing transmission request. The sensor node changes its status from disconnected to setup status when it receives the response. Afterward, the sensor and gateway nodes exchange messages (
setup.request, and
setup.response) to establish the gathering time for each sensor. At that moment, a sensor node is ready to begin the data gathering, so its status changes to the
gathering status. In this status, the sensor nodes get sensor values, structure them into frames, and send them to the gateway node. When a sensor node gathers data from the different sensors, it sends a new message to the gateway node. SAgric-IoT uses the MAC data frame defined by IEEE 802.15.4 to build the message (
Figure 8).
The message contains frame control fields, destination address fields (in our case, we used 16-bit destination addresses), a data field where the data from the different sensors are included, and a checksum field to check that the message is not corrupted. This frame is sent to the gateway node through the data.transmit message. When the sensor node finishes sending data, it changes its status to Sleeping status (Sleep.on) to save energy for an established period. All sensors in the node and the microcontroller are off, and the node is considered a sleep node. When the sleeping time finishes, the sensor node wakes up and starts another data-gathering session from the sensors, or when the gateway node sends a request for information on data from the sensors. After the node gathers data and sends it to the gateway node, it goes to sleep again to save the battery (Sleep.on).
3.5. Convolutional Neural Network Model
The following paragraphs explain the proposed architecture for the plant leaf disease detection and classification model. The proposed model takes color images of plant leaves as input and displays the image with a series of labels representing the plant leaf health state (whether it is healthy or the name of the detected disease) and the prediction percentage value obtained by the model as output.
3.5.1. Dataset
We used the public PlantVillage dataset of 20,600 images in 10 categories, available at [
91].
Table 4 shows the categorized information contained in the dataset.
For the project, only the tomato categories were used to test the model (a total of 16,012 images) [
92]. The total dataset was divided into two parts, assigning 80% of the images for training (12,810 images) and the rest for validation (3202 images). The problem with the models is that during the training process, overfitting can occur (i.e., the model “memorizes” the dataset) [
93]. Thus, we applied a method known as data augmentation [
88] to increase the dataset. New images were created using transformation methods (rotation, brightness adjustment, and Gaussian noise) to complement the dataset.
3.5.2. Model Creation
A model based on a convolutional neural network architecture was developed for the plant disease detection process. The model takes color 200 × 200 images normalized to (0,1) as input for training and validation. The neural network architecture consists of five convolutional layers using 256, 128, 64, 32, and 16 filters, respectively. The kernel size for the 2D convolution window was 3 × 3. Rectified linear unit (ReLU) was used as the activation model for each convolutional layer. MaxPooling layers were applied to each convolutional layer. In addition, a global average pooling layer was applied to convert the data to a column vector. This layer is connected to a dense layer of 10 output nodes (which represent the categories used in the model) that uses softmax as the activation model.
3.5.3. Model Training
Table 5 shows the parameters for training the model and the Adam optimization algorithm. The model’s loss function was
categorical_cross_entropy, one of the most widely used functions for multi-class classification. The number of epochs was 200.
5. Conclusions
In this paper, we evaluated SAgric-IoT, an IoT platform, in terms of packet delivery ratio and energy consumption in a small-scale network under a controlled environment (laboratory) and test bed conditions in a field, including its embedded system, the communication protocol, and its algorithms. SAgric-IoT reduces the intensive human involvement required in current agricultural information collection systems and provides information in a faster way.
Results proved that SAgric-IoT is superior in energy saving and reliability of transmission. On the other hand, the CNN model for identifying diseases in the crop has high levels of accuracy, with average values greater than 95%. This value has an acceptable reliability level for detecting early disease problems affecting the yield. We conclude that SAgric-IoT is a viable solution to improve precision agriculture because it is a wireless platform that uses low-power algorithms for gathering data.
Our future work focuses on the platform’s security to avoid integrity problems with the collected data that cause a reduction in the quality or quantity of production.
Another significant challenge to solve in the next phase is to go from a model trained with images taken in the laboratory to images generated directly in the sowing field. Due to the lack of context and diversity in plant appearance, deep learning models trained on individual leaf photographs may need help identifying plant diseases in full plant images. However, several studies have shown that the use of a combination of leaf and full plant images, and the use of deep learning techniques, can improve the accuracy of plant disease detection.
For example, a study [
97] to detect tomato plant diseases used a convolutional neural network (CNN) trained with laboratory-taken leaf images and real-world leaf images. The real-world leaf includes other elements, such as stems and other leaves. With this combination of training, they achieved an accuracy rate of 99.53%. Another recent study [
98] used various images from a leaf dataset and manually taken photos, along with deep learning techniques, to detect diseases in grapevine plants and achieved over 80% accuracy in this mixed scenario.
In summary, a deep learning model trained only with images of a single leaf may have difficulties recognizing diseases in plants in pictures of a whole plant. Still, the combination of leaf and entire plant images, as well as deep learning techniques, can significantly improve accuracy in disease detection in plants.
In future work, the model will be trained with complete plant images and implemented in the real-time plant monitoring scenario. This way, it will be possible to check the crops’ conditions by leaf samples and directly monitor the plants from the images captured by the camera system, fully integrating it into the SAgric-IoT platform.