Wireless Sensor Network (WSN) of a flood monitoring system based on the Internet of Things (IoT)

. Indonesia records exceptionally high rainfall, particularly during the rainy season when almost all areas of the country are consistently showered with heavy rain. Vigilance is therefore crucial due to the risk of flooding from overflowing rivers or dams. It is essential to develop flood monitoring systems to mitigate the risk and impact of flooding. This study aimed to design and build a flood monitoring system with parameters that support flood warnings. These include measurement of the water level using an ultrasonic sensor and rainfall using a tipping bucket-based hall sensor. The flood detection system was installed at Pondok Aren, Tangerang Selatan, Banten. A website was developed to display information on water levels and rainfall measurements every 10 minutes, as well as cumulative rainfall over 24 hours, presented in values, tables, and graphs. The device design included a warning feature in the form of a strobe light that would activate if the water level exceeded the minimum threshold in addition to providing rainfall status notifications. The system performed well in trials, with data transmitted to the database every 10 minutes. Raingauge sensors exhibited a 0.86% error rate, while the ultrasonic sensor showed an average error rate of just 0.25%.


Introduction
The vast archipelagic nation of Indonesia faces a significant and persistent threat from natural disasters, 76% of which are categorized as hydro-meteorological events, including floods, landslides, tropical cyclones, and droughts [1].
Situ Parigi is an artificial lake spanning 52,500 square meters with depths ranging from 1 to 4 meters.It is located in Perigi Lama Village, Pondok Aren, South Tangerang, Banten.Situ Parigi contains two water gates that are controlled by gatekeepers.The gates are opened when the water level reaches a specified height to prevent flooding in the surrounding areas due to river water overflow.Opening the water gates also helps to maintain the level of Situ Parigi, thus ensuring its capacity is not exceeded.During the rainy season, Situ Parigi frequently experiences heavy rainfall, creating a rapid increase in its water level.The gatekeepers must therefore conduct daily or afternoon inspections of the water level at the gates, especially during periods of intense rainfall.However, these inspections continue to be performed manually by physically visiting the gates.In a bid to improve the process, this research introduces the development of an automatic water level monitoring system.
Floods are among the frequent natural disasters that occur in Indonesia, particularly during the rainy season.These disasters can lead to both material and non-material * Corresponding author: agustina.rahmawardani@stmkg.ac.id losses for communities, including damage to buildings, the loss of valuable belongings, and even the loss of life.Factors contributing to flooding include high rainfall and overflowing river water levels.To minimize casualties and the impact of flood disasters, it is essential to promptly disseminate information and early warnings about potential floods [2].
A monitoring and warning system that is accessible, fast, and continuously available is critical for delivering urgent flood-related information to communities.An early warning mechanism is also an essential tool for informing the community so that they can prepare for impending floods [3].The implementation of an effective natural disaster early warning system requires appropriate technology.One commonly used method comprises an Internet of Things (IoT)-based disaster warning information system.This offers numerous advantages, including automatic and real-time operation 24/7 [4].
A flood early warning system aims to assist the community in anticipating flood occurrences.This research therefore develops a flood monitoring system employing rainfall and ultrasonic sensors to monitor water levels.The system will trigger an audio alarm and strobe lights whenever the water level reaches or exceeds a predetermined threshold.This monitoring approach not only simplifies the task of inspecting water levels for the gatekeepers of Situ Parigi but also enhances overall disaster preparedness.

Ultrasonic sensor
The progression of global digitalization has led to significant advances in technology that enable measurements to be conducted free from any physical contact with the objects being measured.One such cutting-edge technology employs sound waves, commonly known as ultrasonic waves [5].The technique of water level detection using ultrasonic sensors has gained widespread popularity due to its high accuracy, which minimizes analysis errors.Ultrasonic sensors operate on the principle of sound wave reflection to detect the presence of a specific object in front of them.Ultrasonic waves are sound waves with frequencies above 20 kHz.They share similar properties with regular sound waves, including the ability to bounce off surfaces and propagate through solid and air mediums with low energy, making them suitable for distance measurements both in the air and underwater [6].An ultrasonic sensor comprises two main units: a transmitter and a receiver.The transmitter circuit emits ultrasonic waves while the receiver circuit detects the reflected waves [7].Ultrasonic sensors operate at frequencies ranging from 40KHz to 400 KHz.The transmitter emits ultrasonic waves into the air.When these waves encounter specific objects, they are reflected and then received back by the receiving sensor unit within the ultrasonic sensor, as shown in Figure 1.[8].
The measurement distance for the JSN-SR04T ultrasonic sensor ranges from 25cm to 4.5m, which means it can be positioned more safely in a higher location compared to submerged conditions.The process of determining the distance from the JSN-SR04T ultrasonic sensor uses the following equation 1 [9].D = (HLT) x (SS) / 2 (1) Where: D = distance (in cm) HLT = high-level time or sensor output data (in µs) SS = speed of sound (0.034 cm/µs) Fig. 2. Ultrasonic sensor JSN-SR04T

Rain gauge
The tipping bucket rain gauge is commonly used to measure rainfall.It is favored for its automatic functionality and high efficiency in collecting rainfall data Figure 3.

Fig. 3. Tipping bucket rain gauge
The tipping bucket comprises four main parts: a rainwater collection funnel, a tipping sensor, a transducer in the form of a reed switch, and a transducer pulse generator connector.When obtaining measurements, the area of the funnel hole is a determining factor in the amount of rainfall received.The conversion factor used to calculate the amount of rainfall from the rain gauge is based on the volume of water required to tip one bucket.Typically, the conversion factor is expressed as a unit of volume (e.g., millimeters or inches) per tip.For example, if one tip of the rain gauge results in 0.2 millimeters of water, then the conversion factor is 0.2 mm/tip.Thus, each tip of a bucket corresponds to 0.2 millimeters of measured rainfall [10].
It is essential to periodically check and calibrate the conversion factor to ensure the accuracy of the rainfall data produced.The rainfall counter operates via a sensor that measures rainfall by collecting rainwater up to a specific value (e.g., 0.1 mm, 0.2 mm, 0.5 mm, or 1.0 mm).When the rainwater reaches this value, the sensor is triggered and the reed switch connects, generating a square pulse signal.This signal is then counted or converted to obtain the total amount of rainfall.
The pulses are recorded manually or automatically using a digital data recorder.The recorder stores information on the number of pulses or triggers generated by the sensor.The total rainfall over a specific period can be calculated by analyzing this data.
The system provides an accurate and efficient method for collecting rainfall data.Because the sensor is triggered by a specific amount of rain, each measurement can be precisely calibrated.The collected data is valuable for various applications, including weather analysis, hydrological research, and other fields that require detailed information about rainfall in a particular region.A detailed algorithm explanation for Figure 5 is given as follows: 1. Start: The system begins the program by initializing the devices, which consist of the JSN-SR04T ultrasonic sensor, The hall effect magnetic sensor, and the NodeMCU ESP8266.2. If the device initialisation fails, the system will rerun the process.If the device initialization is successful, the program proceeds to the next step.

System Block Diagram
Fig. 6.Block diagram of the system The system employs numerous input systems containing ultrasonic sensors to measure the water level and rain gauges to measure rainfall.The readings and measurements from these sensors and instruments are then processed through an Arduino microcontroller.The resulting data, which includes flood information and warnings, can be received through multiple media, namely an LCD for direct monitoring on the device, and can also be sent via the internet to a website.If the water level exceeds the predefined threshold, the relay will activate a strobe light.

Implementation of the system
The implementation of the instrument and display are shown in Figures 7 and 8, respectively.Figure 7 shows all the components of the device, assembled as a whole, viewed from the front and also from the side, along with the data logger component.The implementation of the website interface followed that of the designed website layout.The system website interface displaying water level and rainfall monitoring data at the Situ Parigi reservoir can be accessed at https://fewsstmkg.com.The website also presents monitoring data for water levels at West Jurang Mangu and rainfall at Pondok Pucung.The interface consists of five menu tabs: home, graphs, tables, locations, and info.The data on the website is updated approximately every ±10 minutes.Figure 8 shows the display output of the website interface.

Testing of JSN-SR04T Sensor
The JSN-SR04T sensor was tested to gauge its output response and assess its performance in measuring the height parameter.This testing was performed by comparing the sensor with a rolling tape measure.The comparative data were recorded and used to calculate the correction values generated by the sensor [11].Set points of 100 cm, 140 cm, and 150 cm were used, representing the distances between the sensor and the Styrofoam.Five measurements were taken for each set point.The comparative data from the JSN-SR04T sensor can be seen in Table 1.Based on the comparative results between the JSN-SR04T sensor and the rolling tape measure, it was determined that the sensor had an average measurement error of 0.2% at set point 100, 0.286% at set point 140, and 0.133% at set point 150.

Testing of the Magnetic Sensor on the ARG
The magnetic sensor on the ARG was tested to understand its output response, thus facilitating an assessment of its performance in measuring the tip count parameter.This evaluation enabled the calculation of rainfall values for each tip of the tipping bucket on the ARG.Comparative data were recorded and utilized to obtain the correction values generated by the magnetic sensor, as detailed in Table 2.The data in Table 2 indicate that the water measurements using the tipping bucket were read relatively accurately, with an average error rate of 0.86%.

Testing of the Water Level Float Sensor
The water level float sensor was tested to understand its output response; this enabled an assessment of its performance in the specific parameter of sending a high signal.The sensor was tested by repeatedly raising and lowering the sensor float.When the float rises, the sensor sends a high output signal; when it lowers, it sends a low output signal.The sensor output was displayed on an I2C 20x4 LCD screen, and the data can be seen in Table 3.

Table 3. Results of the water float sensor comparison
Based on the results of the water level float sensor testing in Table 3, it can be observed that the water level float sensor has a measurement error of 0%.

System Field Test
A field test of the system was conducted by installing the equipment at the Situ Parigi reservoir.Water level and rainfall data were then sent to a website using the ESP8266 every 10 minutes.The process of sending data to the website proceeded smoothly.The data stored in the database is displayed on the website https://fewsstmkg.com.Selected data acquired during the system field test is shown in Figure 9. Based on the sample data from Figure 9, the water level of the Situ Parigi reservoir was observed to rise with an increase in rainfall intensity.During the testing period, the rainfall at Situ Parigi was classified as moderate, with a 24-hour rainfall intensity measurement of 50.46 mm/day.To test whether the strobe light would activate when the water level of the Situ Parigi reservoir reached or exceeded the level of the water level float sensor, the float on the sensor was manually raised.When the float was lifted, the strobe light activated, as shown in Figure 12.This observation confirmed that the strobe light functioned correctly.
An automatic transfer switch (ATS) is a device that operates automatically when the power source from the utility grid (PLN) is interrupted or experiences an outage.In such cases, the switch will transition to an alternative power source, which in this system is a battery.To test that the ATS was functioning correctly, a cut in the power from the PLN was simulated by moving the miniature circuit breaker (MCB) switch to the OFF position.This disconnected the flow of utility power to the terminal.
When the MCB switch was returned to the ON position, the utility power from PLN began flowing again, as indicated by the illumination of a blue 5mm LED light.However, when the MCB switch was moved to the OFF position, the utility power from PLN ceased, triggering an automatic switch to the battery power source with a transfer delay of approximately ±2 seconds.Therefore, the ATS functioned correctly and effectively transferred power sources during the simulated utility power outage.

Conclusion
The following conclusions are drawn from this research: 1.The design of this device incorporated a JSN-SR04T sensor, a water level float sensor, a hall effect magnetic sensor, and a strobe light.A NodeMCU ESP8266 was used as the microcontroller and data transmitter.The water level and rainfall measurement data were presented through an I2C 20x4 LCD and a website.2. The system measured parameters such as water level and rainfall every 10 minutes, and the data were subsequently transmitted to a database using the NodeMCU ESP8266 via the Internet.Data were transmitted to the database every 10 minutes.The system display comprised an I2C 20x4 LCD (on-site) and a website (online).3. The water level and rainfall monitoring system at Situ Parigi reservoir, utilizing the JSN-SR04T sensor, water level float sensor, and hall effect magnetic sensor, was found to function effectively.The transmission of data to the database worked well, and the magnetic sensor and water level float sensor both had an error rate of 0%.Additionally, the average error rate for the JSN-SR04T sensor was 0.25%.4. To display the measured water level and rainfall values on the website, the data measured every 10 minutes by the sensors were sent via ESP8266 over the internet using the HTTP protocol to a MySQL database.PHP was used to connect the data from the database to the website.JavaScript was employed to provide real-time data visualisation on the website, while HTML and CSS were utilised to enhance the website aesthetics.The early warning system was established by placing the water level float sensor at a maximum water height of 180 cm.When the water level equaled or exceeded the height of the water level float sensor, the sensor sent a high signal to the ESP8266.This signal was then processed and led to the activation of the strobe light to provide an early warning.

Fig. 5 .
Fig. 5. Flowchart of the prototype water level and rainfall monitoring system.
3. The JSN-SR04T sensor measures the distance from the sensor to the Styrofoam.Next, the program calculates the water level of the reservoir based on this distance value.4. The hall effect magnetic sensor provides a LOW input when the seesaw moves on the tipping bucket.The program then calculates the rainfall value based on this input.5.If the water level in the reservoir exceeds the height of the water level float sensor, the latter will rise, activating the reed switch within it, closing the circuit, and providing a HIGH input signal to the NodeMCU ESP8266.This HIGH input will be processed by the program in the NodeMCU ESP8266, causing the relay to be set to LOW.This allows electricity to flow to the strobe light, which will activate it and provide an early warning.6. Display the water level of the reservoir and the rainfall value on the I2C 20x4 LCD. 7. The reservoir water level and rainfall data are sent through the NodeMCU ESP8266 Wi-Fi module to the MySQL database and displayed on the website.8.If the device is not turned off, the program will restart from measuring the distance from the JSN-SR04T sensor to the Styrofoam.If the device is turned off, the system program is completed.

Fig. 8 .
Fig. 8. Implementation of the website display

Fig. 11 .
Fig. 11.Data chart of the website

Figures 9 - 2 .
Figures 9-11 show that the data successfully sent to the database can be displayed on the website.The tab menus on the website are explained as follows: 1. Section a) displays the home tab page, containing information about the water level, 10-minute rainfall, and 24-hour rainfall at Situ Parigi reservoir.It also provides information about the water level at Jurang Mangu Barat and the 10-minute and 24-hour rainfall at Pondok Pucung.The background box displaying the 24-hour rainfall value for the Situ Parigi reservoir and Pondok Pucung changes colour and provides a scrolling text notification indicating the rainfall status for each location based on the respective 24-hour rainfall values.The colour changes based on the following ranges of 24-hour rainfall values:  Rainfall of 0.5-20 mm/day (green) indicates light rain. Rainfall of 20-50 mm/day (yellow) indicates moderate rain. Rainfall of 50-100 mm/day (orange) indicates heavy rain. Rainfall of 100-150 mm/day (red) indicates very heavy rain. Rainfall >150 mm/day (purple) indicates extreme rain.The date and time of the last sensor data sent to the database are also displayed, enabling technicians to quickly inspect any issues if the device is not sending data to the database.2. Section b) shows the table tab page, displaying tables for the water level and 10-minute rainfall at Situ Parigi reservoir.It also includes a table for the water level at Jurang Mangu Barat and the 10-minute rainfall at Pondok Pucung.Each displayed table contains the values from the latest 100 data points sent to the database.3. Section c) presents the graph tab page, showcasing graphs for the water level and 10-minute rainfall at Situ Parigi reservoir.It also includes graphs for the water level at Jurang Mangu Barat and the 10-minute rainfall at Pondok Pucung.Each displayed graph represents the values from the latest 100 data points sent to the database.

Fig. 12 .
Fig. 12. Data chart of the website

Table 2 .
Result of rain gauge testing