Water Distribution Control Using Arduino With Fuzzy Logic Algorithm
Water Distribution Control Using Arduino With Fuzzy Logic Algorithm
Abstract – The pipe distribution network is a complex leak locations by reading sensors which were placed in
matter for the water distribution system. Meanwhile, the pipes from a certain distance. The leak location was then
needs of clean water have grown rapidly. This has become a sent to the operator [2]. However, this method was not
problem for water distribution in many cities, including able to control the water distribution in an area, especially
Palembang since the clean water is not distributed equally.
Consequently, every household does not get the flow rate
when there was an error in the sensor reading. Other
based on their needs yet. Thus, this paper proposes a clean studies that discussed the control system of water
water distribution control system which utilizes Arduino distribution were performed by [3-4]. .
based on the fuzzy method. This control system is built in a The problem of clean water distribution also occurs in
prototype design and uses 3 sensor flows as input and 3 servo Palembang since it is not distributed equally to every
outputs which control the valve of the servo. Meanwhile, the region based on the needs. Besides, the difference in water
fuzzy logic program uses Arduino Mega microcontroller as a flow may be due to a leak in the transmission pipe [2].
process regulator at the input and output. Each distribution Some studies have discussed the water distribution
area is controlled by a servo value as the output of Pulse problem. Ahmadullah and Dongshik proposed GIS and
Width Modulation (PWM) from the Arduino Mega. The
results show that PWM will control the opening of the valve
Espanet-based methodology to solve the closed-loop
according to the needs so the water flow will be distributed network problem in water distribution network [5].
and received by the costumers at the same time. Meanwhile, [6] introduced a clustering approach for a
real-time decision support system in water distribution
Keywords - water flow sensor. servo motor, Arduino Mega, systems. Besides that, [7] implemented fuzzy logic control
fuzzy logic for irrigation systems. This study showed that fuzzy may
I. INTRODUCTION provide an optimal distribution of water resources.
Thus, this study aims to propose a method for water
Water is an important aspect of our daily life. Regional distribution control based on fuzzy logic. It is expected
water supply company (known as Perusahaan Daerah Air that water flow can be distributed at the same time, based
Minum (PDAM)) has to fulfill such needs by distributing on the needs of customers.
clean water from the river as the source for water
treatment systems to comply domestic and non-domestic
water needs. As the population grows, the water needs II. RESEARCH METHODS
may increase as well. Hence, it is essential to have a good The prototype was designed to represent the condition
plan for water system based on the growth of population. of the water distribution system which can be seen in Fig.
Some papers have discussed the importance of water 1. As shown in the figure, the flow sensor and servo may
distribution. [1] discussed the effect of water flow control the valve for 3 distribution areas.
increasing demand in the water service zone of PDAM
Tirta Mawar. Based on this research, the piping network is Flow sensor, as input, will provide data to the
complex and the need for clean water increases in line microcontroller and adjust the opening of the valve. A
with the development of the city and population growth, servo motor is applied as a regulator component which
while the planning is not optimally carried out. The adjusts the opening of the valve. Control of servo motor
results of the research conducted at PDAM Tirta Mawar on the valve will be regulated directly by the Arduino
showed that it has not been fully optimal because it did Mega 2560 From the data received by the flow sensor,
not use a method for water distribution [1]. the microcontroller will control the valve so that the water
flow complies with the requirements read in each area.
Chakchouk et al. implemented an algorithm to detect Before implementing fuzzy logic controller in Arduino, it
*corresponding author is simulated in Matlab.
343
Authorized licensed use limited to: Institut Teknologi Sepuluh Nopember. Downloaded on April 27,2021 at 04:52:35 UTC from IEEE Xplore. Restrictions apply.
International Conference on Electrical Engineering and Computer Science (ICECOS) 2019
in Fig. 2. Input parameters come from sensor flow. The
value obtained from this input will be used by fuzzy to
control the Pulse Width Modulation (PWM) of the servo
motor. There are 3 servo motors used to distribute to three
areas. Then, the PWM may control the opening of the
valve.
As shown in Fig. 2, in the beginning, the device
control system will be initialized by setting and
determining fuzzy membership functions. Then, the
sensor reads the water flow from 3 areas. Following this
stage, the fuzzification is performed. Here, a non-fuzzy
variable (numeric variable) from the sensor is changed
into a fuzzy variable (linguistic variable) which will
determine the output. Then, the rule set will be used to
group fuzzy rules in relation to the state of the input and
output signals. This rule evaluation is the basis for
decision making or inference process to get the control
Fig. 1. Prototype Design of Water Distribution System. signal output from input conditions based on
predetermined rules. After the rule set is determined, the
process is carried out on the defuzzification block. This
Start process is the opposite of the Fuzzification process where
the fuzzy variable (linguistic variable) is changed to a
non-fuzzy variable (numeric variable) which produces all
fuzzy output values specified with the PWM value in
System Initialization order to control the motor servo on the valve. From the
PWM value output, all fuzzy output values will
effectively change the valve quantity position in
Determining Fuzzy
accordance with predetermined rules so the water flow is
Membership Functions distributed based on the customers’ needs. .
344
Authorized licensed use limited to: Institut Teknologi Sepuluh Nopember. Downloaded on April 27,2021 at 04:52:35 UTC from IEEE Xplore. Restrictions apply.
International Conference on Electrical Engineering and Computer Science (ICECOS) 2019
The membership function of fuzzy logic for the water
distribution control system consists of 3 input variables
and 3 output variables as presented in Table I. Input
variables consist of input Flow1, Flow2, and Flow3 while Fuzzy logic implemented in water distribution has 27
output variables consist of output valve1, valve2, and rules to prescribe membership values so that the results
valve3. Each variable has the same set and value of are suitable for the distribution of water which will be
members. The input variable is divided into 3 Fuzzy Logic controlled by servo. The rules of the proposed FLC is
sets, which are slow, mid, and fast, respectively. shown in Table III.
Meanwhile, the output variable is divided into 3 fuzzy To test the proposed FLC, we use Matlab application
sets, namely, small open, mid open, dan big open. using the same 3 variables for input and output. Fig. 4
shows the fuzzy logic input setting in Matlab.
TABLE II. VARIABLE FLOW PARAMETER VALUES AND VALVE
TABLE III. FUZZY LOGIC RULES OF WATER DISTRIBUTION
Flow in Milliliters Valve in PWM value
No Small Mid Big Flow Flow Flow Valve Valve Valve
Slow Mid Fast No
1 2 3 1 2 3
Open Open Open
Mid Mid Mid
1 Slow Slow Slow
1 0 5 20 0 10 35 Open Open Open
Small Small Mid
2 Slow Slow Mid
2 0 15 30 0 25 50 Open Open Open
Small Mid Small
3 Slow Mid Slow
3 5 20 35 10 35 60 Open Open Open
Small Mid Mid
4 15 30 35 25 50 60 4 Slow Mid Mid
Open Open Open
Small Mid Big
5 Slow Mid Fast
Open Open Open
In the initial stage of determining the fuzzy variable, Small Big Mid
6 Slow Fast Mid
water flow as the input variable is obtained from Open Open Open
experimental reading of water flow to determine the Small Big Big
7 Slow Fast Fast
maximum and minimum capacities before the application Open Open Open
Small Big Small
of fuzzy control with Arduino. Meanwhile, the size of the 8 Slow Fast Slow
Open Open Open
valve is determined by testing the Arduino control output Small Small Big
in the form of a PWM value with a valve amount of 0- 9 Slow Slow Fast
Open Open Open
100%. All experiments get fuzzy sets of each input and 10 Mid Slow Slow
Mid Mid Mid
output variable have the value range of 0 to 35 liters Open Open Open
minutes for input and magnitude of PWM of 0-60 which Mid Small Mid
11 Mid Slow Mid
Open Open Open
represents the opening of servo according to degrees.
Mid Mid Small
Parameter values for the slow input membership is [0 0 5 12 Mid Mid Slow
Open Open Open
15], [5 15 20 30] for the mid input membership, and [20 Mid Mid Mid
13 Mid Mid Mid
30 35 35] for the fast input membership . The trapezoidal Open Open Open
curve type is used for all input membership parameters. 14 Mid Mid Fast
Mid Mid Big
The value of the small open output membership parameter Open Open Open
is [0 0 10 25], the value of large open output is [10 25 35 Mid Big Mid
15 Mid Fast Mid
Open Open Open
50], and the value of open output is [35 50 60 60] with the Mid Big Big
trapezoidal curve type on all output membership 16 Mid Fast Fast
Open Open Open
parameters. These variables of input and output can be Mid Big Small
17 Mid Fast Slow
seen in Table II. Open Open Open
Mid Small Big
18 Mid Slow Fast
Open Open Open
Big Mid Mid
19 Fast Slow Slow
Open Open Open
Big Small Mid
20 Fast Slow Mid
Open Open Open
Big Mid Small
21 Fast Mid Slow
Open Open Open
Big Mid Mid
22 Fast Mid Mid
Open Open Open
Big Mid Big
23 Fast Mid Fast
Open Open Open
Big Big Mid
24 Fast Fast Mid
Open Open Open
Big Big Big
25 Fast Fast Fast
Open Open Open
Big Big Small
26 Fast Fast Slow
Open Open Open
Big Small Big
27 Fast Slow Fast
Open Open Open
345
Authorized licensed use limited to: Institut Teknologi Sepuluh Nopember. Downloaded on April 27,2021 at 04:52:35 UTC from IEEE Xplore. Restrictions apply.
International Conference on Electrical Engineering and Computer Science (ICECOS) 2019
is set to 11 ml/sec. The results are shown in Fig. 7. The
total time flow water distribution maintains to 17-second
test. As shown in the figure, the flow rate is around 11-24
ml/sec per area where the water flows are 0, 361, and 166
at Flow1, Flow2, and Flow3, respectively.
Then, the simulation of rules value which is divided Fuzzy logic is then implemented to the system using
into 27 groups using the Mamdani method can be seen in the same duration of 17 seconds. The results in trial 1 are
Fig. 5. shown in Fig. 8. In this test, the flow rate of Flow1 is 23
ml/sec, Flow2 is 11 ml/sec, and Flow3 is 0 ml/sec.
Meanwhile, the amount of water flow is 346 milliliters in
Flow1, 163 milliliters in Flow2, and 0 milliliters in Flow3.
Fig. 9 shows the result in trial 2 of implementing the
fuzzy logic system. The same duration of 17 seconds is
used. In this test, the flow rate of Flow1 is 0 ml / sec,
Flow 2 is 34 ml/sec,and Flow3 is 11 ml / sec. The number
of water flows are 0, 512 and 166 at Flow1, Flow2, and
Flow3, respectively.
346
Authorized licensed use limited to: Institut Teknologi Sepuluh Nopember. Downloaded on April 27,2021 at 04:52:35 UTC from IEEE Xplore. Restrictions apply.
International Conference on Electrical Engineering and Computer Science (ICECOS) 2019
TABLE IV. COMPARISON OF FUZZY LOGIC CONTROL 361 ml to 512 ml and Flow3 is fixed at 166 ml. Before
RESULTS ON ARDUINO AND MATLAB
implementing fuzzy, the water Flow2 was read as 24
Input Output ml/sec and Flow3 was 11 ml/sec in the initial condition.
Test Trial Flow Flow Flow Valve Valve Valve When the fuzzy was implemented, Flow2 changed to 34
Simulation 1 2 3 1 2 3
ml/sec. On the output, the value of PWM was set equally
to 45 before implementing the fuzzy logic. It indicates that
the opening of the valve is the same even though the input
Water 1 23 11 0 25 35 49 is different. This condition may imply that the water
Distribution supply is not distributed equally based on the needs. Once
Performance the fuzzy has been applied to the prototype, the PWM
value for valve 1, valve 2, and valve 3 are 49, 10, and 34,
with Fuzzy
respectively for Flow1 of 0 ml/sec, Flow2 of 34 ml/sec,
Logic 2 0 34 11 49 10 35 and Flow3 of 11 ml/sec. These results may present that
Control on the implementation of fuzzy logic in the water distribution
Arduino
may control the opening of the valve based on the needs.
Thus, the amount of water flow in Flow 2 is higher than
Flow 3 which may imply that the need in area 2 is higher
Performance 1 23 11 0 26 35.2 49.7 than 3 as shown in experiment 2 in Table V. Hence,
of water implementing fuzzy may improve the distribution of the
distribution water based on the need. The fuzzy logic may control the
water distribution for each area effectively than without
with fuzzy
2 0 34 11 49.7 10.3 35.2 fuzzy.
logic controls
in Matlab IV. CONCLUSIONS
In this study, a prototype of water distribution control
was designed by using the Fuzzy Logic algorithm. The
TABLE V. COMPARISON OF THE WATER FLOW WITH AND results showed that before implementing fuzzy logic, the
WITHOUT FUZZY LOGIC IN 17 SECONDS USING ARDUINO distribution of the water flow becomes relatively small
eventhough that area needs more water than other regions,
Experiment 1 Experiment 2 the flow of water flow is only 361 ml. After implementing
Input Without With Without With Fuzzy Logic Algorithm, Flow2 water flow increases to
Fuzzy fuzzy Fuzzy Fuzzy
512 ml which means that fuzzy logic can increase the
Value of Flow 20 24 24 34 water flow based on the water requirements so customers
Flow 1 300 346 0 0 get the water flow based on their needs. It might also
imply that fuzzy logic can be used as a controller for a
Flow 2 150 163 361 512
water distribution system by dividing the flow of water
Flow 3 0 0 166 166 with other regions.
The proposed system was first tested using Matlab and
. then implemented in Arduino.The experiments conducted
in both program show that the values of fuzzy output
between them are very close or not significantly different.
Both Matlab and Arduino use 3 inputs, 3 outputs, and 27
rules. Thus, this structure may become optimal parameters
for the proposed prototype.
REFERENCES
[1] Z. Zamzami, A. Azmeri, and S. Syamsidik, “Sistem Jaringan
Distribusi Air Bersih Pdam Tirta Tawar Kabupaten Aceh Tengah,”
J. Arsip Rekayasa Sipil dan Perenc., vol. 1, no. 1, pp. 132–141,
2018.
[2] W. Chakchouk, C.B. Regaya, A. Zaafouri, and A. Sallami, "An
improved fuzzy logic control of irrigation station." In 4th
International Conference on Control, Decision and Information
Technologies (CoDIT). IEEE, 2017, pp. 0259-0264.
[3] N. Satiya, V. Varu, A. Gadagkar, and D. Shaha, "Optimization of
water consumption using dynamic quota based smart water
management system." in 2017 IEEE Region 10 Symposium
(TENSYMP), 2017, pp. 1-6.
Fig. 10. Comparison chart of Fuzzy Logic and without Fuzzy Logic [4] A.S. Zamzam, E. Dall’Anese, C. Zhao, J.A. Taylor, and N.D.
Using Arduino Sidiropoulos, "Optimal Water–Power Flow-Problem: Formulation
and Distributed Optimal Solution." IEEE Transactions on Control
Fig. 10 represents a graphical display of testing with of Network Systems, vol. 6., pp. 37-47, 2018.
and without fuzzy logic controls using Arduino as shown [5] R. Ahmadullah and K. Dongshik. "Construction of hydraulically
balanced water distribution network." in 2015 International
in Table V. From this figure, we can see that fuzzy logic Conference on Intelligent Informatics and Biomedical Sciences
may improve the water flow in Flow2 in trial 2. It is from (ICIIBMS), 2015, pp. 96-98.
347
Authorized licensed use limited to: Institut Teknologi Sepuluh Nopember. Downloaded on April 27,2021 at 04:52:35 UTC from IEEE Xplore. Restrictions apply.
International Conference on Electrical Engineering and Computer Science (ICECOS) 2019
[6] A. Predescu, C. Negru, M. Mocanu, and C. Lupu, "Real-time
clustering for priority evaluation in a water distribution system." in
2018 IEEE International Conference on Automation, Quality and
Testing, Robotics (AQTR), 2018, pp. 1-6
[7] J.R.D. Cruz, J.A.V. Magsumbol, E.P. Dadios, R.G. Baldovino, F.B.
Culibrina, and L.A.G. Lim, "Design of a fuzzy-based automated
organic irrigation system for smart farm." in IEEE 9th International
Conference on Humanoid, Nanotechnology, Information
Technology, Communication and Control, Environment and
Management (HNICEM), 2017, pp. 1-6.
348
Authorized licensed use limited to: Institut Teknologi Sepuluh Nopember. Downloaded on April 27,2021 at 04:52:35 UTC from IEEE Xplore. Restrictions apply.