Control and Monitoring Automatic Floodgate Based on NodeMCU and IOT with Fuzzy Logic Testing

Flood is still a problem that always been a major obstacle in several big cities in Indonesia such as DKI Jakarta. If the rainfall so high and river can be accommodating the rainfall, there will be flooding. So that river water doesn’t overflow, it is necessary to make a floodgate in the river flow. One of the previous studies that has been carried out regarding the control and monitoring of water dam gates is researched by Fahruddin. 2014 from the Faculty of Science and Technology, Makassar State Islamic University: Describes the design of a device capable of monitoring the height of water activity in the reservoir and controlling the floodgates automatically according to the height of water activity. The research that the writer is currently carrying out is the design method which consists of a series of sensors, NodeMCU microcontrollers, and Stepper Motors. The workflow of this system is when the water rises or falls, it sends a signal to the sensor. And then the signal will be input for the microcontroller which is then processed to turn on the motor, so that it can open or close the floodgates, and send information to the indicator screen and Telegram application. After the experiment is carried out, it can be said that the system can work properly, namely when the ultrasonic sensor experiment, it was found that the sensor has been sent an output signal that was in accordance with the water level in actual condition. Based on testing using the fuzzy method, it was found that opening value at the floodgate obtained during the test had an average accuracy rate of 91% with an error difference of 9%. Keywords—Floodgate, Water Level, Ultrasonic Sensor, Microcontroller, NodeMCU, Rainfall, Fuzzy Logic


INTRODUCTION
Rainy season still haunts the citizens of the capital. In Indonesia, the rainy season occurs for five to six months. During on the period, Indonesia region have a potential to rain with varying rainfall [1]. During extreme weather events transport infrastructure can be directly or indirectly damaged, posing a threat to human safety, and causing significant disruption and associated economic and social impacts [2]. Flooding, especially as a result of intense precipitation, is the predominant cause of weather-related disruption to the transport sector [3], [4]. If the rainfall is very high, and the river cannot accommodate this rainfall, there will be flooding.
To regulate river water discharge so as not to overflow and causing flooding, it is necessary to make a floodgate in the river flow, because the floodgates in urban river flows have an important function, because that is one of the instruments for controlling river water and become one of the elements of flood control [5].
Optimal flood management in complex river networks is then a way to reduce flood hazard, at a relatively low cost compared to structural measures [6]. The advancement of technology had many influences in aspects of life, especially in the field of urban planning [7]. In modern urban planning, a good control system is needed to carry out and support the urban planning process [8]. Uncontrolled water level can make a reservoir overflow due to lack of information to the flood gate supervisor, this is due to the current flood gate control system [9]. Therefore, manual floodgate control is less effective for controlling river water flow [10], because it was only based on monitoring the water level, therefore the ineffective control of river floodgates is still a major factor in the occurrence of flooding [11]. Based on the above problems, it can be concluded that the relevant agencies need to prepare a monitoring device as well as control the river floodgates automatically.
At the present time now is not impossible to carry out control and monitoring by remote, as the NodeMCU microcontroller can be programmed so that it can monitoring and controlling the floodgates automatically, so that is the background for author to design and build a monitoring and controlling automatic floodgate based microcontroller with Fuzzy logic testing methods.

II. METHOD
In this research, the Fuzzy system is used control floodgate, so that it can be seen whether the device designed is in accordance with mathematical calculations or not. Fuzzy algorithm was proposed by Lotfi Zadeh In 1965 [12], [13]. This algorithm is developed to find solution based on approximate reasoning, that is neither very imprecise nor very precise [14]. From 1965 until now a lot of new fuzzy methods has been develop such as FTS [15], [16], FMEA [17], ANFIS [18], TOPSIS [19]. This fuzzy method not only control problems but also other real world problems [20]- [22], but also decision making [23], supplier selection [24], [25], traffic light [26], Risk and Fault analysis [27]- [29], forecasting [30], and others [31]- [34].
In this fuzzy method design, there is a membership function, where the membership function is a range of values to represent the linguistic variables that are owned so that these variables will determine the outcome of the  Variable of water level has 9 sets: 5cm, 6cm, 7cm, 8cm, 9cm, 10cm, 11cm, 12cm, and 13cm. Meanwhile, the increase variable in the floodgate opening has 3 variables: the increase with a range of 0cm <1cm, a range of 1cm <3cm, and a range of 3cm <5cm.
Based on the input and output values in Table 1, the fuzzy rules can be set which will be programmed as shown in the Table 2 and Fig. 1. Then to test this prototype are using the Weighted Average formula as follows:

= ∑
For example, calculating the water level input 8 cm using the Weighted Average formula as follow. Calculating the value : [8] = 10 − 8 10 − 7 = 0.6667 The "Z" value is: So that the value of the increase in the floodgate if the water level in the tank reaches 8 cm when calculated using the weighted average formula is 1.6667 cm.

A. Prototype Design
The prototype design is shown in in Fig. 2. The ultrasonic sensor functions to measure a water level, and will send input to the NodeMCU so that it can send a signal to the OLED screen and send notifications to the Telegram application, such as a water level and altitude status. NodeMCU also processes the data received, so that it can determine level of opening the floodgate.
The motor on the floodgate functions as a gate driver to move up or down, adjusting the command from the NodeMCU which previously got the output value from the water level read by the ultrasonic sensor. When the sensor reads the water level has reached 11cm or more, the buzzer will light up and indicate a danger status.

A. Prototype Testing
Testing on the prototype is doing to find out whether the hardware or software can work in accordance with the planning of this research. Prototype testing is also useful for knowing the level of performance of the prototype function, so that all deficiencies and risks in the tool can be minimized so that the design of the tool can actually function effectively and be useful when implemented in the field.
Based on the Table 3, when the water level has detected, starting from a level of 1cm up to level of 13cm, overall the value that appears on the OLED indicator screen has a difference in accuracy of an average of 3.1803% error.

B. Notification Telegram Testing
This step is a testing the results of notifications about the status and water level via Telegram application. In this prototype design, the telegram notice will send notifications through the group so that all residents can monitor the water level with their smartphones wherever and whenever.
Test of the result this a quite important, considering that all the output results produced by this floodgate controller will affect the information obtained by residents who live around the river, so that residents and stakeholders can take effective steps in flood prevention and early response steps to minimize the risk of flooding. The test results:  Fig. 4 is showing the status and water level on the OLED screen are same as that appears on the telegram notification, which is 11cm. At this altitude the status showed "ALERT", so that through this notification the residents get information that the water level on the river is quite high.

C. Fuzzy Analysis
As the author has previously described, this research using Sugeno-type fuzzy test, which uses the "weighted average" mathematical formula. The author chose the calculation of fuzzy logic using the weighted average formula because the formula is very easy to apply, so there is no need to use mathematical software such as Matlab or etc. All test data using the weighted average formula have been obtained in Table 4.
Based on the Table 4, the results show that there is a difference between increase of the sluice gate with the calculation using the weighted average formula. The average error is taken at each height level, the difference between the actual calculation using the fuzzy method is 9% error. According to the author's opinion, this occurs due to the unstable flow of the electric current at the MCU node so that it affects the stability of the electric current received on the stepper motor components.

IV. CONCLUSION
The NodeMCU microcontroller is used as a component to process data from the system which functions to receive output and send commands to the stepper motor so that it can open the floodgates automatically by adjusting the water level. Based on the Table 4, it can be concluded that the test using the fuzzy method is the result of the height of the increase in the sluice gate obtained when testing has an average error difference of 9%.
IoT-based notifications through the Telegram application are useful for make it easier for residents around the river to get actual information. So that residents and stakeholders around can take effective steps in flood prevention and early handling steps to minimize the risk of flood disasters.
To develop this research, in order to be more effective when implemented in the field, the selection of components on the tool needs to be improved and developed with a sensor to detect rainfall levels, so that the command generated for the floodgate is more accurate and effective.