Early-flood-detection-and-avoidance-using-IoT-and-machine-learning2
Early-flood-detection-and-avoidance-using-IoT-and-machine-learning2
net/publication/383588295
Early flood detection and avoidance using IoT and machine learning
CITATIONS READS
0 215
7 authors, including:
SEE PROFILE
All content following this page was uploaded by Raed Abdulla on 22 September 2024.
View Export
Online Citation
Abstract. With the increasing frequency and severity of natural disasters, particularly floods, there is a pressing need for
advanced monitoring and prediction systems to mitigate their impact on vulnerable communities. Leveraging IoT
technologies and machine learning algorithms present promising avenues for enhancing early warning systems and
improving disaster preparedness. This research entails the design and implementation of a sensor module coupled with a
LoRa-based recovery hub operating at 915MHz. The primary objective is to transmit real-time data on water level,
humidity, rainfall intensity, and temperature to an IoT dashboard and a PostgreSQL database. This facilitates open access
to the data for both research endeavours and public consumption, particularly for weather data analysis. The water level
data collected by the system serves as input for a machine learning algorithm known as ARIMA (AutoRegressive
Integrated Moving Average) implemented on the Up-square platform. The algorithm leverages time series forecasting
techniques to predict flood occurrences in the river basin where the sensor module is deployed. By analyzing historical
trends and current conditions, the system forecasts the water level for the subsequent thirty minutes, providing insights
into potential flash flood events and establishing thresholds for near-future risk assessment. Through the integration of
sensor technology, wireless communication protocols, and advanced analytics, this project contributes to the
development of proactive flood prediction systems, enhancing public safety and disaster preparedness in vulnerable
regions. Additionally, the open-source nature of the data facilitates collaborative research efforts and empowers
communities with valuable weather-related information for informed decision-making.
INTRODUCTION
Real climate change is taking place at an unprecedented rate [1]. According to scientific evidence, extreme
weather events are becoming more likely as a result of climate change, particularly changes in rainfall [2]. Floods
are frequently caused by precipitation and river overflow, especially during a very rainy season [3]. Fluvial flood
frequency increases in urban areas during periods of heavy precipitation are mostly caused by the rapid and
unplanned urbanisation of these areas [4-6]. In Malaysia, monsoonal flooding and flash floods occur every year
during the northeast monsoon, particularly in the eastern states such as Kelantan, Terengganu, and Perak. Many
more urbanized cities like Kuala Lumpur also face this problem due to clogged and inefficient drainage systems.
Researchers have found that an estimation of the area at risk of flooding is approximately 29,800km 2 which is about
9% of the total area in Malaysia affecting almost 4.85 million people, which is approximately 22% of the total
Proceedings of 5th International Conference on Sustainable Innovation in Engineering and Technology 2023
AIP Conf. Proc. 3161, 020017-1–020017-11; https://doi.org/10.1063/5.0230082
Published under an exclusive license by AIP Publishing. 978-0-7354-5032-5/$30.00
020017-1
population in this country [7]. Internet of Things (IoT) is the foundation of data transmission between individual
devices and web application applications. The main idea is for simple everyday objects and physical components
which we generally describe in this context as ‘‘things” to gain the ability to be linked to sensors, software and other
technologies, thereby connecting and sharing data through the Internet with other devices [8–10]. IoT is a very
creative resource which plays a vital role in manufacturing, industrial, and residential systems [11]. The LoRa
system is intended to be utilised in equipment with long-life batteries where power consumption is minimal. LoRa
has been widely used in many IoT applications [12, 13]. Over the last decade, flood detection has become a hot topic
of research, and much research has been carried out on flood detection systems [14–19].
This research aims to design and develop early flood detection and avoidance using IoT and Machine learning.
The system can detect temperature, water level, and humidity based on Arduino. An IoT system was developed
using LoRa that can collect and store data on current floods and previous floods. This research aims to find a cost-
effective and efficient IoT-based flood detection and avoidance method that can be installed in remote areas require
minimal maintenance and provide twenty-four-hour flood monitoring without any further assistance provided there
is a stable network connection and power supply to the IoT device.
PROPOSED METHODOLOGY
Figure 1 shows how the data flows within the system and all the hardware that is used in the project. The Blue
arrows show the wired connection while the red arrows show the wireless connections. The system starts when both
the Arduino and the TTGO board have been powered up. The sensors will be powered up by the Arduino. The
sensor data will be periodically sent to the Arduino UNO which has been connected to an Arduino LoRa shield. This
will send the data in packets to the TTGO Lora ESP32 board. The TTGO board is coded to send the data via MQTT
to the server that has been hosted on the Upsquare. The Upsquare is also the device where the machine learning
algorithm is running. Using the PAHO MQTT python library, Upsquare waits for new sensor readings to be
published to the topics. The data is then aggregated for one hour and the average of this data is logged for each
020017-2
Figure 2 shows the sensor module connected to an Arduino UNO and the circuit diagram for the sensor system.
This system is fully self-reliant and portable and requires no internet connection. With a 10000 mAh battery the
system can work for approximately 6 hours. The three sensors blinking are the Rain sensor which detects if there is
rainfall and the rainfall intensity. The second sensor is the DHT11 sensor which detects temperature and humidity.
The third and last sensor is the water level sensor which tells the water level in the river basin. Additionally, the
915Mhz Cytron LoRa-RFM Shield attached to the Arduino UNO sends the received data in a packet to the TTGO
board.
In Fig 3, a TTGO LILYGO LORA32 915Mhz ESP32 OLED Display Board is receiving the packets of data
being sent from the Arduino LoRa shield. The Upsquare is running an MQTT server and the TTGO is publishing to
the server which is how the data is obtained by both the Upsquare and Node-red. The Upsquare is also using the data
to run a machine learning algorithm called ARIMA to give an early flood prediction which will be further discussed
in the next section.
This data is acquired from the official website of “The Department of Irrigation and Drainage, Ministry of
Environment and Water” which updates the water level in all the major river basins in Malaysia in real-time and
logs the data graphically. All of the data is open source. The river basin in Sungai Melaka was chosen for this
project. The Data was logged at a frequency of 5 minutes for the 24 hours. The threshold is 0.24 m for normal water
level, 1.20 m for alert, 1.38 m for Warning and 1.80 means the basin has flooded. Figures 4 and 5 show the trendline
for the logged 45 hours where the water level did increase to a warning level at the river basin. This data was then
tabulated so that it could be used in the machine learning dataset.
020017-3
30 August 2024 23:29:56
FIGURE 4. Rainfall at the river basin during the 24 hours (20)
020017-4
Water Normal Alert warning danger
2.7 Level
2.5
2.0
1.5
1.0
0.5
The dataset is secured inside the Heroku servers and can be accessed anytime anywhere is the world just like the
Node-red database provided the Upsquare Server is running which it will be. Figure 6 shows the secure 2-factor
authentication login portal of the Heroku website and the MySQL Heroku database. The simplest way of explaining
the relationship between Node-red, Heroku and MySQL is to describe Heroku as the OneDrive and MySQL as the
Excel sheet stored in said OneDrive which is what the data gets logged into by a PyCharm script. And Node-red is
the display for the data that has been logged.
020017-5
30 August 2024 23:29:56
FIGURE 6. Heroku login portal and Postgres SQL database
Figure 7 shows the attempt to simulate rainfall intensity and to alter the temperature and humidity in a cold
humid room. This data is then recorded on the serial monitor and on the dashboard.
020017-6
30 August 2024 23:29:56
FIGURE 7. Rainfall simulated via rainfall sensor and LoRa shield and Arduino Uno serial monitor
Figure 8 shows the serial monitor when the sensor data is relayed to the TTGO ESP32 LoRa board. This data is
then published to the MQTT server running on the Upsquare.
020017-7
30 August 2024 23:29:56
FIGURE 8. TTGO board and the upsquare and ttgo board serial monitor
Figure 9 shows the Dashboard getting updated as soon as the data is available on the MQTT server. Node-red
will update the sensor value below each of the corresponding graphs. The predicted threshold is currently not
updated as enough data is not available for ARIMA. Also, the tip of the water level sensor is placed on the water so
that a low water level average and the code will predict a “Normal” water level.
On the Upsquare runs a PyCharm code based on Linux. When this code is run it will connect to the MQTT
server running on the Upsquare. Fig.10 shows that the ARIMA code is successfully connected and subscribed to the
MQTT topics. The data is now available for ARIMA to work with. The serial monitor shows the data getting
printed. For a short demonstration, an average of 6 data is taken as soon as it is retrieved and it is used to forecast the
water level and predicted threshold for the next 30 seconds. Each data typically arrived at 6 seconds so 30 seconds
020017-8
of data is being used to predict the next 30 seconds of data. When deployed on the field to predict flash floods, the
data arrives every 5 minutes and the next 30 minutes is forecasted.
Figure 11 shows, if the data is consistently below 100 from the A0 pin, the threshold given, is normal. The
dataset will then use ARIMA to predict the “Alert” and “Warning” where the live sensor data is fed to ARIMA, and
the prediction is made. As shown in the dashboard River level significantly increased above the Normal Level and
ARIMA has forecasted the “Alert” threshold.
Figure 12. shows the graphical display of all the data collected for all of the selected p, q, d values for the
ARIMA accuracy test. This experiment aims to acquire investigate and find the p, q, d values with the lowest RMSE
thus choosing the best values for the flood prediction system. Each of the AR, I, and MA components are included
in the model as a parameter p, q, d when ARIMA was introduced. p, q, d can be assigned specific integer values and
that determines what kind of model it is. In this experiment, the most common kinds of ARIMA models are tested.
these numbers may look random, but they are mathematically equivalent to forecasting models and may even be set
to 0 which implies that they are not used at all as shown in Table 3. ARIMA model was tested with three different
parameters, the data is represented graphically.
020017-9
TABLE 3: Parameters set to zero
Parameter Notation Explanation
d=0 No stationary data
d = 0, q = 0 No moving averages or stationary data, just an autoregression on past values
p = 0, d = 0 Moving average model with no autoregression or stationary data
(a)
(c)
FIGURE 12. Data collected for all of the selected p, q, d values (a) (1,0,1) (b) (2,0,1) (c) (2,2,1)
020017-10
CONCLUSION
This research is done to find the best way to develop and enhance the IoT-based flood prediction and monitoring
systems that are currently available. the portable sensor system based on Arduino and the Arduino LoRa Shield was
deployed and the aforementioned sensor data was obtained in real-time using a complementary and specifically
specialized sensor for each parameter which was connected to the Arduino. The LoRa shield and the TTGO board
were used to relay the sensor data to the Upsquare which is running a Mosquito server. The sensor data is sent from
here to be stored on the Heroku PostgreSQL database therefore current and previous flood data along with the
sensor data gets stored on a cloud-based SQL database. ARIMA accuracy tests were done to see which model is the
best for a flood prediction model.
REFERENCES
1. S. Manandhar et al., International Journal of Disaster Risk Reduction 11, 47–59 (2015).
2. J. Kiehl, Science 331, 158–9 (2011).
3. Wilson, A. C.H. Cheong and S. Sivanesan, J. Eng. Sci. Technol.17, 203–213 (2022).
4. S. Bae, H. Chang, International Journal of Disaster Risk Reduction 37, 101186 (2019).
5. V. Sekar, A. Putra, S. Palaniyappan, S. Y. E. Noum, S. Sivanesan, and Y. L. Jiun, Wood Mater. Sci. Eng. 12, 1-
10 (2023).
6. V. Sekar, S. Palaniyappan, S. Y. E. Noum, A. Putra, S. Sivanesan, and D. D. C. V. Sheng, Wood Res. 68, 68-82
(2023).
7. M. I. Hadi et al., IOP Conf Ser Earth Environ Sci 479, 012016 (2020).
8. R. Lakshmanan et al., International Journal of Electrical and Computer Engineering 10 (2020).
9. L. M. Thakur, R. Abdulla, S. K. Selvaperumal, C. Nataraj, in 2022 3rd International Conference on Smart
Electronics and Communication (ICOSEC) (IEEE, 2022), pp. 414–21.
020017-11
View publication stats