Analysis and Implementation of Monitoring Flood System Based on IoT using Sugeno Fuzzy Logic

– Flood disasters can have a detrimental impact such as damage to infrastructure, materials, and loss of life. One of the efforts that can be made to carry out early detection of flood disasters is to use a flood prediction system, where this system can monitor water levels, water flow rates, and predict real-time water increases. Information is sent to every citizen using the telegram chatbot. This system is built using several sensors and integrated with Telegram. The Sugeno method is more suitable to be applied in this study because the output required in the study is in the form of constants or linear equations. The sensors used are ultrasonic and water flow sensors. The ultrasonic sensor is used to read the water level in the range of 0-50 cm and the water flow sensor is used to calculate the flow of water entering the test face with an interval of 0-10 liters/ minute. Data is sent to telegram in realtime using the firebase database using the NodeMCU ESP8266 and the WiFi module. The results of reading water level and water discharge data are processed using Sugeno fuzzy logic. The results obtained in this study indicate that the average error reading from the ultrasonic sensor is 2.43% or 97.58%. The water flow sensor shows an average error of 0.206 liters/minute or the percentage of tool accuracy is 87.06 %.


INTRODUCTION
Based on data from the Indonesian Ministry of Home Affairs (KEMENDAGRI), there are around 5,590 main rivers and 65,017 tributaries spread across the archipelago. Of the number of main rivers, the Watershed (DAS) reaches 1,512,466 square kilometers [1]. Flooding is caused by several factors, such as the amount of water discharge flowing from other environments or drainage channels or the like towards the river, and/or high rainfall intensity, so that the water experiences an increase in water volume rapidly and exceeds the river limit which results in the river overflowing. Several attempts have been made by the government, but flooding can still occur. One of the early detection efforts needed is to use a technology-based approach with the use of sensors combined with information systems, information or notifications can be disseminated through application media.
Fuzzy logic is a calculation method that can predict the output or output in the form of uncertainty, so that the data obtained from a test is processed with fuzzy logic so that it becomes more accurate. There are three methods of fuzzy logic, namely the Tsukamoto, Mamdani, and Sugeno methods [2]. In the Tsukamoto method, every rule in the form of IF-THEN must be presented in the form of a fuzzy set with a monotonous membership function. The Fuzzy Mamdani method is one part of the Fuzzy Inference System which is useful for drawing conclusions or the best decision in an uncertain problem by using the MAX-MIN function, only the system output or output is not a fuzzy set but a constant [3]. Therefore, the Sugeno method is more suitable to be applied in this study because the output required in the study is in the form of constants or linear equations.
Telegram is a free application that is used to send messages. Telegram can be operated on mobile devices such as iOS, Android, Windows phone and on computer devices such as Linux, Windows, and Mac OS [4]. One of the Application Programming Interface (API) provided is the Chatbot feature. Chatbot implementation has started to be widely used. One of the advantages of Chatbots is the reliability of providing data to users that is not limited by time, and it allows anyone to create a bot that will reply to all its users if it sends a command message that the Chatbot can accept [5]. Sending data via Telegram is safe because the encryption process has been carried out.
The research conducted by D.Kurniawan et al aims to monitor the weather in real-time. The system is designed using temperature, air pressure, and humidity sensors [6]. Research conducted by Mawarizkar Radhya and Agus Mulyana aims to monitor or monitor river water levels in the hope of minimizing losses from flood events. The system is designed to display river and rain water level control information in certain areas via Android and the website [7]. Research conducted by Wahyu Indianto et al aims to help homeowners to find out early on when flooding occurs so that they can save valuables (items that are vulnerable to water) to be placed or stored in a safer place. The system is designed to display flood early warning information to users via SMS [8]. Research conducted by Dedi, et al aims to send information on water level data and flood status as safe, alert, and dangerous to the website information system [9].
Research conducted by Dwi Rahma Ariyani, et al aims to send flood information by region via google maps in the android application [10]. Research conducted by Chrisyantar Hasiholan et al using the MQTT Protocol aims to disseminate flood information through the website as a solution to flood problems in an area [11]. Research conducted by Angga Prasetyo, Moh. Bhanu Setyawan in [12] aims to provide flood awareness information through the Telegram Chatbot. Research conducted by Moh. Fikullah Habibi aims to determine flood-prone zones, study the results of flood-prone zoning based on different types of rain data, analyze events, and identify areas that have the highest risk [13]. Research conducted by Novi Lestari et al at the Social Service of the Tagana Unit of Lubuklinggau City aims to provide information about flooding and water levels on websites in various places quickly and easily accessible [14].
Based on this background, the authors conducted research by modelling the river test environment into a river monitoring tool for flood mitigation by predicting water level per unit time by applying Sugeno's fuzzy logic. Thus, this tool can send flood early warning information quickly and easily understood by the public through the Telegram Chatbot media so that people are ready to anticipate flood disasters early.

METHODS
This study has a system design that is described using a schematic diagram. The diagram is a representation of each component of a process contained in the system. The schematic of the research diagram can be seen in Figure 1. In Figure 1 there are 3 layers with the following information: 1. The Sensor Node Layer consists of: a. The application of fuzzy logic to ultrasonic sensors is used to read water level data. The result in the form of a message, "SAFE STATUS" or "STANDBY STATUS" or "DANGER STATUS" or "ATTENTION STATUS" or "FLOOD STATUS" is displayed on the LCD monitor. For the result, Buzzer alarm sounds with pauses of 1 second for 10 times at hazard water level, pauses of 0.5 seconds for 10 times at water level alert, pauses of 0.2 seconds for 10 times at flood water level. LED light with description: green light on when Safe condition, yellow light on when Standby, and red light on when Danger, red light flashes every 0.5 seconds during Alert, and red light flashes every 0.2 seconds during Flood b. Water Flow sensor to calculate water discharge to predict how high the river water rises per second and is displayed on the LCD and cell phone 2. Layer Sink Node, there is a NodeMCU that provides a WIFI signal with the following functions: a. To access and send data from sensor detection results on Telegram Chatbot b. To connect a device with the Firebase Database 3. Layer Client Layer consists of: a. The LCD monitor gets the information data from the microcontroller and displays the status information of the last water level b. The phone gets information data from the Telegram Chatbot and displays the latest water level status information c. Firebase stores data from sensor detection results in the system and displays real-time status information on the last water level The flood prediction system uses water flow sensors and ultrasonic sensors that can predict water levels and river water discharge based on safe, alert, danger, and flood alert levels. The sensor is connected to a microcontroller which oversees sending sensor reading data. Data that is processed using fuzzy logic and data from sensor detection results will be sent to the Firebase Database.

Hardware Design
The hardware needed in the study amounted to 8 components. Consists of NodeMCU, Ultrasonic Sensor, Water flow Sensor, Buzzer, Jumper Cable, LCD I2C Monitor 16*2, Power Supply, and Test Container. The hardware requirements can be seen in Table 1. As a microcontroller that functions to detect the safety status of river water using sensors and is connected via a cellular network to control flooding and as a medium that transmits Wi-Fi signals to access Firebase Ultrasonic Sensor HCSR04 As a sensor to detect objects that are still and moving with a certain distance.

Water flow sensor
As a sensor to calculate the amount of water discharge. Active Buzzer As an alarm that produces sound waves.

Jumper Cable
As a connecting line between disconnected circuits. 16*2 . I2C LCD As a device that will display flood prediction system information Power Supply As a device to turn on the microcontroller.

Experiment Container
As a place for the system tool to be placed to read the water level by the sensor.
There are 2 points in the hardware design, which are as follows:

a. Inner View Hardware Design
The monitoring hardware design can be seen in Figure 2. In Figure 2 the design of the monitoring hardware looks inside there is a test container containing an ultrasonic sensor and a water flow sensor. The ultrasonic sensor will be mounted on the upper side of the test container to detect the water level with a distance based on a certain level of height in the test container. The water flow sensor is mounted on the side of the ultrasonic sensor to measure the water flow rate or water discharge that will enter the test container through the hose that is attached to the water flow sensor.

b. Outer Hardware Design
The hardware design looks inside can be seen in Figure 3.  Figure 3, the external monitoring hardware design at the top of the test container has a water flow sensor to drain water from a water source through a hose and the NodeMCU is above the cover of the test container. The test container is designed to be made of acrylic.
Functional requirements are requirements that contain processes, services, and how a system can behave on certain inputs to the system to be developed.
The functional requirements of the flood prediction system are: 1) Ultrasonic sensor reads high water values at safe, alert, danger, alert and flood levels in the system; 2) The water flow sensor reads the water discharge value per unit time in the system; 3) The microcontroller can display information on water level, water discharge, and water level status on the LCD monitor; 4) Sending Telegram Chatbot notifications with certain conditions automatically to the user's cell phone to monitor the river remotely safely; 5) Save sensor detection data to Firebase automatically.

Activity Diagram of Overall System
Activity diagram of the whole system work can be seen in Figure 4. Based on Figure 4, the activity diagram starts when the user turns on the tool, then the tool works by detecting the water level and water discharge simultaneously then the tool sends the detection data to the system. The system then displays water level and water discharge information on the serial monitor and LCD monitor. Next, the system displays information on water level, water flow, and predictions of rising water to the next level on Firebase, then the system performs the process again to display information on water level, water flow, and predictions of water rise to the next level on the Telegram Chatbot with certain conditions. When the tool is working, the user can turn off the tool or not, if not then the tool will continue to work automatically, if yes then the tool will stop working.
These stages include: Fuzzification At this stage, change the input data of water discharge with height in the river modelling test container from a firm form (crisp) to a fuzzy form (linguistic variable). There is data on the height of the river modelling which can be seen in Table 2.  The membership of the water level fuzzy value can be seen in Figure 5 and the membership of the water discharge fuzzy value can be seen in Figure 6.

Application Function Implication
The application stage of the implication function, namely the formation of rules used to process fuzzy data. There are 2 inputs, namely water level and water discharge with 5 variable water levels and 3 variable water discharge resulting in 15 variables.

Aggregation
The aggregation stage is to produce the output of each rule. There are 5 fuzzy logic outputs with a value range of 0 to 1 [15]. The outputs of the flood prediction system, namely Safe Information, Alert Information, Hazard Information, and Flood Information have values, namely: 1) Safe Information is 0; 2) Alert Information is worth 0.25; 3) Hazard Information is 0.5; 4) Alert Information is worth 0.75; 5) Flood Information is worth 1.
In a variable of water level each has 2 different outputs when multiplied by the variable of water discharge, except for the flood variable which only has 1 output. For each water level variable, the condition of a water level variable at that time has the potential to produce the next water level variable, resulting in 27 fuzzy value rules from 2 inputs with 5 water level variables and 3 water discharge variables can be seen in Table 3 and Figure 7.

Defuzzification
The defuzzification stage is a process to get a crisp output value (firm). Defuzzification is done by finding the average value, with the equation [16]: (1) Description: = Average value, = rule predicate value to n, = constant output value index to n

Design of Water Level Increase Prediction
The design of the prediction of the increase in water level is influenced by the time of the intensity of the flowing water, so to calculate the prediction of the increase in water by using the formula for the time of water intensity, by using the derivative of the formula for water discharge as follows [17]:

RESULT AND DISCUSSION
In this study, the hardware used is shown in Table  1. The design of the flood prediction tool can be seen in Figure 8. In Figure 8, pin D1 is the yellow cable for the SCL port, pin D2 is the green cable for the SDA port, and the Vin pin is the red cable for the SCL port. The 5V VCC and GND pins are the black wires for GND on a 16x2 I2C LCD. On pin D3 is the green cable for the ECHO port, pin D4 is the yellow cable for the TRIG port, the Vin pin is the red cable for VCC 5V and the GND pin is the black cable for GND on the Ultrasonic Sensor. On pin D0 is the red wire for the red cathode, D5 is the yellow wire for the green cathode, D6 is the green wire for the blue cathode, and the GND pin is for the RGB LED anode. On pin D7 for signal/pulse, the Vin pin is the red wire for VCC 5V, and the GND pin is the black wire for GND on the Water Flow Sensor. On pin D8 for Buzzer signal. The results of the design of the flood prediction tool can be seen in Figure 9 and Figure 10. In Figure 10 there is a flood prediction tool placed at the top of the test container. The function of the tool is the NodeMCU 8266 microcontroller as a control tool and a Wi-Fi signal provider to receive ultrasonic sensor readings and water flow sensors. The ultrasonic sensor is placed in the centre of the cover which is given a hole to read the water level. The water flow sensor is placed next to the ultrasonic sensor which has also been given a hole to channel water and reads water flow data that enters through a valve that is connected from the water source to the water flow sensor. When the water level and discharge data are read, the microcontroller will display water level and water flow data information on the 16*2 I2C LCD, Telegram Chatbot notifications that are automatically sent by the tool and send a realtime database to Firebase. Figure 10 is a river modelling in the form of a test container that has been filled with river rocks and fake plants to make it look like the original river. The test container is used to hold water and as a reference for measuring the water level that will be used when the flood prediction tool is working.
In this research, the software used is Telegram Chatbot. The NodeMCU ESP8266 microcontroller provides a Wi-Fi signal to access the Telegram Chatbot software on the user's phone. In Figure 11, is a list of menus provided by BotFather. Currently, the author types the function / newbot to create a new bot. Gambar

Bot father Menu
In this study, Sugeno's fuzzy logic modelling flood prediction system uses MATLAB R2015a tools which have 2 inputs, namely water level and water discharge and 1 output, namely water level information which can be seen in Table 4. In Table 4 there are 2 input values, namely water height and water discharge and 1 output value, namely flood information. The input value for water height has 5 variables, namely safe level (0 -20 cm), standby (20 -30 cm), danger (30 -40 cm), alert (40 -45 cm), and flood (45 -50 cm). and the input value of water discharge there are 3 variables, namely small (0-5 litters/minute), medium (5-8 litters/minute), and large (8-10 litters/minute). The output value at the time of testing the tool there are 5 variables, namely safe information (0 -20 cm interval), standby information (20 -30 cm interval), hazard information (30 -40 cm interval), alert information (40 -45 cm interval), and flood information (45 -50 cm interval). Segeno fuzzy membership formula can be seen in the formula 3 [18].  Figure 12 shows that lines a and b have a value between 0 to 1 degree of membership, on lines b and c the degree of membership is worth 1, on lines c and d the degree of membership is between 0 to 1, and in addition to lines a, b, c and d degree of membership is 0. The implementation of membership value fuzzy input water level which has 5 variables, namely safe, alert, danger, alert, and flood can be seen in Figure 13 with the type of input value trapmf (Trapezoidal membership function) or the type of member function trapezoidal shape.

Implementation of Water Level Increase Prediction
The application of predictions for increasing water levels in this study uses Arduino IDE programming with a water intensity time formula that has been modified to suit the needs of the equipment used. The application of flood prediction calculations can be seen in Figure 14.  Figure 14 is a flood prediction calculation when predicting an increase in water from a safe level to a standby level, alert to a danger level, danger to an alert level, alert to a flood level. This calculation is applied to each level from 5 prediction applications at 5 water levels, namely the safe to standby hose is 20 cm, the standby to danger hose is 10 cm, the danger to alert interval is 10 cm, the alert to flood hose is 5 cm, and the flood has a 5 cm interval. cm from the height of the test container.

Ultrasonic sensor accuracy testing
In testing the accuracy of the ultrasonic sensor compared to a measuring ruler, which can be seen in Table 5. The following are the results of the comparison of the ultrasonic sensor and the measuring ruler. In Table 5 testing the accuracy of the ultrasonic sensor there are 5 test samples to test the accuracy of the reading value of the tool data using a ruler, so that an average error difference of 2.43% is produced and the accuracy of the tool is 97.58%.

Water Flow Sensor
In testing the water flow sensor, there are 2 test items, namely detecting the flow of water entering the test container and testing the accuracy of the water flow sensor.

Testing the flow of water entering the test container
In testing the water flow using a water flow sensor. Data retrieval is carried out with indicators of success, namely being able to read incoming water through a hose connected to the sensor when water is flowing. The flood prediction tool is placed at the top of the test container by providing a hole for the water flow sensor so that it can channel water from the water source to the test container using a hose attached to the water source to the valve on the water flow sensor. The valve functions to read the incoming water flow through the water flow sensor. Then the test is carried out by opening the water tap with water that has been accommodated in the water reservoir (tower). Next, the faucet is opened with a lever measure of 45 degrees for 30 seconds. The results of the water flow sensor test can be seen in Table 6

Testing the accuracy of the water flow sensor
In testing the accuracy of the water flow sensor by comparing the difference in reading water discharge data from a water source (water faucet) with a water faucet lever that is opened 45 degrees for 30 seconds which can be seen in Table 7. In Table 7 testing the accuracy of the waterflow sensor there are 5 test samples to test the accuracy of the reading value of the tool data with a water tap lever that is opened 45 degrees for 30 seconds, so that an average difference in test error of 0.206 litters / minute and percentage the accuracy of the tool is 87.02%. The results of the overall comparison of the input and output fuzzy values on the tool directly by testing using MATLAB can be seen in Table 8. Based on Table 8, there are 5 data samples that the authors concluded that the results of the comparison of measurements on the tool with fuzzy values on MATLAB are appropriate because they have fuzzy values with water information that are similar to water information on the tool.

CONCLUSION
The results of the conclusions in the study are as follows: In testing the accuracy of the ultrasonic sensor, there are 5 test samples to test the accuracy of the reading value of the tool data using a ruler, so that an average error difference of 2.43 % is produced and the accuracy of the tool is 97.58 %. In testing the accuracy of the water flow sensor, testing the accuracy of the waterflow sensor, there are 5 test samples to test the accuracy of the reading value of the tool data with a water tap lever that is opened 45 degrees for 30 seconds, so that an average difference in test error of 0.206 Litters / minute and the percentage of tool accuracy is 87.06%.
In Sugeno's Fuzzy Logic test, that the results of the comparison of measurements on the tool with fuzzy values in MATLAB are appropriate because they have fuzzy values with water information that are like water information on the tool.