Content uploaded by Wijaya Kurniawan
Author content
All content in this area was uploaded by Wijaya Kurniawan on Jul 29, 2020
Content may be subject to copyright.
Fuzzy Logic for Flood Detection System in an
Embedded System
Mochammad Hannats Hanafi Ichsan
Computer Engineering
Faculty of Computer Science
Brawijaya University
Malang, East Java, Indonesia
hanas.hanafi@ub.ac.id
Wijaya Kurniawan
Computer Engineering
Faculty of Computer Science
Brawijaya University
Malang, East Java, Indonesia
wjaykurnia@ub.ac.id
Aulia Tri Wulandari
Computer Engineering
Faculty of Computer Science
Brawijaya University
Malang, East Java, Indonesia
auliatwa@gmail.com
Abstract-Flood is a natural phenomenon that occurs due to
accidental and unpredictable circumstances. It occurs when
water is overflowing from drains and causing waterlogging on
the mainland. Thus, the potential of flood water in the drains
should be monitored by observing water level and water
velocity. The water level is monitored by ultrasonic sensors,
while water flow sensor is used to sense water velocity.
Embedded System is a small system designed for a specific
purpose. One of its kind that is good enough for prototyping is
arduino nano as a processing device. It is used to process the
data from ultrasonic sensors and water flow sensor and then
provide decision about the potential of flood occurence. This
process has a high degree of ambiguity, so Fuzzy Logic is a good
choice to overcome the problem. Because of the difficulty to do
an onsite monitoring, it is carried out remotely using NRF24L01
module as a wireless radio frequency transmission device. The
porototype system has been succesfully implemented in this
research. The result shows that water speed reading has an
error of 0.608%, water level reading has an error of 4,640%, the
data transmission has a time delay of 1147ms, and all of the
fuzzy decision making is valid. So, it can be concluded that the
results from this prototype is acceptable and ready to be
implemented in the real world application.
Keywords-Flood, Drains, Detection System, Fuzzy Logic,
Embedded System
I. I
NTRODUCTION
Flood is a natural phenomenon that is harmful for life in
an ecosystem [1]. Flood happens when the land flooded with
water because the drains are not able to accommodate the
water discharge [2]. The drains were referred to various kinds
like: suppose culverts, rivers, canals, irrigation channels,
lakes, drainage, etc. [3, 4]. The phenomenon of flood is
common in terrestrial ecosystems e.g.: in residential areas, rice
fields, etc. It is accidental and difficult to predict. In terms of
material, flood impacts a huge economic losses and endanger
life. Some of the causes include: garbage, dense settlements,
plain, high rainfall, less precise manipulation in drainage,
lands that are not able to sink in the water, and so on [5, 6].
These conditions can be seen from the water level altitude and
speed of water passing through a location. Therefore we need
a system that can read the potential for flood based on those
conditions to minimize the negative impacts.
Embedded system is a system that works like a mini
computer. The features of embedded systems is very limited
in accordance of the computing needs to be done [7].
Embedded systems can be used to monitor water level altitude
and velocity of water flow because it is low cost. One good
device of embedded systems for prototyping is arduino nano
[8]. Arduino Nano is chosen to be used as a processing device
because this system doesn’t need a lot of features. It only
needs to read the two parameters, to process logic operations,
and to process data transmission.
Two parameters that will be observed are the height of
water level and speed of the water flow. Arduino Nano has
some sensor kit that can be used to measure these parameters:
water flow sensor for water velocity [9] and ultrasonic sensors
for water level [10]. The sensor is already compatible with
arduino. The location of the sensor where the acquisition of
data happened is called a sensor node. Location of the sensors
and location to view results of the process is not in the the
same place because of the risk of a huge flood. Equipment
used for data transmission is NRF24L01 which is also already
compatible with arduino. Location for data receiver is called
the master node [11].
A decision to be made about the possibility of flooding is
quite complicated in accordance to the water conditions and
the condition of the different waterways [12]. Assumptions
related to the speed and water level altitude is also different.
Therefore it takes a special algorithm to resolve this ambiguity
problem. One algorithm that is good enough to cope with the
ambiguity in decision-making is Fuzzy Logic [13]. Fuzzy
logic is a very good algorithm and are often used in complex
decision-making process [14, 15].
Based on the issues raised, this study will be making a
prototype design of device to monitor water conditions on
waterways that potentially cause flooding. The prototype will
include a water channel that can represent rivers, culverts,
drains, etc. Sensor is placed on the node to read speed and
water level. The results of these readings is processed with
fuzzy logic to do a classification of the data about potential for
flooding or not. Then, the result of fuzzy logic is sent to the
master node to be displayed with LED regarding the status of
the water flow.
II. S
YSTEM
D
ESIGN
This section will discuss the design of the system related
to the functional and non-functional requirements. System is
made in the form of a prototype with its dimensions are 5cm
width, 10 cm depth, and 100 cm in length. Broadly speaking,
the system will be designed according to some block diagrams
and flowcharts. The functional requirement is related to the
Fuzzy Logic that made the decision about status of the river’s
prototype. While non-functional requirement is related to the
readings from each of the sensors and data transmission
process.
A. System Block Diagram
System will be designed into two parts: the sensor node
and the master node. The reason for this design is the
assumption that a water monitoring is done at a hazardous
place. The sensor node is a node that is located on the river,
while the master node, which is a data viewer, is located in a
safe place.
Each node is illustrated by Fig. 1. In this figure, the sensor
node consists of two sensors: water flow sensor to measure
velocity and ultrasonic sensors to measure the water level.
Data obtained by this sensor node will be processed with fuzzy
logic. After issuing the results of fuzzy logic, the data is sent
by the transceiver to the master node that has a receiver to be
displayed in the form of RGB LED.
Fig. 1. System Block Diagram
B. Fuzzy Logic
This section will explain the stages of the fuzzy logic
implemented on the system. The first stage is to make the
membership function of each input which is water speed and
water level. The number of those membership are determined
intuitively. When it is high, the number of conditions that can
be recognized is increasing and it needs more resources to do
the computation. Because the processing device used an
arduino uno which is an embedded device that has small
number of resources (memory storage, processor, etc)
compared to a computer/PC, it is decided that water speed will
use three membership function and water level will use four
membership function.
For water speed, membership can be seen in Fig. 2.
0
1
24 72 120
Slow Avg Fast
Meter
/
second
Fig. 2. Water Speed Membership Function
Water speed is divided into three membership functions
which is: Slow, Avg (Average), and Fast. In this figure, the
membership function is measured in meters/second.
Next is the membership function for the water level. It is
divided into four membership functions. The membership
function is Very Low, Low, High, and Overflow. This
function is describing the condition of the water level as in
Fig. 3. In this figure, the membership function is measured in
centimeters.
1.25 3.75 6.25 8.75
Very Low Low High Overflow
Centimetre
0
1
Fig. 3. Water Level Membership Function
After membership function is completed, the Evaluation
Rule is made. From 3 membership functions of water speed
and 4 membership functions of water level, the gained
combination of the membership is 12. As shown in Table I.
these 12 combinations is used to represent the results of
evaluation rule. For example, Low water level and Avg water
flow combination will result in Cautious, and so on.
TABLE I. T
ABLE
T
YPE
S
TYLES
Water
Flow
Water Level
Very Low low High overflow
slow Normal Normal Cautious Flood
Avg Normal Cautious Dangerous Flood
Fast Normal Dangerous Dangerous Flood
The next step is to design defuzzification process.
Defuzzification process used here is Fuzzy Sugeno order of
zero. This model is enough to perform a simple classification
for decision making. The Z scores is used to issue a
defuzzification process and to display the status of the
monitored waterways. Z scores which is designed are: Z = 1
for normal; Z = 2 for Cautious; Z = 3 for Dangerous; and Z =
4 for Flood. The river status is displayed by RGB LED
according to the value of Z score.
C. Data Transfer
This data transfer is about data transmission, from the
result of fuzzy logic processing, in sensor node to the master
node. Fig. 4 showed the design of data transmission
process.The first thing to do is initializing the system and then
read the Z score as the result from Fuzzy Logic process. Then,
the format and size of data are declared. The next step is to
also declare destination’s address and channel of the receiver
device. Data is sent in the form of Z scores. Every 1 minute, Z
scores will be read again to determine the changes of its value.
Fig. 4. Sensor Node Data Transceiver Flowchart
The design in master node is showed in Fig. 5. When it
received the value of Z score is 1, which is a normal condition
indicator, it will light on the green LED. If the value is 2 or 3,
which are a cautious or dangerous condition, it will light on
the blue LED. At last, if the Z score value is 4, which is a flood
indicator, it will light on the red LED.
Fig. 5. Master Node Data Receiver Flowchart
III. T
ESTING AND
R
ESULTS
This section will deliver results related to functional and
non-functional testing as in the process of designing the
system. Non-functional testing is done by testing the water
speed sensor, water level sensor, and the data transmission.
Functional testing is done by testing the implemented fuzzy
logic.
A. Water Speed Sensor Testing
This test is done to determine the reliability of sensor. The
procedure is as follows: a reading from the sensor is compared
to other same devices to determine the level of error.
Table II showed several columns. No. column to present a
number of testing, Sensor column to present the results from
the sensor readings, rest of the columns present a reading of
the other measuring devices which is a Flow Meter. The unit
is in meter/second. The test is performed 40 times and it
obtained an average error of 0608%.
TABLE II. W
ATER
S
PEED
S
ENSOR
T
ESTING
R
ESULT
No Sensor
(M /
sec)
Other
(m /
sec)
Error No Sensor
(m /
sec)
Other
(m /
sec)
Error
1 22 21.86 0640 21 58 57.8 0346
2 24 23.8 0840 22 64 63.2 1,266
3 48 47.61 0819 23 69 68.3 1,025
4 56 55.98 0036 24 73 72.6 0551
5 62 61.9 0162 25 78 77.4 0775
6 68 67.7 0443 26 87 86.7 0346
7 72 71.9 0139 27 94 93.8 0213
8 88 87.7 0342 28 118 117.3 0597
No Sensor
(M /
sec)
Other
(m /
sec)
Error No Sensor
(m /
sec)
Other
(m /
sec)
Error
9 96 95.8 0209 29 124 123.4 0486
10 104 103.8 0193 30 27 26.7 1,124
11 112 111.8 0179 31 38 37.8 0529
12 120 119.9 0083 32 48 47.6 0840
13 23 22.6 1,770 33 74 73.9 0135
14 26 25.7 1,167 34 82 81.9 0122
15 31 30.4 1,974 35 89 88.7 0338
16 35 34.6 1,156 36 92 91.9 0109
17 44 43.5 1149 37 96 95.6 0418
18 46 45.6 0877 38 104 103.9 0096
19 49 48.3 1,449 39 109 108.9 0092
20 53 52.5 0952 40 118 117.6 0340
Average Error (%) 0.608
B. Water Level Sensor Testing
This test is done to measure whether the used sensor is
good enough or not. It is similar to the previous test. The
sensor’s reading is compared to a ruler.
TABLE III. W
ATER
L
EVEL
T
ESTING
R
ESULT
No Sensor
(cm)
Other
(cm)
Error No Sensor
(cm)
Other
(cm)
Error
1 35.5 36 1389 21 109.9 112.8 2,571
2 41.7 42.4 1,651 22 116.1 119.2 2,601
3 47.9 48.8 1844 23 63 68 7353
4 54.1 55.2 1,993 24 122.3 125.6 2,627
5 60.3 61.6 2,110 25 128.5 132 2,652
6 140.8 132.6 6184 26 134.7 138.4 2,673
7 97.5 100 2,500 27 83.2 80.4 3,483
8 103.7 106.4 2,538 28 89.6 86.2 3,944
9 102.4 97.8 4,703 29 70.4 68.8 2,326
10 28 29 3,448 30 76.8 74.6 2,949
11 108.8 103.6 5,019 31 63 65 3,077
12 115.2 109.4 5,302 32 59.5 61.5 3,252
13 121.6 115.2 5,556 33 55 57.4 4,181
14 128 121 5,785 34 50.5 53.3 5,253
15 134.4 126.8 5994 35 46 49.2 6504
16 66.5 68 2,206 36 41.5 45.1 7982
17 72.7 74.4 2285 37 37 41 9756
18 78.9 80.8 2351 38 32.5 36.9 11 924
19 85.1 87.2 2408 39 28 32.8 14 634
20 91.3 93.6 2,457 40 23.5 28.7 18 118
Average Error (%) 4,640
Table III, showed the results in many columns. No.
column is to display the number of testing, Sensor column to
display data from sensor readings, and other columns to
display data from a ruler . This test is done 40 times with the
reading of the data input is varied. The units are in centimeters.
Error gained from this test is 4.640%.
C. Delivery Testing Data
The last non-functional testing is the testing of data
transmission. Data transmission is a process to transmit data
from Sensor Node to the Master Node. The test is done to
determine the performance of data transmission between the
Sensor Node and Master Node. The test is performed 45 times.
Measurements are done by calibrating the time in transceiver
and receiver device to make sure that their time reference is
same, and then measuring the received time of data on the
Master Node reduced with transmission time at Sensor Node.
Table IV showed the results. No. column for testing numbers,
and the column Time with millisecond unit is the results of
reduction process. This test displayed an average delay
generated for data transmission is equal to 1147 milliseconds.
TABLE IV. D
ATA
T
RANSMISSION
T
ESTING
R
ESULT
No. Time (ms) No. Time
(ms)
No. Time (ms)
1 1234 16 1106 31 1004
2 1237 17 1045 32 1018
3 1234 18 1241 33 1020
4 1237 19 1234 34 1022
5 1228 20 1232 35 1028
6 1229 21 1208 36 1030
7 1234 22 1208 37 1033
8 1232 23 1135 38 1036
9 1241 24 1008 39 1039
10 1242 25 1004 40 1042
11 1241 26 1004 41 1206
12 1240 27 1005 42 1237
13 1241 28 1004 43 1268
14 1240 29 1005 44 1298
15 1241 30 1004 45 1329
Average Delay (ms) 1147
D. Fuzzy Logic Testing
The last is functional testing. It is done by giving some
inputs to the two sensors and then calculate it with the Fuzzy
Logic. The results is then observed whether it fulfills the
requirements or not.
TABLE V. F
UZZY
L
OGIC
T
ESTING
R
ESULT
Test
No.
Water Speed
(m / sec)
Water
Level (cm)
fuzzy
Output
Validity
1 8 4 Normal valid
2 32 4 Normal valid
3 8 5 Normal valid
4 32 5 Normal valid
5 8 7 Cautious valid
6 32 7 Cautious valid
7 8 8 Flood valid
8 32 8 Flood valid
9 56 4 Normal valid
10 64 4 Normal valid
11 56 5 Cautious valid
12 64 5 Cautious valid
13 56 7 Dangerous valid
14 64 7 Dangerous valid
15 56 8 Flood valid
16 64 8 Flood valid
17 120 4 Normal valid
18 144 4 Normal valid
19 120 5 Cautious valid
20 144 5 Cautious valid
Test
No.
Water Speed
(m / sec)
Water
Level (cm)
fuzzy
Output
Validity
21 120 7 Dangerous valid
22 144 7 Dangerous valid
23 120 8 Flood valid
24 144 8 Flood valid
Table V is the results. Test No. column showed the number
of tests performed. The Water Speed is in meter / second and
the Water Level is in centimeters. Both of these parameters
are given a random value input, but in accordance with a given
rule. Fuzzy output column showed calculation’s result from
fuzzy logic. The last column is the validity to verify
compliance with the system design. In this test, the overall
obtained results are valid.
IV. C
ONCLUSSION
This study is conducted to observe the condition of the
water in the drains and make a decision making based on that
observation. The drains can be a river, culverts, sewers, or
other waterways. The used method is fuzzy logic, because it
can cope with the ambiguity of the conditions of the used
parameters. This study has already produced a river’s
prototype equipped with an embedded systems to do the
Fuzzy Logic process computation. Arduino nano is chosen as
a processing device. The input parameters are velocity, which
is read by water flow sensor, and water level altitude, which is
read by ultrasonic sensor. Sensors and processors (called a
sensor node) are placed near the river and observation device
is placed at other locations (called the master node).
In this study, non-functional and functional system
requirements testing have been done. Non-functional testing
give results that is: error of 0608% for water speed sensor
reading, 4.640% for ultrasonic sensor reading, and the average
delay of data transmission is 1147 milliseconds. Functional
testing give results that Fuzzy Logic in the system are Valid,
fulfilling the system requirement in giving a good decision
based on the observation of data from sensors.
For future works, other parameters as input such as the
amount of water flow can be added to the system to make a
better predictions about potential risk of flood happening.
A
CKNOWLEDGMENT
Special thanks to Robotics and Embedded Systems
Laboratory, Computer Engineering Department, Brawijaya
University in giving facility to perform all of this research. this
research is part of the output of HPP 2019 held by LPPM
Brawijaya University.
R
EFERENCES
[1]
N. S. Debortoli, P. I. M. Camarinha, J. A. Marengo and R. R.
Rodrigues, "An index of Brazil’s vulnerability to expected increases
in natural flash flooding and landslide disasters in the context o
f
climate change," Natural Hazards, vol. 86, no. 2, p. 557–582, 2017.
[2]
Sudirman, S. Trisutomo, R. A. Barkey, H. I. M. Ali, A. Onishi, P.
Tsai and K. Yonezaki, "System of urban flood control: A
Comparative Study between Kanagawa Prefecture and Makassar
City," in IOP Conf. Series: Earth and Environmental Science, 2018.
[3]
E. Salminen, N. Christensen, J. Keller and C. Thieman, Hood River
Basin Water Conservation Strategy, Watershield Professionals
Network, 2016.
[4]
S. Banerjee and D. Dey, "Eco-system Complementarities and Urban
Encroachment: A SWOT Analysis of the East Kolkata Wetlands,
India," Cities and the Environment (CATE), vol. 10, no. 2, 2017.
[5]
A. B. M. Saed and A. R. E. Abdelaziz, "Flood Mapping and Risk
Assessments by Using Geographic Information System and Remote
Sensing," Sudan University of Science and Technology, 2016.
[6]
P. Adjei-Darko, "Remote Sensing and Geographic Information
Systems for Flood Risk Mapping and Near Real-time Flooding
Extent Assessment in the Greater Accra Metropolitan Area," KTH
Royal Institute of Technology, Stockholm, Sweden, 2017.
[7]
J. K. Peckol, Embedded System: A Contemporary Design Tool,
Wiley, 2019.
[8]
T. Nguyen and S. Z. Andreasen, "From Lab on a Chip to Point o
f
Care Devices: The Role of Open Source Microcontrollers; Anders
Wolff; Dang Duong Bang," Micromachines, vol. 9, no. 8, p. 403,
2018.
[9]
Z. Gao, Y. Yang, L. Zhai, N. Jin and G. Chen, "A Four-Sector
Conductance Method for Measuring and Characterizing Low-
Velocity Oil–Water Two-Phase Flows,"
I
EEE Transactions on
Instrumentation and Measurement, vol. 65, no. 7, pp. 1690-1697,
2016.
[10]
T. Perumal, M. N. Sulaiman and C. Y. Leong, "Internet of Things
(IoT) enabled water monitoring system," in 2015
I
EEE 4th Global
Conference on Consumer Electronics (GCCE), Osaka, 2015.
[11]
S. S. Sonavane and D. B. P. Patil, "Experimentation for Packet Loss
on MSP430 and nRF24L01 Based Wireless Sensor Network,"
Journal Of Advanced Networking and Applications, vol. 1, no. 1, pp.
25-29, 2009.
[12]
A. M. Davis, R. G. Pearson, J. E. Brodie and B. Butler, "Review and
conceptual models of agricultural impacts and water quality in
waterways of the Great Barrier Reef catchment area,"
M
arine and
Freshwater Research, vol. 68, no. 1, pp. 1-19, 2016.
[13]
M. H. H. Ichsan, W. Kurniawan and M. Huda, "Water Quality
Monitoring with Fuzzy Logic Control Based on Graphical
Programming," Telkomnika, vol. 14, no. 4, p. 1446, 2016.
[14]
M. Fakoor, A. Kosari and M. Jafarzadeh, "Humanoid robot path
planning with fuzzy Markov decision processes,"
J
ournal of Applied
Research and Technology, vol. 14, no. 5, pp. 300-310, 2016.
[15]
H. Z. Sabzi, D. Humbersona, S. Abudu and J. P. King, "Optimization
of adaptive fuzzy logic controller using novel combined evolutionary
algorithms, and its application in Diez Lagos flood controlling
system, Southern New Mexico,"
E
xpert Systems with Applications,
vol. 43, pp. 154-164, 2016.