Keywords

1 Introduction

The proper definition of the much-hyped word “Internet of Things (IoT),” at its core, is the idea of its literal meaning, i.e., the self-connectivity of physical electronic devices or “things” [14], i.e., stuff that consist of sensors, electronics, softwares, and network connection modules, etc. which enable these objects to gather and interchange data with the user and among themselves. To simplify, it is an object or group of objects which is controlled or sensed remotely through and across an existing network setup which permits the combination of physical and digital world together. This, in turn, improves their accuracy and efficiency reducing human intervention. Upon addition of sensors, actuators, and other complementing hardware [21], the technology becomes a class of IOT systems, which comes under the technologies of today and that of future, such as smart homes, smart grids, intelligent thermostable environment, smart transportation, and smart cities [5].

In recent years a trend has been observed in the integration of the IoT in almost all the industrial sector. In popular culture it is being called the industrial revolution 4.0 [24]. The agricultural industry is no exception. Monitoring, aiding production, safeguarding harvest, etc. are some of the areas that have been using IoT in recent times [22]. With developing threats like water scarcity, more animal intuition, reduced harvests, etc., it is the time to look into sustainable methods of agriculture. Sustainable technology approaches are quite different from traditional system of agriculture. It makes smart use of limited water, nutrients, and resources like power. Alternative energy (like solar, wind,etc.) is used to power the machines in agriculture field [8].

The technologies that are powering the backbone of the IoT are in existence since a long time, but the expansion of their combined uses in such a technological advanced manner is the industry of the future [29]. The Radio Frequency Identification (RFID), Wireless Sensor Networks (WSN), Internet Protocol (IP), Low-power wide-area network protocol (LoRa), and Wireless Fidelity (Wi-Fi) are some of the examples of such system [14]. To understand the chapter better, some important parts of the IOT systems and some basic hardware are discussed too before diving deep into their use in agriculture.

Hardware

The backbone of IoT is the web of interconnected devices which are attached with sensors, actuators, relays, and various other transmission module that controls and senses the changes of physical world as data points. While using computer network for transmitting the data in real time, or after a certain temporal cycle, these devices need some basic processing, storage, and electrical proficiencies, provided by an integrated circuit, microcontroller, or a similar System on a Chip (SoC) or something like a field-programmable gate array (FPGA) [6].

Networking

Network designing and management are vital within and across IoT systems. It is important mainly because of two reasons. Firstly, the volume of connected devices is quite large so it impacts the network design decisions. Proper connection enables devices to communicate better with devices present or connected to the same network. Secondly, the network designing also plays a key role with running applications and web services that control the devices. It is important to have real-time data streaming for the appropriate functioning of the Internet of Things (IoT) system. The web infrastructure is used for data processing, storage, and analysis and also for the implementation of IoT applications [15].

Programming

Most of the IoT hardware are embedded devices. Often, they are prototyped using commercially available microcontroller platforms, i.e., Arduino, Raspberry Pi, etc. Prototyping an IoT system single-handedly requires circuit designing skills, microcontroller programming, and a complete understanding of hardware communication systems like serial, I2C, SPI, etc. They are traditionally programmed using C++ or C. However, in current years Python and other similar languages are becoming more popular for use in IoT devices.

Artificial Intelligence and Machine Learning

To visualize and conclude important insight from the data that is produced by IoT devices, computer-aided approach such as AI and machine learning plays an important role in IoT development. To become a real-world usable system from a lab-based prototype, different techniques such as data mining, statistics, visualizations, machine learning, modeling, etc. along with AI implementation are essential. These methodologies are functional in real-time feed into sensor data streams to perform predictive analysis, which in turn will help in making decisions autonomously [1].

Analytics

The amount of IoT devices increases on a daily basis. It is one of the issues for the development. The data accumulated needs to be analyzed, stored, and visualized for inferences and predictions. The vast amounts of data originating from these devices pose a problem for its use. Hence the use of analytics is also an important part for the same [19]. Also, it is seen that many IoT devices face latency in time-sensitive data. Thus, it is also needed to filter or reject irrelevant data.

2 Basic IoT Hardware Used in Agriculture

The use of IoT-based irrigation system has gained popularity in recent times; over the last few years, embedded system is used extensively to make agriculture automated and easy with little supervision. In scientific literature, some the following hardware are seen as a vital component for almost all embedded systems. The use of these hardware are seen in some of the studies which uses the IoT approach in sustainable and smart agriculture [19].

Raspberry Pi

Embedded boards liked Raspberry Pi in Fig. 1 or Arduino in Fig. 2 are the vital components of the system. One could argue this as the brains of “the system.” It works on the Raspbian operating system which is installed via a microSD card. The other sensors are connected to the board along with the power supply [2].

Fig. 1
figure 1

Raspberry Pi 4B

Fig. 2
figure 2

Arduino Uno

All the data that are collected through the different sensors are processed in the microprocessor of the main unit, and those values are sent to the web or phone via any Internet of Things application or by using an application programming interface (API). The data is sent using the HTTP and MQTT protocol over the Internet or via a Local Area Network. All the other programs related to the IoT are loaded into the microSD, and using the feeds from the different sensors the required action is implemented.

Temperature and Humidity Sensor

The temperature and humidity sensors in Fig. 3 are both an important part of the system which measures the temperature and humidity of the soil. One of the most used sensors is the DHT11 Temperature and Humidity Sensor Module. It uses a capacitive sensor for humidity detection and a thermostat to measure the surrounding; it produces a digital signal on the data pin. Apart from this, the other sensors like the LM35 Temperature Sensor and DS18B20 Temperature Sensor Probe can also be used. For detection of soil humidity, Soil Hygrometer Humidity Detector can be used as a separate sensor.

Fig. 3
figure 3

DHT11 Temperature and Humidity Sensor

Motor and Switch

Motor in Fig. 4 can be used for supplying the water for irrigation, when water level is below a certain level. When the moisture content is less in the soil, this motor is used to turn on the sprinklers.

Fig. 4
figure 4

Motor

Camera/Arduino Camera Module

The cameras in Fig. 5 are used for a variety of purposes, such as looking at the plant condition, security, and also for capturing animal intrusion in real time. An aiding system can be of the infrared (IR) sensor which can detect this and start an alarm while the camera records or streams so that the user can know what kind of animal is in the farm or field. This image/video can be processed by using libraries like OpenCV, SimpleCV, Mahotas, etc. Further classification can be done by using algorithm like Scikit-learn, convolutional neural network (CNN), support vector machine (SVM), etc. To find out the animal real time, a huge noise can be triggered to drive away the animal.

Fig. 5
figure 5

Arduino camera module

Infrared Sensor

The purpose of this sensor in Fig. 6 is to detect movement of animals if they are inside the area. Such similar approach is seen in wildlife monitoring, which can be extrapolated and used into the agricultural protection; the only issue in this arrangement is that it will increase the cost. Further an alarm system can be made to send text/mail so that the user is alerted.

Fig. 6
figure 6

HC-SR505 Mini Infrared PIR Motion Sensor Infrared Detector

Rain Sensor

The rain sensor in Fig. 7 is essential as it reduces the wastage of water. Upon rainfall, this sensor detects the droplets of the rain and switches off the sprinkler or the irrigation pump.

Fig. 7
figure 7

Raindrop sensor module

Siren/Flashlights

The siren or flashlights are an essential for the creation of a system grazing animal-proof system. Upon intrusion, movement can be detected by the IR sensors, and then the smart alarm system can be relayed to be activated based on that signal feed (Fig. 8).

Fig. 8
figure 8

Siren/horn

3 Algorithms Used in IoT

Some of the prominent works in these fields have been done using simple components like Raspberry Pi 3, Arduino, and simple programmable embedding boards. Fully or even partially automated systems, however, make use of other sophisticated techniques like artificial intelligence (AI), machine learning (ML) techniques, etc. and algorithms, like principal component analysis (PCA), linear discriminant [28] analysis (LDA), convolutional neural network (CNN), regression modeling and fuzzy logic, etc.

Principal Component Analysis (PCA)

PCA or principal component analysis can simply be explained as a perpendicular, linear transformation system that converts each of the new data to an improved, new, simplified coordinate system in such a way that the greatest variance by the data clusters on each of the coordinate system [11]. In this way, the data corresponding to the very first coordinate (called the first principal component) has the most variation, second one has the second most, and so on. The components with the highest variation consist of most of the information regarding the classification task. Each of these components is influenced by all of the features of the system (feed data from various sensors), and the ones which influences the components the most are the most important ones which contributes to the classification. The orientation of the first PC is such that geometrically it causes greatest variance in the dataset, hence retaining the maximum classification information.

Linear Discriminant Analysis (LDA)

LDA is also related to principal component analysis (PCA) and factor analysis, as in that algorithm, they both look for combinations that are linear in nature, of variables which best explain the data. However, instead of just looking into the variation like PCA, LDA organizes a much simpler method to “fit” the required data points (variables) in such a way that there is maximum clear distinction based on the difference between the classes of data. LDA is best suited when the quantities made on independent variables for each observation are continuous quantities [28].

Convolutional Neural Network (CNN)

Convolutional neural network has gained popularity for the analysis image data. It is currently one of the best algorithms for detecting image diagnostics or image embedded object. The IoT systems use the CNN algorithm to identify the pests like wild animals, so that one could be alerted when they approach the field. The model can be pre-trained using datasets of various animals so that upon requirement this model can fetch the identity of the pest and so the user can prepare accordingly. Upon detection of the trained animals, the model will clearly show the result. To improve this system, OpenCV can be used which has some elevated capabilities for better resolution processing, which will aid in this process. Works in this sector are quite limited as most model suffers from natural lighting issues which limits the proper functioning of the system.

Support Vector Clustering (SVC)

The use of clustering is to divide and segment “scattered” or “unorganized” dataset into separate groups of similar parameters to organize the data into a more expressive form based on some criteria. In our case, all the sensor readings are fed to the microcontroller to perform the decision making. Once that is done, it moves to the next phase where the sensor values of humidity, temperature, and soil moisture sensor are uploaded to a web application or to some connected device. The training set and testing set (usually, 20% of data for testing set and 80% of data for training set) is implemented, depending upon the datasets formed by the continuous feed. The SVC model is able make predictions about the field parameters such as water requirements [13].

4 Application of IoT in Agriculure

Like many other industries, Internet of Things (IoT) has entered in agriculture and has flourished as well. Some of the important uses that are worth mentioning in are variable rate irrigation (VRI) optimization, automated evaluation crop health, monitoring of progress, irrigation, spraying harvest and pest and animal intrusion monitoring, etc. However, the extended discussion of all of those systems is quite lengthy and is loosely bound with respect to this chapter. Hence, we’ll keep our discussions limited to the irrigation, crop pH, and animal intrusion management.

Over the last few years, a steady attention in this field has been observed. The table provided below is a short summery of some of the recent advancements of the use of computer-aided system in agriculture. The list is not all inclusive; efforts were made to keep the summery table relevant to the chapter objective, and any deviation that is perceived as important in IoT has been included as shown in Table 1.

Table 1 Some of the notable development in application of IoT in agriculture

Irrigation

Irrigation is one of the essential commodities that directly affect the harvest. Water is essential for any form of crop production. The shortage of irrigatable water worldwide has created a need for its optimum utilization. Researchers are keenly looking into different approaches to solve the issue of sustainable water use in agriculture. It is estimated that 844 million people don’t have access to clean drinking water [10]. Earlier, traditional methods were used to improve the water use in agriculture [20]. With the development of automation systems, methods like artificial intelligence, machine learning, and Internet of Things (IoT) came into play. IoT is built for using sensors’ data acquisition and intelligent decision-making technology to integrate the digital and physical systems to provide result. Hence, system based on IoT can help in achieving optimum water use in smart agriculture. The development of smart system for the prediction of the irrigation must take the account of the various parameters like temperature, moisture, and weather conditions. The efficient use of water in an agricultural field is one of the major hurdles that IoT-based technologies are keen on achieving. To accomplish the efficient use of the water, agronomists, agrobiologists, and engineers rely on information from different sources (plant, soil, and atmosphere) to properly manage and mitigate the requirements of the crops.

This is generally done by using an automated system . The system, in its heart, has mainly three parts, a sensing node (sensor), an evaluative pre-programmed board (Raspberry Pi, Arduino, etc.), and a implementation (switch on/off) unit. The sensing nodes are involved in sensing the ground and environmental parameters (temperature, moisture, pH, etc.). This information is often expressed by a set of predefined variables, which are measured using the aforementioned sensors. Then, they are evaluated by programs to characterize the status of the matrix (soil in the case of regular farming or water in the case of aquaponics) to correctly obtain their water levels, nutrient requirements, or other physiological needs like total dissolved solids (TDS), dissolved oxygen (DO), biological oxygen demand (BOD), etc. While meteorological variables (moisture, temperature, light density, etc.) of an area are easily measured by a single sensor, or by a group of sensors for a vast area, the soil type and vegetation cover creates a large variability. Monitoring other variables, such as hydrodynamic factors like water drainage, terrain elevation, etc., might increase the chances of successful implementation of the models obtained by the system. Hence, the usage of sensors which detect the water status is an important complement to modulate the water requirements for the harvest. The systems developed have three core parts, namely , a detection unit, a decision unit, and a deployment unit (Fig. 9).

Fig. 9
figure 9

As can be seen easily from the diagram, this is a simplified version of the usual IoT arrangements

Animal Intuition Management

Apart from the environmental factors, detection of small to large animals is important which causes problem to farmlands that share borders with forests or animal routes. Animals such as elephants, cows, deer, and monkeys are often seen feeding from easily available farmland or agricultural fields. The increase of non-regulated developmental activities such as construction of road, railways, and power projects is disrupting the natural environment and is contributing to the breakup of large forest covers. Moreover, clearing of forestland for agriculture and creation of human settlements, plantations, etc. often results in forests being divided into smaller patches. The wild animals present in these segmented forests are left with very little resources and often have no choice but to come to the human settlements for food and shelter leading to intrusion [7].

Researchers all over the world have tried to develop various methods of prevention of animal intrusion using methodologies like computer vision, infrared sensors, ultrasonic emitters , etc. The most common system that is suggested is that a sensor senses the entry of wild animals into the field and produces a noise or flash of light or ultrasonic waves to drive them away. The use of ultrasonic sound waves is beneficial as it is inaudible to humans [27].

pH Control

Another important factor in agriculture is the pH of the soil. The water, which is being supplied to the field for irrigation, is often used as a means for providing fertilizers. Hence it is important to have a check and balance in the system so that the pH doesn’t reach any extremes. We developed an automated pH control algorithm for using in IoT systems to keep the pH under control.

Automated pH Control System

Sodium hydroxide to increase the pH of acidic solutions or hydrochloric acid to decrease the pH of alkaline solutions is a widely used chemical for pH control. Make sure that you use goods for hydroponic systems that are formulated. You may add weak acids such as vinegar or citric acid for limited systems or short-term effects. Automatic pH controllers cost more than products with pH up or pH down, but they maintain pH at consistent levels. The treatment process of soda ash/sodium hydroxide injection is used if water is acidic. When injected into a water stream, soda ash (sodium carbonate) and sodium hydroxide boost the pH of water to near neutral.

In human body, by releasing carbon dioxide the, lungs regulate the pH balance of the body. Carbon dioxide is a compound that is slightly acidic. It’s also a waste product that cells in the body generate when they use oxygen. It’s released into the blood by the cells, and it’s taken to the lungs. Using hydroxyl ion source in water-base mud to regulate pH is shown in Table 2.

Table 2 Hydroxyl ion source in water-base mud to regulate pH

To preserve or raise pH, caustic soda is used. Increasing pH precipitates magnesium (Mg2+) with caustic soda and suppresses calcium (Ca2+) in high-hard waters such as seawater. It also decreases corrosion and neutralizes acid gases such as carbon dioxide (CO2) and hydrogen sulfide (H2S). Typical concentrations vary from 0.25 to 4 lbm/bbl [0.7 to 11.4 kg/m3] depending on water chemistry and drilling fluid type, with treatments. A higher concentration of caustic soda is required in marine water and waters containing buffering salts. To precipitate all magnesium, the Gulf of Mexico seawater takes 1.5 to 2 lbm/bbl [4.3 to 5.7 kg/m3] to transform the calcium to lime as shown in Fig. 10.

Fig 10
figure 10

pH vs caustic soda concentration and calcium solubility vs caustic soda concentration

The appropriate pH is between 5.5 and 6.5 in the hydroponics method. This system requires manpower to maintain its equilibrium. If the user of the reservoir tests it periodically and adds acid or base accordingly, the eqileberium is easily maintained. In cases, where plants can be affected by a wrong pH level and its concentration, a nutrient lock is also triggered to protect such incidents from happening. Here we suggested an AI-based system that operates automatically on the prediction model and with few components to balance pH value. This technique is even less difficult and has a chip to execute.

Data Collection

The main component is data for creating an AI-based application. We are preparing a system that has 20 liters of water capacity and set up with one cucumber and two tomato plants to collect the real-time pH data. The entire setup was DWC architecture and connected to an air stone that runs every 30 minutes for 10 minutes. We placed a pH electrode and an onboard computer (Raspberry Pi) to process the data to obtain the pH value. As the pH sensor comes in UART mode, jumpers are added to turn it into a Raspberry Pi-compliant i2c mode. In the method, the electronic computer was assembled with regular running routines that read and store the data in the device itself. The device runs for all three months to collect real-time data from five different stages of growth of the plant. We found that pH imbalance is not common during the running time, so we added some bases to get data read. We choose two small water pumps in the second portion, capable of pumping 50 ml of liquid in 5 seconds. To get the running time, both of them are linked to the Raspberry Pi kit and the trigger is fixed with a web service endpoint to start and stop. For pH level 7.2 to 6.5, we measure that 10 ml of acid is required to be added to 1 liter of water where 200 ml of acid is needed for 20 liters of reservoir. We also developed diluted base solutions in the case of the base to simplify the operation, where the 2nd pump is connected to the base solution.

The optimized machine runs with a pumping time of 0 seconds every day for reading and runs manually when we need to apply the acid or base to maintain the pH level in seconds with the right pump running time. We gathered data with the attribute pH value, pump A running time, and pump B running time after the complete growth period. To visualize the pH spike and pump running time, we use the data analysis process. Figure 11 shows the spikes and the Table includes the sample data we obtained (Table 3).

Fig. 11
figure 11

Value of pH with pump time running

Table 3 pH dataset demonstration in real time

Study of Correlation

We evaluated the association between the pH value and the running time of each pump here. We find that both running times are associated with a positive correlation of pump B running time and a negative correlation of pump A with pH value. Figure 12 is a demonstration of the configuration of the entire device.

Fig. 12
figure 12

Demonstration of the whole process

Dataset

The created dataset contains 90 collected data dates with three attributes such as pH value, pump A runtime, and pump B runtime. We split the dataset into two separate sections during the preprocessing section, with two columns holding the pH value and one pump running time in each sub-data set. Each subset contains 90 records where the independent variable is the pH value and the dependent variable is the pump operating time.

Model Generation

We need to predict the running time of the pump here as the length of seconds, where a value is the predicted attribute. So we’ll turn to the mechanism of regression. To implement the model with distinct algorithms, we used Python libraries. In this method, we introduced linear regression, support vector regression, and K-nearest neighbor regression according to the data attribute, where 90% of the prediction precision is provided by linear regression. And KNN has 73% and SVR has 60% of the precision of the model. It was seen in Chat in Fig.13.

Fig. 13
figure 13

Precision of the model

Final Installation

We selected a linear regression model after testing the model to predict the running duration of the pump. We prepared two triggers for the pump to operate as both the model produced separately for both the pump. The Algorithm-1 is designed to deploy the model and other features, such as calculation, initialization of the input value, pump triggers, etc.

Algorithm-1: For Final Installation

Step-1:

  • Water contains in the liter ← Input

Step-2:

  • Load_model(model_A, model_B)

  • (where model_A is for pump_A and model_B is for pump_B)

Step-3:

  • pH_value ←- read from the sensor

  • predict _value for pump_A = model_A.predict(Ph_value)

  • predict _value for pump_B = model_B.predict(Ph_value)

  • (Here ph value is read in each day and then the duration of pump A and B is predicted from the ML model.)

Step-4:

  • predicted_value_A = total_amount_of_water*predict_A

  • predicted_value_A = total_amount_of_water*predict_A

  • (Here the duration of predicted value is for one letter so it’s recalculated according to the amount of water input.)

  • Run_triger_with duration(predicted_value_A, pump_A)

  • Run_triger_with duration(predicted_value_B, pump_B)

  • (Here pump running method is called based on the predicted duration that is obtained.)

For the same test setup with the same plant where positive results are observed, this approach is used for the same setup. The greatest benefit of this method is its flexibility and lower cost. The device architecture is also compatible for any volume of water as the value is predicted to be set to 1 liter of the unit length. We have checked the method with rising greens where, with less effort, we find very good results. It can be flexible in large-scale applications by adjusting the volume of input water. It is absolutely reliant on the air stone in DWC, water in-out as a drip system, or NFT, as it does not have a diluting function. In Kratky’s architecture, the mechanism would fail.

5 Result and Discussion

The study conducted based on the pH parameters of an agricultural system yielded us the required inference. The process was able to become a low-cost method of the regulation of pH. The system consisted of two pumps which, upon detection on the pH value to either too acidic or basic sides, switches itself on and maintains a somewhat neutral area. Our work was based on an aquaponics system. The results so obtained were satisfactory with respect to the time interval.

To sum up, use of IoT in agriculture is the new addition to agricultural system’s ever-growing development. A lot of contributions to this field can be seen. It is assumed that a diverse plethora of individuals are being benefited by the technology, small farmers, high-tech agricultural fields, plantations, farms, greenhouses, hydroponics farmers, etc. are using IoT to their advantage. This chapter looks into the various methodologies that are used in irrigation and development of intrusion-proof farms. Our work in the area of pH management is in alignment with the previous systems that has been developed.

6 Conclusion and Future Work

The overall conclusion of the work done so far summarizes a smooth path for the development of IoT in agriculture. With the development of cheaper electronics, we hope that one day agriculture will be able to work as smooth as the other IoT technologies. With smart lighting, pH management, irrigation, and animal intrusion-proof systems, the yield is expected to increase in smart agriculture with lesser efforts and costs.