Smart Farming Enabled by Fuzzy Logic-Controlled Wireless Sensor Networks

Smart Farming Enabled by Fuzzy Logic-Controlled Wireless Sensor Networks

Zahraa S. Kareem* Gregor A. Aramice Abbas H. Miry

Electrical Engineering Department, College of Engineering, Mustansiriyah University, Baghdad 10001, Iraq

Corresponding Author Email: 
zahraasameer96@uomustansiriyah.edu.iq
Page: 
1041-1058
|
DOI: 
https://doi.org/10.18280/jesa.580517
Received: 
6 April 2025
|
Revised: 
13 May 2025
|
Accepted: 
24 May 2025
|
Available online: 
31 May 2025
| Citation

© 2025 The authors. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

Sometimes, traditional irrigation mismanages water, wasting resources and harming yields. An automated irrigation system adjusts based on soil needs. This boosts productivity while conserving water and energy. Traditional methods falter due to inconsistent management. Fuzzy logic was used to optimize watering timing. We crafted a fuzzy logic controller (FLC) on a Raspberry Pi using sensor data for irrigation timing. Twenty-seven fuzzy rules were developed after establishing the membership function. This automated system waters precisely, enhancing crop yield autonomously. Watering halts when soil moisture is adequate and resumes when it dips. The Raspberry Pi fuzzy logic boasts a mere 1.184% error, achieving a stellar 98.816% accuracy compared to MATLAB. Manual control had an even lower average error of 0.838%, reaching 99.162% accuracy. The system features advanced innovations, particularly through the effective application of fuzzy logic rules on Raspberry in Baghdad, Iraq, during the dry winter season marked by limited rainfall. It adapts swiftly to changing weather, responding quickly to temperature and humidity shifts. The study shows this smart irrigation saves resources, achieving 52.5% less water usage and 80.8% energy savings compared to old methods. Plus, it only costs $217, a thrifty alternative to traditional irrigation.

Keywords: 

wireless sensor networks (WSNs), Internet of Things (IoT), fuzzy logic control (FLC), artificial intelligence (AI)

1. Introduction

Agriculture is one of the most vital events directly impacting food security and the global economy. With the ever-increasing population and climate change, it has become imperative to provide multiple technological solutions that contribute to enabling efficient agricultural production and reducing waste of resources, such as water, energy, and many other factors.

In mature and emerging economies, agriculture contributes considerably to GDP. By 2050, the world population may exceed 10 billion. To feed this growing population, food output must increase by 70%. Sustainable agriculture is essential for food security in a rising population. Sustainable agriculture increases output while minimizing environmental impact from inadequate farming. Innovative agricultural methods frequently lag in demand and require substantial research and development to achieve sustainable agriculture goals. Farming requires attention to irrigation. Overirrigation uses 70% of freshwater. Internet of Things (IoT) and AI can monitor, regulate, and plan agricultural irrigation systems efficiently [1].

The rapid development of the IoT and artificial intelligence (AI) has led to the concept of "Artificial Intelligence of Things" (AIoT). The integration of AI and the IoT allows devices with specific features to sense and transmit data over the network. Data can be analyzed and reacted to in real time using AI. Advanced AI models processing massive amounts of data enable human-like automated decision-making. AIoT can choose machine settings according to human learning. This technological evolution has produced several neural architectures designed for different settings [2].

The lack of wireless sensor networks (WSN) in modern irrigation systems [3, 4] faces many challenges, including poor water and energy use, inability to react dynamically to changing environmental factors, inability to modify the environment, and unreliable data transmission. We solved these problems with wireless Wi-Fi networks in our innovative solution. This technology allows precise irrigation scheduling based on ongoing surveillance of diverse environmental parameters and instantaneous control, improving water and energy efficiency, addressing water scarcity, and lowering operational costs. These growth-oriented networks can be customized for different field sizes and crop types, making them adaptable to different agricultural contexts.

Wireless sensor networks (WSN) must be included in IoT systems if we are to solve communication issues and improve agricultural practices [5]. The combination of AI with advances in wireless communication offers smart decision-making assistance for irrigation systems, hence enabling remote monitoring and administration [6]. Advancements in (WSNs) have helped to influence creative trends in the agricultural industry. In precision agriculture, WSNs have been the favored choice as sensor technology has shrunk in size and cost. These networks are used not only in conventional agriculture but also in sectors including horticulture, animal husbandry, and wine growing. Using WSNs in these domains aims first to enhance quality and production [7].

This research proposes the design of a smart irrigation system based on Internet of Things (IoT) and fuzzy logic technologies to improve water and energy efficiency in agriculture. The system focuses on analyzing environmental data such as temperature, humidity, and soil moisture to make automated decisions regarding irrigation timing and duration.

The research contributions can be encapsulated as follows:

  • The significance of accurately estimating the requisite water volume for soil irrigation, which is adequate for the soil, plays a crucial role in promoting water conservation and mitigating waste.
  • A correlation has been established among air temperature, humidity, and soil moisture, highlighting a direct interrelationship among these variables to ascertain the necessary irrigation for the soil. This data is integrated into the Internet of Things (IoT), offering an intuitive interface for novice farmers to effectively oversee their agricultural practices as required.
  • The proposed system facilitates irrigation management via a fuzzy inference mechanism, utilizing sensor data to determine water pump activation, thereby minimizing water and electricity wastage while ensuring automatic motor deactivation upon adequate soil moisture, thus enabling real-time management and reducing labour costs through the elimination of human involvement.

The research is divided into eight sections. The first section discusses a general introduction, the problem deviation in the second section and the objective in the third section, while the fourth section includes previous studies. The fifth section covers the methodologies. The sixth section is about the proposed system, while the seventh section discusses the results and discussions. We conclude the research in the eighth section.

2. Problem Deviation

Some problems with traditional methods are:

  • Too much waste and water loss because the soil's real needs aren't being properly assessed, which means that the soil stays too wet, which could hurt plants or cause the growth of sick and unhealthy plants.
  • The irrigation system runs for too long, which wastes electricity.
  • The need for workers to regulate the motor and irrigate the soil, which raises costs.
3. Objective

A smart irrigation system based on fuzzy logic has been put in place to deal with the problems listed above. This new method figures out how long it takes to properly irrigate the land. The technology will turn off the irrigation system when the soil reaches the right amount of moisture and turn it back on when the moisture level drops below the specified level. The system changes the amount of time it needs to water based on things like the temperature and humidity in the air and the moisture levels in the soil. This method makes sure that both water and power are saved while also cutting down on the requirement for physical work.

4. Literature Review

Imteaj et al. [8] studied an automated irrigation system employing technologies such as Raspberry Pi 3, Arduino microcontrollers, Wi-Fi modules, GSM shields, relay boards, and various sensors. This integration facilitates a reliable and effective irrigation solution. By assessing soil moisture and light intensity, the system maximizes the timing of tree watering, hence fulfilling plant hydration requirements. The technology also alerts the administrator to any water supply deficits. By use of particular phrase commands, it allows SMS communication with the administrator, hence enhancing irrigation management and control.

Alhasnawi et al. [9] discussed an IoT-based network concept connecting agricultural uses to rural communities. Irrigation efficiency and agricultural practice development depend on this. The system uses many sensors—including temperature, humidity, and soil moisture—combined with valves. Working together, these parts offer an adaptive smart irrigation system appropriate for plant needs and environmental changes. Essential for system functioning, the paper explains the protocols governing Terminal Units (TU) and Base Station Unit (BSU). The BSU processes data from TUs tracking necessary parameters for efficient watering.

Abdullah et al. [10] presents the concept of smart farming leveraging IoT technologies. Smartphone apps enable farmers to track significant environmental variables. These qualities are quite crucial for optimal plant development. The paper suggests a method based on user-defined criteria employing advanced fuzzy logic to manage pump operation timing.

Covering tomato crop management and monitoring, the study looks at how DL and IoT technologies are used in agriculture [11]. The paper emphasizes how IoT allows tracking of environmental elements influencing the life of plants. Ideal crop growth is determined by three extremely significant variables: temperature, humidity, and soil moisture. The device offers farmers automated irrigation and remote crop watering. This characteristic defines suitable circumstances for plant growth and efficient management of water resources. The main objective is to develop a smartphone application using a CNN to identify problems in tomato plants. This program aims to help farmers properly control and identify plant diseases.

Irwanto et al. [12] investigate the extent to which the IoT influences agricultural productivity, particularly through autonomous decision-making. This is crucial in that region since growing mushrooms requires certain weather conditions. The light-dependent resistor (LDR), passive infrared receiver (PIR), capacitive soil moisture sensor (CSMS), and DHT22 sensor are just a few of the several sensors utilized by the system. Based on the information gathered by these sensors, judgments are made about the substrate's watering, environmental regulation, lighting management, and insect detection. Fuzzy logic (FL) could improve the responsiveness of decision-making using sensor data in the IoT architecture.

Separating sensor networks into static and dynamic clusters is novel model design [13]. A master node and several member nodes that serve as its subordinates comprise each cluster. To improve the efficiency of data transmission, it is helpful to choose the main node so that member nodes are closer together. The primary node receives data on soil moisture and temperature from the member nodes, which use the DHT22 sensor to collect this information. Upon receiving readings from other nodes, the central node checks the data for correctness and notes any mistakes it finds. Aside from communicating with a gateway/base station or another cluster coordinator to start irrigation, it also updates its cloud database, makes decisions, and analyzes data. Data is stored locally in CSV format by both the gateway and the main nodes. The sender's MAC address, date, and time are logged as well. Each entity—including the main nodes, member nodes, and the gateway—represents Raspberry Pi 3B+, a low-power single-board computer able to endure harsh environments.  BLE 4.2 is the way to go for communication within member node clusters; LORA is the way to go for communications with base stations for off-site signal propagation.  This system is powered by rechargeable solar energy banks, hence ensuring its efficiency and sustainability. Monitoring other factors, such energy consumption and Bluetooth signal strength, helps to maintain optimal distances between network components and improve operational efficiency.

5. Methodologies

5.1 Sensors and communication technologies

5.1.1 DHT11

The DHT-11 is an integrated sensor designed for the measurement of ambient temperature and humidity levels. It employs capacitive technology for humidity detection. The implementation of specialized digital module collection methodologies, in conjunction with humidity and temperature sensing techniques, guarantees that the device exhibits remarkable long-term stability and a high degree of reliability [14].

5.1.2 Soil moisture

Soil moisture sensors are utilized to assess the hydration levels and moisture content within the soil for plant life [15]. These sensors predominantly operate on two separate principles: tension-based sensors (Tensiometer, Granular Matrix Sensor) and sensors that quantify soil moisture content (Time Domain Reflectometry, Capacitive sensor) [16]. There exist two classifications of soil moisture detection instruments: (Resistive Soil Moisture Sensor, Capacitive Soil Moisture Sensor) [17].

5.1.3 Wi-Fi

IEEE 802.11-based wireless LANs are created [18]. Wi-Fi has become popular in many fields as technology has advanced. Wi-Fi has high data transmission speeds, signal range, and bandwidth. The technology relies on bandwidth, and signal interruptions could cause operational failures [19]. Lack of data protection makes Wi-Fi vulnerable to breaches and data loss in agricultural monitoring. Wi-Fi can't handle large amounts of agricultural data. Its networking capacity is limited to dozens of devices, making it unsuitable for large irrigation systems [19]. This technology carefully configures data packets across 2.4 to 60 GHz radio frequencies. Wi-Fi is popular across many devices due to its long operational range, usually 3–7 km, facilitated by a high-performance transmitting antenna, and its 700 Mbps data transfer rates [20].

5.2 Processing unit

5.2.1 Arduino Uno R4 Wi-Fi

The Arduino® UNO R4 Wi-Fi is the first UNO board to feature a 32-bit microcontroller and an ESP32-S3 Wi-Fi® module (ESP32-S3-MINI-1-N8). It features a RA4M1 series microcontroller from Renesas (R7FA4M1AB3CFM#AA0), based on a 48 MHz Arm® Cortex®-M4 microprocessor. The UNO R4 Wi-Fi's memory is larger than its predecessors, with 256 kB flash, 32 kB SRAM and 8 kB of EEPROM. The RA4M1's operating voltage is fixed at 5 V, whereas the ESP32-S3 module is 3.3 V. Communication between these two MCUs is performed via a logic level translator (TXB0108DQSR).

5.2.2 Raspberry Pi

A budget-friendly, compact Linux-operated circuit board, which is capable of interfacing with a monitor and keyboard/mouse, presents an economical approach for engaging with electronic systems while simultaneously serving as a platform for programming or even facilitating basic web services. It is imperative to note that this device lacks analogue input capabilities in contrast to the Arduino, thus necessitating the utilization of an external Analog-to-Digital Converter (ADC) or an interfacing board to achieve such functions. MySQL can be integrated within the board whereby a General-Purpose Input/Output (GPIO) pin may function as either a digital Input or output, both of which operate at a voltage level of 3.3V [21].

5.3 IoT ThingSpeak platform

ThingSpeak is an IoT platform that facilitates data storage, visualization, and analysis from devices. The platform accommodates MATLAB code, allowing advanced data analyses. ThingSpeak features event triggers known as ThingSpeak applications (apps). These applications are employed to manipulate and visualize data or initiate actions upon specific data insert conditions [22].

5.4 Decision of irrigation management

The decision-making process in irrigation management through fuzzy logic (FL), established by Lofti Zadeh in 1965, extends Boolean logic. This framework generalizes classical set theory while challenging modal logic principles due to its digital nature. It introduces a confidence principle that allows conditions to exist beyond binary true or false states. FL enhances flexibility and allows for the formulation of rules in natural language [23].

6. Proposed System

6.1 Implementation of the suggested model

The suggested system has two Sub-Nodes, which are Arduino Uno R4 Wi-Fi, and a Head-Node, which is Raspberry Pi. Each sub-node has a motor pump and sensors that measure temperature and humidity (DHT11) and soil moisture. Figure 1 shows the framework that was suggested, and Figure 2 shows how it was put into action.

The planned system will happen in a sequence of steps:

1. Collecting data: The linked sensors on the Arduino devices carefully record values of temperature, humidity, and soil moisture.

2. Data relay: The Wi-Fi network sends this information to the Raspberry Pi module using the MQTT protocol. The MQTT protocol was used to send data to and from the Raspberry, making sure that communication was quick and effective.

3. Data interpretation: The Raspberry Pi uses Fuzzy Logic to look at the data and figure out if irrigation is needed.

4. Decision and action: The Raspberry Pi sends orders to the Arduino devices to turn on or off the irrigation motor based on the results of the study.

5. Transmit your input and output information to the ThingSpeak platform using the HTTP protocol.

Figure 1. The circuit of the proposed system

Figure 2. The execution of the suggested framework

6.1.1 The flowchart of the sub-nodes and head-node

The flowchart in Figure 3(a) illustrates the Sub-Nodes, which are crucial for system operation by monitoring vital parameters like soil moisture, humidity, and temperature and transmitting this data to the Head-Node, whose flowchart is presented in Figure 3(b).

(a)

(b)

Figure 3. The flowchart of the: (a) Sub-nodes (Arduino Uno R4 Wi-Fi) (b) Head-node (Raspberry Pi)

6.2 Process of the fuzzy logic system

At first, the motor was switched on and off by hand to water the land for training. Then, AI was utilized, and the fuzzy logic control software was set up to automatically run the motor for a set amount of time to save water. The fuzzy control mechanisms used the Mamdani inference method, which is shown in Figure 4. This figure shows the internal structure of the fuzzy reasoning system that was made to control the water pump's operation. The first step in the fuzzy logic controller (FLC) is to get information from different sensors that keep an eye on the weather, such as temperature, humidity, and soil moisture levels.

Figure 4. The structure of a FLC

We use sensor data to come up with fuzzification guidelines. The moisture sensor makes it easier to figure out how much water is needed. When the soil's moisture level drops below a certain point, irrigation starts. Fuzzy reasoning figures out how long to water the plants to keep the water cycle in check. The rule-based method finds the best length and frequency of irrigation. The FLC that is being recommended uses triangle and trapezoidal functions, as well as segmented linear affiliation functions, to carry out the fuzzification process. The triangle function and the trapezoidal function are two of the most well-known membership functions. They are shown in Eqs. (1) and (2) below [24]:

$\begin{gathered}\frac{\zeta-a}{b-a}  \quad a \leq \zeta \leq b \\ X(\zeta)=F(a, b, c)=\frac{c-\zeta}{c-b}  \quad  b \leq \zeta \leq c \\ 0  \quad otherwise\end{gathered}$              (1)

$\begin{gathered}\frac{\zeta-a}{b-a} \quad a \leq \zeta \leq b \\ X(\zeta)=F(a, b, c, d)=\frac{d-\zeta}{d-c} \quad c \leq \zeta \leq d \\ 1 \quad b \leq \zeta \leq c \\ 0 \quad  otherwise \end{gathered}$               (2)

The nebulous variable x, which encompasses the magnitude of ζ, relies heavily on the definitions of the membership functions.

Tables 1-4 provide essential input and output values.

The fuzzy logic program was applied on the Raspberry Pi using Python, where sensor data was sent from the sub-nodes to the Raspberry Pi via Wi-Fi. Based on this data, the Raspberry Pi decides whether to turn the motor on or off and sends the command to operate or shut down the motor to the sub-nodes via Wi-Fi. Additionally, the Raspberry Pi sends sensor data to the platform for display on a smartphone. MATLAB was also used to plot the input and output, referred to as Figure 5.

In the context of membership characteristics, each input variable is characterized by three distinct membership characteristics, comprising a pair of trapezoids and a single triangle configuration. The initial input variable, humidity, is delineated through three fuzzy sets {low, medium, high}, while the subsequent input variable, temperature, is similarly represented by three fuzzy sets {low, medium, high}. The third input variable, soil moisture, is categorized into three fuzzy sets {dry, moderate, wet}, and the output variable, designated as the motor time, is characterized by five distinct membership characteristics, comprising a pair of trapezoids and a three-triangle configuration, and five linguistic values are incorporated {very low, low, medium, high, very high}. Figure 6 elucidates the specifics regarding the employed membership characteristics and the grand expanse of conversation. Soil moisture refers to the water retained within the soil matrix, which is subject to the influences of rainfall, soil, temperature, and additional elements.

Table 1. Temperature threshold

Temperature (℃)

Category

0-22

low

17-27

medium

22-32

high

Table 2. Humidity threshold

Humidity (%)

Category

0-57

low

23-91

medium

57-100

high

Table 3. Soil moisture threshold

Soil Moisture (%)

Category

0-39

dry

19-59

moderate

39-80

wet

Table 4. Motor time threshold

Motor Time (sec)

Category

0-120

Very short

108-135

short

120-153

medium

135-174

long

153-200

Very long

(a)

(b)

(c)

(d)

Figure 5. Membership functions of input and output: (a) temperature membership (b) humidity membership (c) soil moisture membership (d) output motor time membership

The interrelationship between soil moisture and these influential elements has been duly acknowledged and integrated into the fuzzy rule framework, wherein 27 rules predicated on Mamdani inference methodology were employed to facilitate the regulation of the controller. The correlational dynamics between the input and output variables are articulated through “IF THEN” rules, which are derived from empirical experiences and expert insights. A selection of these rules is illustrated in Table 5. These rules serve to facilitate the generation of informed decisions regarding the management of irrigation practices in accordance with the prevailing conditions of soil and the surrounding environment.

Figure 6. System irrigation system: 3 input, 1 output, 27 rules

Table 5. A Few of the fuzzy rules

Rules

Rule 1

IF

AND

AND

THEN

Humidity is Low

temperature is high

soil moisture is dry

motor time is very long

Rule 2

IF

AND

AND

THEN

Humidity Low

temperature is high

soil moisture is moderate

motor time is long

Rule 3

IF

AND

AND

THEN

Humidity Low

temperature is high

soil moisture is wet

motor time is medium

Rule 4

IF

AND

AND

THEN

Humidity Low

temperature is medium

soil moisture is dry

motor time is long

Rule 5

IF

AND

AND

THEN

Humidity Low

temperature is medium

soil moisture is moderate

motor time is medium

Rule 6

IF

AND

AND

THEN

Humidity Low

temperature is medium

soil moisture is wet

motor time is short

Rule 7

IF

AND

AND

THEN

Humidity Low

temperature is low

soil moisture is dry

motor time is medium

Rule 8

IF

AND

AND

THEN

Humidity Low

temperature is low

soil moisture is moderate

motor time is short

Rule 9

IF

AND

AND

THEN

Humidity Low

temperature is low

soil moisture is wet

motor time is very short

Rule 10

IF

AND

AND

THEN

Humidity is medium

temperature is high

soil moisture is dry

motor time is long

The enchanting Fuzzy Logic procedure woven into the Raspberry Pi unfolds through  four of captivating stages:

1. Fuzzification: Implement membership functions that transform inputs into the realm of fuzzy sets.

2. Rule Evaluation: Use either the min (AND) or product procedures to find out how intense the firing is. The word "min" is used in the following guideline to refer to organic classes for humidity levels, temperature conditions, and soil moisture levels.

IF Humidity Low AND temperature is low AND soil moisture is dry THEN motor time is medium.

3. Rule Aggregation: Use max (OR) to combine the outputs into one result.

4. Defuzzification: Transform the consolidated fuzzy output into a precise value utilizing the Center of Area (COA). As demonstrated by the following Eq. (3) below [25].

COA=$\frac{\mathop{\int }_{{{x}_{min}}}^{{{x}_{max}}}f\left( x \right).x~{{d}_{x}}}{\mathop{\int }_{{{x}_{min}}}^{{{x}_{max}}}f\left( x \right)~{{d}_{x}}}$                     (3)

where CoA stands as the center of the area, x signifies the measure of the linguistic variable, while xmin and xmax delineate the spectrum of the linguistic variable.

7. Result and Discussion

To tackle the issue of data interference coming  from each node, we devised a solution that involves the Raspberry Pi launching an individual terminal window for every node. In these separate windows, we execute the code pertinent to each node, allowing the respective node data to be displayed independently. This approach guarantees that the data received by the Raspberry Pi remains untainted by interference. Below is the terminal window for the first node, showcasing the complete automatic irrigation of the soil via the fuzzy logic program applied to the Raspberry to automatically control the operation or shutdown of the motor for the first node and display the data of the first node via the platform, referred to as Figure 7.

(a)

(b)

(c)

Figure 7. Irrigations of the soil via the fuzzy logic program: (a) raw data output (b) ThingSpeak IoT web application (c) the soil is dry and the soil is wet

Figure 8 shows the sensor data received from the second node displayed on the platform.

Figure 8. Sensor data of the node 2 display on the ThingSpeak

Information was gathered from various sensors over distinct time intervals, resulting in a visual representation depicted in Figure 9. The horizontal axis of the chart signifies the passage of time, whereas the vertical axis illustrates the information obtained from each individual sensor.

(a)

(b)

(c)

Figure 9. Graph of the data acquisition from each sensor: (a) temperature (b) soil moisture (c) humidity

The empirical findings pertaining to the fuzzy logic system implemented on the Raspberry Pi alongside that developed on MATLAB software are presented in Table 6. Upon examination of Table 6, it is evident that the discrepancies in the watering time values derived from the fuzzy logic assessments on both the Raspberry Pi and MATLAB are minimal. Cumulatively, an average error of 1.184% was observed, which can be interpreted as an accuracy rate of 98.816%. Furthermore, the test results concerning the fuzzy logic system deployed on the Raspberry Pi in conjunction with Manual Operation are depicted in Table 7. Analysing Table 7 reveals that the variance in watering time values acquired from the fuzzy logic evaluations on the Raspberry Pi and Manual Operation is exceedingly negligible. Collectively, an average error of 0.838% was recorded, indicating an accuracy rate of 99.162%.

Table 6. Fuzzy logic test results in Raspberry Pi and MATLAB

Humidity (%)

Temperature (c)

Soil Moisture (%)

Motor Time in Sec

Error

Raspberry Pi

MATLAB

23

27

19

175

181.7462

3.71

23

27

39

154

153.9756

0.016

23

27

59

136

136.0324

0.024

53

18

19

120.9

120.0076

0.744

58

23

39

109.6

108.0591

1.426

Average (%)                                                                        1.184

Accuracy (%)                                                                       98.816

Table 7. Fuzzy logic test results in Raspberry Pi and Manual Operation

Humidity (%)

Temperature (c)

Soil Moisture (%)

Motor Time in Sec

Error

Raspberry Pi

Manual Operation

23

27

19

175

174

0.57

23

27

39

154

153

0.65

23

27

59

136

135

0.74

53

18

19

120.9

120

0.75

58

23

39

109.6

108

1.48

Average (%)                                                                                            0.838

Accuracy (%)                                                                                          99.162

This indicates that the FLC utilizing the Mamdani approach, constructed on the Raspberry Pi, demonstrates a commendable level of accuracy, thereby rendering it suitable for regulating the duration of irrigation periods in agricultural practices.

when:

$\begin{gathered}\text { Error }=\frac{\mid \text { Estimated-Actual } \mid}{\text { Actual }} \times 100 \% \\ \text { Accuracy }=100 \%-\text { Error }\end{gathered}$

If the Estimated is the fuzzy logic implemented on Raspberry Pi.

The technique has worked well on different kinds of dry, moderate, and wet soil (19%, 39%, and 59%), as shown in Tables 6 and 7. In Iraq, especially in Baghdad, and during the severely cold winter, it is hard to have temperatures as low as 18 degrees or as high as 27 degrees. Iraq's dry environment, which doesn't get much rain all year, also makes it hard to get the air humidity levels below 23% or above 58%. We tried to create a diverse environment, nevertheless, so that we could fully test the system in real-world situations. The system shows how rapidly it can adapt to changes in the environment and soil. It easily adjusted to changes in temperature (from 18 to 27 degrees) and air humidity (from 23% to 58%). The Raspberry's fuzzy system rapidly and accurately told how long it would take to operate the engine to water the soil enough.

Figure 10 shows the amount of water needed for irrigation for different systems, including our system that applies FLC on the Raspberry Pi, compared to Manual Operation and also compared to the FLC system applied in MATLAB. This substantiates the numerous benefits of implementing the suggested system, which ensures intelligent irrigation through a fuzzy inference mechanism, IoT, and WSNs, thereby facilitating substantial cost savings for agronomists regarding water, energy, and labour costs.

Figure 10. Comparison of proposed (Raspberry pi) vs. MATLAB and Manual Operation

A visual representation was crafted to illustrate the correlation between the readings from each sensor and the motor time computed by the Raspberry Pi, as depicted in Figure 11.

(a)

(b)

(c)

Figure 11. Graph of the correlation between data acquisition from each sensor and motor time: (a) temperature (b) soil moisture (c) humidity

Water flow regulation has varied effects, as shown in Figure 12(a) and (b). According to Figure 12(a), several environmental factors affect irrigation duration. The low humidity of 23%, high temperature of 27 degrees Celsius, and soil moisture of 59% indicate that water will continue irrigation for 136 minutes. In Figure 12(b), the temperature and humidity are the same, but the soil moisture is 39% lower. This will increase watering time to 154 minutes.

(a)

(b)

Figure 12. Motor time: (a) medium (b) long

A MATLAB-generated surface plot in Figure 13(a) demonstrates how humidity and soil moisture impact motor time as independent factors and motor time as the dependent variable. This plot shows an inverse relationship: when moisture levels go down (yellow), water flow goes up; when moisture levels go up (blue), water flow goes down.

(a)

(b)

(c)

Figure 13. The interplay between (a) soil moisture, relative humidity, and the FLC's final product (b) temperature, soil moisture, and the FLC's final product (c) humidity, temperature, and the FLC's final product

Figure 13(b) exhibits identical temperature, soil moisture, and FLC output. Figure 13(c) displays humidity, temperature, and FLC output.

The comparison will be made based on the techniques used, and the comparison is illustrated with Table 8 and Table 9. The comparison indicates the superiority of the proposed model in terms of the techniques used, as WSN, AI, and IoT were integrated.

Table 8. The comparison based on the techniques used

Ref

Year

Sensors

Wireless Communications

AI

IoT Platform

[8]

2016

Water level

Soil moisture

Wi-Fi

_

_

[9]

2020

Moisture

DHT11

Flow

ultrasonic

Wi-Fi

_

Node-Red

[10]

2021

DHT11

Soil moisture

ultrasonic

NRF

FL

Blynk

Think Speak

[11]

2023

DHT22

Soil moisture

MQ135

TDS

Wi-Fi

DL

Fire base cloud

[12]

2024

DHT22

Soil moisture

LDR

PIR

Wi-Fi

FL

cloud

[13]

2024

DHT22

Soil moisture

BLE

LORA

_

IoT cloud

Proposed

 

DHT11

Soil moisture

Wi-Fi

MQTT

FL

ThingSpeak

Table 9. The complete of the comparison

Ref

Year

No. of Sub-Node

Microcontroller

No. of Head-Node

Microcontroller

[8]

2016

tow

Arduino Uno

one

Raspberry Pi

[9]

2020

five

Wemose-d1

one

Raspberry Pi

[10]

2021

one

Node MCU

one

Arduino Uno

[11]

2023

_

_

one

Esp8266

[12]

2024

_

_

one

Arduino Uno R3

[13]

2024

three

Raspberry Pi

one with one base station

Raspberry Pi

proposed

 

tow

Arduino Uno R4 Wi-Fi

one

Raspberry Pi

In Table 10, the energy usage of every element integrated into the system is explored alongside the cumulative energy usage of the system over a span of one hour.

Table 10. Energy Consumption of the system

The Apparatus

Number

Energy Usage for Each Element (W)

Aggregate Energy Utilization (W)

Raspberry Pi 4 B

1

7.6

7.6

Arduino uno R4 Wi-Fi

2

1.0

2.0

DHT 11

2

0.0125

0.025

Soil moisture sensor

2

0.175

0.35

Pump

2

5.0

10.0

Relay

2

0.4

0.8

Total = 20.775

Table 11. Evaluation of the proposed system

Model

Water Consumption (L)

Energy Consumption (Wh)

Operating Time of water pump approximately 1 hour

[26]

59

108

[23]

46

73

[27]

37

59

Proposed

28

20.775

Table 11 presents a juxtaposition of the suggested and existing frameworks, concentrating on three primary dimensions: water usage, energy usage, and pump operation duration, limited to around one hour exclusively.

We observe that when the system operates for a remarkable span of 17 hours, it reveals that the innovative system uses an astonishing 80.8% less energy in contrast to the system [26], 71.5% less when juxtaposed with the system [23], and a striking 64.87% less when viewed alongside the system [27].

Figure 14. Water usage comparison proposed system vs. existing methods

In Figure14, it is illustrated that the pump's water flow rate stands at 3.6 L for each water pump per hour, based on a water pump flow rate of 60 ml/min. Given that the system comprises two water pumps, we estimate that the combined water flow rate per hour for both pumps reaches 7 L, with updates anticipated every 15 minutes. This indicates:

The total water consumption for the watering routine:

1 hour = 4 updates

17 hours = 68 updates

That means the water consumption of the total system is:

7 L * 68 = 476 L

Figure 14 shows that the new method has led to a huge cut in water use in contrast to the suggested frameworks throughout a span of 17 hours. To be exact, the system [26] says that the baseline use was 1003 liters, but the recommended technique cut that down by 527 liters, or 52.5%. The system [23] also says that the baseline usage is 782 liters. The recommended solution was able to decrease consumption by 306 liters, which is 39%. Also, the system [27] shows a reference consumption of 629 liters. The suggested method cuts consumption by 153 liters, which is roughly 24%. This shows how useful it may be for farmers to use the proposed strategy that includes smart irrigation with FLC and IoT technology. This could save them a lot of money on water, electricity, and labor costs.

Table 12. The expenses associated with the materials utilized within the system

The Apparatus

Number

Price of Each Element (US $)

Aggregate Price (US $)

Raspberry Pi 4 B

1

112

112

Arduino uno R4 Wi-Fi

2

33.5

67

DHT 11

2

1.5

3

Soil moisture sensor

2

7

14

Pump

2

9

18

Relay

2

1.5

3

Total = 217

Table 12 delineates the economic viability of the system. It gives a full list of the costs for each device in the framework. The system doesn't have to pay for installation since wireless nodes are easy to use, so the user may set it up on their own. With a total cost of $217 US dollars. The system's low cost and high efficiency make it a good choice for many farmers who can't afford to try other methods. As a result, the system has shown that it is cost-effective and easy to install and maintain. It doesn't cost any more than traditional irrigation methods, which require a lot of manual labor for setup and field oversight.

8. Conclusions

The research accomplished the development of a fuzzy logic system to regulate the duration of irrigation within agricultural frameworks, commencing from sensor data acquisition, transmitting it to the Head-Node, and subsequently displaying it on the ThingSpeak platform, thereby enabling user monitoring of the parameters. The framework employs fuzzy inference system alongside IOT technologies to enhance efficient water utilization and refine irrigation oversight. Utilizing the Mamdani approach, the fuzzy inference System adeptly ascertains the optimal frequency and duration of irrigation. This system relies on trapezoidal and triangle organic functions. The fuzzy control approach is meant to save water and energy by controlling extra runoff and keeping the soil moisture level above a certain level. Also, testing the fuzzy logic system on Raspberry Pi and MATLAB-based fuzzy logic showed an average error rate of 1.184%. In contrast, the results from manual control tests exhibited an average error of 0.838%, reinforcing the efficacy and applicability of the system within automated irrigation frameworks. Furthermore, the mechanism adjusts for the moisture deficit resulting from evapotranspiration throughout the winter months. It is crucial that the suggested approach preserve its ease of use and cost-effectiveness, even when applied to extensive agricultural initiatives. 

To adapt this system for larger farms or varying climates, several innovative enhancements can be made:

•More sensor networks: By putting out more sensors, bigger farms may be able to get more information on the temperature, humidity, and soil moisture in their fields. Adding more sensors to this larger network should not affect the integrity of the data.

•Make the wireless network cover a larger area: Wi-Fi is an excellent wireless communication technology because it is robust, stable, and constant even when it is under stress. This network can handle additional nodes and distances of up to 200 meters without losing signal strength during transmission and reception. An extender catches the signal from the main router and boosts it. The extender and router can function together as one network if they have the same network settings. The router will handle the system's IP addresses (DHCP server), and the extender will make the signal reach farther. It needs a static IP address that is inside the range of the main router's network, but it shouldn't utilize DHCP so that it doesn't cause problems with the main router.

•Better Data Processing: Large-scale operations need to analyze data in real time and make decisions quickly; therefore, it's important to improve data processing capabilities by adding additional sensors with sophisticated units or cloud solutions.

•Customized Adaptation for Crops: You may change the fuzzy rules and functions to make the fuzzy logic system work better for different types of crops and weather. This makes it possible to adjust crops to their needs. This makes irrigation more efficient, which means more crops with less water.

Upcoming endeavors will focus on these key aspects:

•Evaluation of the system under varying environmental conditions.

•Comparisons with other advanced methods.

•Combining with advanced technology: Integrating blockchain technology to enhance data security. Adding drones for aerial surveillance and automated irrigation equipment can improve resource management and operational efficiency.

Acknowledgment

This work is supported by the College of Engineering/ Mustansi riyah University Iraq, Baghdad. https://www.uomustansiriyah.edu.iq/.

  References

[1] Lakshmi, G.P., Asha, P.N., Sandhya, G., Sharma, S.V., Shilpashree, S., Subramanya, S.G. (2023). An intelligent IOT sensor coupled precision irrigation model for agriculture. Measurement: Sensors, 25: 100608. https://doi.org/10.1016/j.measen.2022.100608

[2] Kitcharoen, P., Chookaew, S., Howimanporn, S. (2024). Implementation of an AIoT-based intelligent water resources control system for smart farm. IEEE Access, 12: 156878-156892. https://doi.org/10.1109/ACCESS.2024.3482088

[3] Trihandoyo, A., Aristawati, N.R. (2023). Designing plant monitoring system using Arduino. In 2nd International Conference on Research and Development (ICORAD), Indonesia, pp. 71-80. https://doi.org/10.47841/icorad.v2i1.84

[4] Sinha, C., Gupta, P. (2024). Smart Irrigation System using Arduino. International Journal of Science, Research in Engineering and Management, 8(6): 1-5. https://doi.org/10.55041/ijsrem35606.

[5] Atmaja, A.P., El Hakim, A., Wibowo, A.P.A., Pratama, L.A. (2021). Communication systems of smart agriculture based on wireless sensor networks in IoT. Journal of Robotics and Control (JRC), 2(4): 297-301. https://doi.org/10.18196/jrc.2495

[6] Tang, P., Liang, Q., Li, H., Pang, Y. (2024). Application of Internet-of-Things wireless communication technology in agricultural irrigation management: A review. Sustainability, 16(9): 3575. https://doi.org/10.3390/su16093575

[7] Kamath, R., Balachandra, M., Prabhu, S. (2019). Raspberry Pi as visual sensor nodes in precision agriculture: A study. IEEE Access, 7: 45110-45122. https://doi.org/10.1109/ACCESS.2019.2908846

[8] Imteaj, A., Rahman, T., Hossain, M.K., Zaman, S. (2016). IoT based autonomous percipient irrigation system using raspberry Pi. In 2016 19th International Conference on Computer and Information Technology (ICCIT), Dhaka, Bangladesh, pp. 563-568. https://doi.org/10.1109/ICCITECHN.2016.7860260

[9] Alhasnawi, B.N., Jasim, B.H., Issa, B.A. (2020). Internet of things (IoT) for smart precision agriculture. Iraqi Journal for Electrical and Electronic Engineering, 16(1): 1-11. https://doi.org/10.37917/ijeee.16.1.4

[10] Abdullah, N., Durani, N.A.B., Shari, M.F.B., Siong, K.S., Hau, V.K.W., Siong, W.N., Ahmad, I.K.A. (2020). Towards smart agriculture monitoring using fuzzy systems. IEEE Access, 9: 4097-4111. https://doi.org/10.1109/ACCESS.2020.3041597

[11] Abdulla, M., Marhoon, A. (2023). Deep learning and IoT for monitoring tomato plant. Iraqi Journal for Electrical & Electronic Engineering, 19(1): 70-78. https://doi.org/10.37917/ijeee.19.1.9

[12] Irwanto, F., Hasan, U., Lays, E.S., De La Croix, N.J., Mukanyiligira, D., Sibomana, L., Ahmad, T. (2024). IoT and fuzzy logic integration for improved substrate environment management in mushroom cultivation. Smart Agricultural Technology, 7: 100427. https://doi.org/10.1016/j.atech.2024.100427

[13] Effah, E., Thiare, O., Wyglinski, A.M. (2024). Hardware evaluation of cluster-based agricultural IoT network. IEEE Access, 12: 33628-33651. https://doi.org/10.1109/ACCESS.2024.3370230

[14] Qian, J.P., Yang, X.T., Wu, X.M., Xing, B., Wu, B.G., Li, M. (2015). Farm and environment information bidirectional acquisition system with individual tree identification using smartphones for orchard precision management. Computers and Electronics in Agriculture, 116: 101-108. https://doi.org/10.1016/j.compag.2015.06.003

[15] Natonis, M.M., Manu, L.L.K., Amleni, P.M.C., Nababan, D., Kelen, Y.P., Sucipto, W. (2023). Smart greenhouse design based internet of things (IoT) with microcontroller Arduino Uno. Jurnal Teknik Informatika, 16(1): 35-44. https://doi.org/10.15408/jti.v16i1.30889

[16] Hosny, K.M., El-Hady, W.M., Samy, F.M. (2025). Technologies, protocols, and applications of internet of things in greenhouse farming: A survey of recent advances. Information Processing in Agriculture, 12(1): 91-111. https://doi.org/10.1016/j.inpa.2024.04.002

[17] Muhammad, Z., Hafez, M.A.A.M., Leh, N.A.M., Yusoff, Z.M., Abd Hamid, S. (2020). Smart agriculture using internet of things with Raspberry Pi. In 2020 10th IEEE International Conference on Control System, Computing and Engineering (ICCSCE), Penang, Malaysia, pp. 85-90. https://doi.org/10.1109/ICCSCE50387.2020.9204927

[18] García, L., Viciano-Tudela, S., Sendra, S., Lloret, J. (2022). Practical design of a WiFi-based wireless sensor network for precision agriculture in citrus crops. In 19th International Conference on Wireless Networks and Mobile Systems (WINSYS), Lisbon, Portugal. pp. 107-114. https://doi.org/10.5220/0011355300003286

[19] Guo, Y., Zhang, S., Xiao, D. (2012). Overview of wi-fi technology. In 2012 International Conference on Computer Application and System Modeling, France. pp. 1293-1296). http://doi.org/10.2991/iccasm.2012.330

[20] Mowla, M.N., Mowla, N., Shah, A.S., Rabie, K.M., Shongwe, T. (2023). Internet of Things and wireless sensor networks for smart agriculture applications: A survey. IEEE Access, 11: 145813-145852. https://doi.org/10.1109/ACCESS.2023.3346299

[21] Jindarat, S., Wuttidittachotti, P. (2015). Smart farm monitoring using Raspberry Pi and Arduino. In 2015 International Conference on Computer, Communications, and Control Technology (I4CT), Kuching, Malaysia. pp. 284-288. https://doi.org/10.1109/I4CT.2015.7219582

[22] Rocha, A., Souza, A., Johnathan, D., Aquino, G., Queiroz, R., Melo, M. (2019). Evaluating ThingSpeak as an IoT event platform on building a smart parking application. In 11th Brazilian Symposium on Ubiquitous and Pervasive Computing (SBCUP 2019), Belém, Brazil. https://doi.org/10.5753/sbcup.2019.6582

[23] Benyezza, H., Bouhedda, M., Rebouh, S. (2021). Zoning irrigation smart system based on fuzzy control technology and IoT for water and energy saving. Journal of Cleaner Production, 302: 127001. https://doi.org/10.1016/j.jclepro.2021.127001

[24] Jafari, R., Yu, W., Razvarz, S., Gegov, A, (2021). Numerical methods for solving fuzzy equations: A Survey. https://eprints.whiterose.ac.uk/156068/.

[25] Widyawati, D.K., Ambarwari, A. (2022). Fuzzy logic design to control the duration of irrigation time in the greenhouse. IOP Conference Series: Earth and Environmental Science, 1012(1): 012086. https://doi.org/10.1088/1755-1315/1012/1/012086

[26] Krishnan, R.S., Julie, E.G., Robinson, Y.H., Raja, S., Kumar, R., Thong, P.H., Son, L.H. (2020). Fuzzy logic based smart irrigation system using Internet of Things. Journal of Cleaner Production, 252: 119902. https://doi.org/10.1016/j.jclepro.2019.119902

[27] Hoque, M.J., Islam, M.S., Khaliluzzaman, M. (2023). A fuzzy logic-and Internet of Things-based smart irrigation system. Engineering Proceedings, 58(1): 93. https://doi.org/10.3390/ecsa-10-16243