0% found this document useful (0 votes)
16 views49 pages

Flood Monitoring and Avoidance System

The document outlines an 'IoT Early Flood Detection & Avoidance System' designed to monitor natural factors such as humidity, temperature, and water levels to predict floods and minimize damage. It utilizes various sensors connected to a microcontroller for data collection and has Wi-Fi connectivity for remote access via IoT. The system aims to provide timely alerts to the public to enhance preparedness and reduce the impacts of flooding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views49 pages

Flood Monitoring and Avoidance System

The document outlines an 'IoT Early Flood Detection & Avoidance System' designed to monitor natural factors such as humidity, temperature, and water levels to predict floods and minimize damage. It utilizes various sensors connected to a microcontroller for data collection and has Wi-Fi connectivity for remote access via IoT. The system aims to provide timely alerts to the public to enhance preparedness and reduce the impacts of flooding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 49

ABSTRACT

“IoT Early Flood Detection & Avoidance System” is an intelligent system which keeps close watch

over various natural factors to predict a flood, so we can embrace ourselves for caution, to minimize the

damage caused by the flood. Natural disasters like floods can be devastating leading to property damage and

loss of lives. To eliminate or lessen the impacts of the flood, the system uses various natural factors to detect

floods. The system has a Wi-Fi connectivity; thus, it’s collected data can be accessed from anywhere quite

easily using IoT.

To detect a flood the system observes various natural factors, which includes humidity, temperature, water

level and flow level. To collect data of mentioned natural factors the system consists of different sensors

which collect data for individual parameters. For detecting changes in humidity and temperature the system

has a DHT11 Digital Temperature Humidity Sensor. It is an advanced sensor module with consists of

resistive humidity and temperature detection components. The water level is always under observation by a

float sensor, which works by opening and closing circuits (dry contacts) as water levels rise and fall. It

normally rests in the closed position, meaning the circuit is incomplete and no electricity is passing through

the wires yet. Once the water level drops below a predetermined point, the circuit completes itself and sends

electricity through the completed circuit to trigger an alarm. The flow sensor on the system keeps eye on the

flow of water.

The water flow sensor consists of a plastic valve body, a water rotor, and a hall-effect sensor. When water

flows through the rotor, the rotor rolls. Its speed changes with different rate of flow. All the sensors are

connected to Microcontroller, which processes and saves data. The system has a Wi-Fi feature, which is

useful to access the system and its data over IoT.


TABLE OF CONTENTS
CHAPTTER 1: INTRODUCTION
1.1 INTRODUCTION 01
1.2 PROBLEM BACKGROUND 02
1.3 PROBLEM STATEMENT 02
1.4 LITERATURE REVIEW 03

CHAPTER 2: PROJECT MECHANISM


2.1 BLOCK DIAGRAM AND ITS 05
DESCRIPTION
2.2 SCHEMATIC DIAGRAM 07
2.3 LOGIC DIAGRAM 08
2.4 WORKING PRINCIPLE 09

CHAPTER 3: HARDWARE REQUIREMENTS


3.1 ESP8266 NODEMCU 10
3.2 JUMPER WIRES 17
3.3 FLOAT SENSOR 18
3.4 HUMIDITY SENSOR 19
3.5 TEMPERATURE SENSOR 20
3.6 BUZZER 22
3.7 LED 23
3.8 LCD DISPLAY 23
3.9 ULTRASONIC SENSOR 25

CHAPTER 4: SOFTWARE REQUREMENTS


4.1 ARDUINO IDE 26
4.2 THINGSPEAK 27

CHAPTER 5: RESULTS AND DISCUSSION 30

CHAPTER 6: ADVANTAGES AND CHALLENGES


6.1 ADVANTAGES 33
6.2 CHALLENGES 34
CHAPTER 7: CONCLUSION AND FUTURE SCOPE
CONCLUSION 35
FUTURE SCOPE 35

CHAPTER 8: REFERENCES 36

CHAPTER 9 APPENDIX 37
LIST OF FIGURES

Fig 2.1 Block Diagram 05

Fig 2.2 Schematic Diagram 07

Fig 2.3 Logic Diagram 08

Fig 3.1 NodeMCU Development Board/kit v0.9 (version1) 10

Fig 3.2 NodeMCU Development Board/kit v0.9 (version2) 10

Fig 3.3 Pin Out of ESP8266 11

Fig 3.4 NodeMCU GPIO Pins 12

Fig 3.5 NodeMCU Devkit GPIOs 13

Fig 3.6 Jumper Wires 17

Fig 3.7 Switch Symbol 18

Fig 3.8 Construction of Float Sensor 18

Fig 3.9 Humidity Sensor 20

Fig 3.10 Temperature Sensor 21

Fig 3.11 Buzzer 22

Fig 3.12 LED 23

Fig 3.13 LCD Display 24

Fig 3.14 Ultrasonic Sensor Diagram 25

Fig 4.1 Arduino IDE Software 27

Fig 4.2 Thingspeak Overview 28

Fig 4.3 Thingspeak API key 29

Fig 5.1 Project Set up 30

Fig 5.2 Water safety results 1 31

Fig 5.3 Flood alert indication 31

Fig 5.4 Flood detection records 32


IOT Flood Monitoring and Avoidance 1

CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION

In recent years, flooding has become one of the major natural disasters in India. India is ranked among
the top 10 countries most threatened by floods in the world. Floods have various impacts, with material,
human, economic, and social losses being some of the most significant consequences. Heavy rainfall is one
of the key factors contributing to flash floods. To reduce human and economic losses, certain preventive
measures need to be followed. One of the most important and preliminary steps is to alert the public before a
disaster occurs.

Although some areas have early flood alert systems, many of these systems are not highly efficient, as
they typically only send information to a limited number of organizations within restricted areas. As a result,
during a flood, it takes longer to pass on the message to people living in nearby areas, and they are often
unable to save their belongings as the water rises quickly.

While flooding cannot always be prevented, early detection through continuous monitoring can help
reduce the losses faced by society. Several projects are focused on improving early flood monitoring
systems. One such project involves using a flood observatory system to indicate water levels and alert people
in remote areas. The observatory system communicates with the monitoring system via a GSM modem to
send information about the flow rate and receive commands.

Another approach uses flood detection systems that estimate real-time water levels using wireless sensor
networks. These systems provide data through a GSM modem and send notifications via social media
platforms such as Facebook and Twitter. Additionally, real-time flood monitoring systems using wireless
sensor networks have been introduced to monitor river conditions and provide continuous, up-to-date
information.

There are different types of floods:

1. Coastal Flooding: Coastal flooding occurs when the sea level rises, leading to inundation of low-
lying seaside areas. These areas may have natural or man-made defenses, such as sand dunes or
barriers, to protect against the water.
2. River Flooding: River flooding is the most common type of flooding near coastal areas, often caused
by heavy rainfall. When rivers overflow their banks, they inundate surrounding areas.
IOT Flood Monitoring and Avoidance 2

3. Flash Flooding: Flash flooding happens when the ground is unable to absorb rainwater as quickly as
it falls, leading to rapid water accumulation and flooding.
4. Urban Flooding: Urban flooding occurs due to inadequate drainage systems in urban areas, which
can lead to water accumulation and flooding after heavy rainfall.
5. Ponding: Ponding refers to the accumulation of water in relatively flat areas, often occurring when
the ground is unable to drain excess water efficiently.

Although flooding cannot always be prevented, the damage it causes can be minimized by detecting
floods early. A system that continuously monitors water flow can help achieve this. The system uses a water
level indicator, to measure the water level. This data is displayed on an application. If the water level exceeds
the maximum threshold, the alert system is triggered.

1.2 PROBLEM BACKGROUND


Floods have caused significant material, financial, and sometimes fatal losses in recent years. The
population is often unaware of the potential for floods due to the lack of an early warning system. In this
study, the researcher developed a system for automatically detecting floods that tracks water levels and
issues alerts before a flood occurs. To provide real-time data and determine the water level at a specific
location, this monitoring system uses water level sensors based on IoT technology. This online-connected
device displays current water levels and is integrated with a mobile app to provide advance flood warnings.

1.3 PROBLEM STATEMENT


Floods are highly destructive events that can devastate large cities and residential areas. They often cause
significant property damage and even result in loss of life. Flooding is a natural disaster in which dry land is
suddenly inundated with water. Some floods occur unexpectedly and with little warning. When they strike,
the water can carry and destroy buildings, vehicles, and dangerous debris like sharp wooden objects, which
can pose a risk to people's safety. Moreover, many communities are unaware of flood risks due to the lack of
a proper warning system.

To address this issue, we aim to develop a solution that will benefit the community, such as an early flood
warning system using IoT.

During floods, an intelligent IoT-based flood monitoring system plays a crucial role. A highly effective
system will help both the government and society manage flood situations and assist victims, thereby
minimizing the disaster's impact. It is essential to make this system accessible, easy to use, cost-effective,
and, most importantly, capable of providing timely warnings to the public. The proposed system will feature
IOT Flood Monitoring and Avoidance 3

a simple monitoring interface, along with sufficient data on current flood levels and forecasts of short-term
water levels.

1.4 LITERATURE REVIEW

Do et al. have proposed a flood cautioning structure that has been examined and created. The structure
contains an early flood forewarning station which is charged by solar power. The flood advised station is
equipped with the water level sensor. The data, which is gotten from sensors, are stored and transmitted to
the observing focus by means of GPRS convention. The observing focus' capacity is to gather, research data
from the stations and send results to the notification focus where alerts can be created to the considered
nearby areas and notification is also sent through SMS from the client server. A website page was made to
demonstrate the water level, and the foreseen information for persistent activity. The issue with this
framework is setting up the conditions for testing in the lab takes a while to have the test results as a general
rule [1].

Sakib et al. have proposed a neuro-fluffy controller-based flood observing framework utilizing remote
sensor organize. The framework utilizes IEEE 802.15.4 convention as a conveyed hub to gather the sensor
data, for example, water level information from the waterway, precipitation, and wind speed information
from a chosen site. In order to endorse the flood checking structure, Chadpur, a flood slanted area of
Bangladesh, has been considered as a picked site. The sensors' information is sent to the disseminated alarm
focus from the main control unit by using Zigbee module. Sensor data is researched by the neuro-fluffy
controller. The sensor data are processed using Raspberry Pi controller for warning condition. The remote
sensor is included for sending detected data to location instantaneously. It is incompetent to control moving
procedures with time delays and change in the MF can require a change in the rules. And it undergoes a
multi-parameter optimization problem [2].

Mousa et al. have planned a new detecting gadget that can consistently screen urban flash floods and
traffic blockage for flood watching. This recognizing gadget relies upon the mix of ultrasonic distance
measurement for detecting temperature, using a blend of L1-regularized recreation. Second, looking at
counts that have been executed on a remote sensor platform. And artificial neural systems to process
estimation data. The results demonstrate that water levels can be constantly assessed with reduced error, and
that the pre-preparing and AI plans can continue running logically on starting at now open remote sensor
stages. In the present case, ANNs show extraordinary mix properties anyway it enables us to use a low
number of neurons and parameters, making it suitable for low power installed frameworks applications [3].
IOT Flood Monitoring and Avoidance 4

Khalaf et al. have proposed a portrayal of an alarm making structure for flood identification with an
accentuation on choosing momentum water level using sensors. The framework then gives a cautioning
message about water level using Global Communication and Mobile System modem to explicit individuals.
Also, the Short Message Service is provided for the framework rapidly exchanges and conveys information
through the web-based open framework. AI calculations were directed to play out the classification process.
The tests were done to characterize flood information from typical and in-danger condition in which
arrangement accuracy was accomplished utilizing Random Forest algorithm. The calculation experiences
complexity and is tedious to develop compared to decision trees [4].

Dashpute et al. have proposed a flood detection system to screen rising water in local locations. Utilizing
ultrasonic sensors, they made a flood level detecting device which is connected to Node MCU controller to
process the sensor's analog signal into a usable advanced estimation of separation. The client can get real-
time data on observing overflowed streets over SMS-based administration. The level of the flood will be
partitioned into four. The flood sensor and microcontroller will be controlled by solar-based energy to assist
constant activity of water flood height identification and system information transmission. The Arduino
Flood Detector System is created to monitor flood that will support drivers or street users to stay away from
issues when a flood happens. The issue identified in this system is that it will not predict the values or it
takes previous for classification by using any machine learning algorithm [5].
IOT Flood Monitoring and Avoidance 5

CHAPTER 2
PROJECT MECHANISM

2.1 BLOCK DIAGRAM AND ITS DESCRIPTION


IOT Flood Monitoring and Avoidance 6

Ultrasonic
Sensor

Float Sensor

THINGSPEAK

Fig 2.1 Block Diagram


Figure 2.1 illustrates the block diagram of the flood monitoring system. This project uses water level sensor
to measure the water level of a river. To send alerts during flood events, we utilize the IFTTT web server.
Additionally, the monitoring is managed via an external web server called Thingspeak.

Temperature Sensor:
IOT Flood Monitoring and Avoidance 7

A temperature sensor detects the hotness or coldness of the environment. The temperature is measured either
through direct contact with the surroundings or indirectly.

Humidity Sensor:

A humidity sensor (also known as a hygrometer) detects, measures, and reports both the moisture and air
temperature in the environment. The ratio of moisture in the air to the maximum moisture the air can hold at
a specific temperature is called relative humidity. This becomes an important factor when assessing comfort
levels. Humidity sensors work by detecting changes that affect electrical currents or temperature in the air.

Water Level Sensor:

Water Level sensors are used to measure the water level. These sensors can detect the level of various
substances such as liquids (water, oil), slurries, and even solids that are capable of flowing.

LCD Display:

An LCD (Liquid Crystal Display) screen is an electronic display module widely used in various devices and
circuits. The 16x2 LCD display is a basic module, displaying 16 characters per line across two lines. Each
character is formed in a 5x7 pixel matrix. The 16x2 intelligent alphanumeric dot matrix display can show up
to 224 different characters and symbols. The LCD has two registers: Command and Data. The display
contrast can be adjusted using a potentiometer connected to the VEE pin.

Microcontroller Section:

This section serves as the control unit of the entire project. It consists of a microcontroller along with
associated components. The microcontroller is the heart of the system, as it monitors the sensors and updates
the web through a WiFi module.

Thingspeak:

Thingspeak is an open-source IoT application and API that allows for reading and writing data from various
devices. It uses the HTTP protocol to communicate. In Thingspeak, graphs and numerical displays are used
to monitor the data that is updated from the sensors via the internet. Thingspeak offers several advantages,
including the ability to trigger certain actions if specific conditions are met.

2.2 SCHEMATIC DIAGRAM


IOT Flood Monitoring and Avoidance 8

Fig 2.2 Schematic Diagram


IOT Flood Monitoring and Avoidance 9

2.3 LOGIC DIAGRAM

Fig 2.3 Logic diagram


IOT Flood Monitoring and Avoidance 10

2.4 WORKING PRINCIPAL

The Flood Monitoring and Avoidance System operates using an ESP8266 microcontroller to
collect and process data from various environmental sensors, including a float sensor, temperature sensor,
and humidity sensor. These sensors continuously monitor the water level in the surrounding area, as well as
the temperature and humidity of the environment. The float sensor detects rising water, while the
temperature and humidity sensors provide data about weather conditions that may indicate potential
flooding.

The ESP8266 microcontroller reads the sensor values at regular intervals and compares them to predefined
thresholds. If any of the values exceed these thresholds for example, if the water level rises above a safe limit
or if the temperature and humidity reach levels that suggest heavy rainfall or flooding the system processes
this information to trigger an alert.

Once the system detects dangerous conditions, it activates a buzzer to provide alert to people, warning them
of the potential flood. Simultaneously, the ESP8266 transmits the collected data to the ThingSpeak cloud
platform via Wi-Fi. This allows users to remotely monitor the situation through the ThingSpeak app or
website, providing real-time data on the water level, temperature, and humidity.

The system enables continuous monitoring of flood-prone areas, and users can view trends and track changes
in environmental conditions over time. This combined system of local and remote alerts helps people stay
safe by providing early warnings and enabling proactive flood avoidance.

.
IOT Flood Monitoring and Avoidance 11

CHAPTER 3
HARDWARE REQUIREMENTS

3.1 ESP8266 NODEMCU

Introduction
NodeMCU is an open source LUA based firmware developed for the ESP8266 wifi chip. By
exploring functionality with the ESP8266 chip, NodeMCU firmware comes with the ESP8266 Development
board/kit i.e. NodeMCU Development board.

Fig 3.1 NodeMCU Development Board/kit v0.9 (Version1)


Since NodeMCU is an open-source platform, its hardware design is open for edit/modify/build.
NodeMCU Dev Kit/board consist of ESP8266 wifi enabled chip. The ESP8266 is a low-cost Wi-
Fi chip developed by Espressif Systems with TCP/IP protocol.
IOT Flood Monitoring and Avoidance 12

Fig 3.2 NodeMCU Development Board/kit v1.0 (Version2)


There is Version2 (V2) available for NodeMCU Dev Kit i.e. NodeMCU Development Board v1.0
(Version2), which usually comes in black colored PCB.
NodeMCU Dev Kit has Arduino like Analog (i.e. A0) and Digital (D0-D8) pins on its board.
It supports serial communication protocols i.e. UART, SPI, I2C, etc.
Using such serial protocols we can connect it with serial devices like I2C enabled LCD display,
Magnetometer HMC5883, MPU-6050 Gyro meter + Accelerometer, RTC chips, GPS modules, touch screen
displays, SD cards, etc.

Pin out of ESP8266

Fig 3.3 Pin out of ESP8266


IOT Flood Monitoring and Avoidance 13

Nodemcu GPIO pins

Fig 3.4 Nodemcu GPIO Pins

General-purpose input/output (GPIO) is a pin on an IC (Integrated Circuit). It can be either an input


pin or output pin, whose behavior can be controlled at the run time.

NodeMCU Development kit provides access to these GPIOs of ESP8266. The only thing to take care
of is that NodeMCU Devkit pins are numbered differently than internal GPIO notations of ESP8266 as
shown in the below figure and table. For example, the D0 pin on the NodeMCU Devkit is mapped to the
internal GPIO pin 16 of ESP8266.
IOT Flood Monitoring and Avoidance 14

Fig 3.5 NodeMCU DevKit GPIOs

The below table gives NodeMCU Dev Kit IO pins and ESP8266 internal GPIO pins mapping

Pin Names on NodeMCU Development Kit ESP8266 Internal GPIO Pin number

D0 GPIO16

D1 GPIO5

D2 GPIO4

D3 GPIO0

D4 GPIO2

D5 GPIO14

D6 GPIO12

D7 GPIO13
IOT Flood Monitoring and Avoidance 15

Pin Names on NodeMCU Development Kit ESP8266 Internal GPIO Pin number

D8 GPIO15

D9/RX GPIO3

D10/TX GPIO1

D11/SD2 GPIO9

D12/SD3 GPIO10

The GPIO’s shown in the blue box (1, 3, 9, 10) are not commonly used for GPIO purpose on Dev Kit

ESP8266 is a system on a chip (SoC) design with components like the processor chip. The processor
has around 16 GPIO lines, some of which are used internally to interface with other components of the SoC,
like flash memory.

Since several lines are used internally within the ESP8266 SoC, we have about 11 GPIO pins
remaining for GPIO purposes.

2 pins out of 11 are generally reserved for RX and TX in order to communicate with a host PC from
which compiled object code is downloaded.

Hence finally, this leaves just 9 general-purpose I/O pins i.e. D0 to D8.

As shown in the above figure of NodeMCU Dev Kit. We can see RX, TX, SD2, SD3 pins are not
commonly used as GPIOs since they are used for other internal processes. But we can try with SD3 (D12)
pin which mostly likes to respond for GPIO/PWM/interrupt like functions.

Note that the D0/GPIO16 pin can be only used as GPIO read/write, no special functions are
supported on it.

Note
Some of the GPIO pins are used while booting, so pulling this pin HIGH or LOW can prevent NODEMCU
from booting
 GPIO0: It oscillates and stabilizes HIGH after ~100ms. Boot Failure if pulled LOW
 GPIO1: LOW for ~50ms, then HIGH, Boot Failure if Pulled LOW.
 GPIO2: It oscillates and stabilize HIGH after ~100ms, Boot Failure if Pulled LOW.
 GPIO3: LOW for ~50ms, then HIGH.
IOT Flood Monitoring and Avoidance 16

 GPIO9: Pin is HIGH at Boot.


 GPIO10: Pin is HIGH at Boot.
 GPIO15: LOW, Boot failure if Pulled HIGH
 GPIO16: HIGH during Boot and Falls to ~1Volt.

GPIO Cautions:
 If the GPIO pin defines as an OUTPUT LOW then don’t connect this pin to VCC, it will get short
circuit, and large current flow will damage your controller or GPIO pin.

 If the GPIO Pin defines as an OUTPUT HIGH then don’t connect this pin to Ground, it will draw
large current which will damage your controller or GPIO pin.

 For switch connection always use a pull-up or pull-down (based on your coding logic). Always use
pull UP/pull down resistor inside the microcontroller or connect an external resistor.
 Don’t connect the direct VCC pin to the GPIO pins, otherwise it will short the power supply when
you press the switch.
IOT Flood Monitoring and Avoidance 17

 Kindly check following scenarios:

 While interfacing the led always connect a series resistor to limit the current, otherwise LED will
burn.
IOT Flood Monitoring and Avoidance 18

3.2 JUMPER WIRES

Jumper wires are simply wires that have connector pins at each end, allowing them to be used to
connect two points to each other without soldering. Jumper wires are typically used with breadboards and
other prototyping tools to make it easy to change a circuit as needed. Fairly simple. In fact, it doesn’t get
much more basic than jumper wires.

Fig 3.6 Jumper wires

Though jumper wires come in a variety of colors, the colors don’t actually mean anything. This
means that a red jumper wire is technically the same as a black one. But the colors can be used to your
advantage to differentiate between types of connections, such as ground or power.

Jumper wires typically come in three versions: male-to-male, male-to-female and female-to-female.
The difference between each is in the end point of the wire. Male ends have a pin protruding and can plug
into things, while female ends do not and are used to plug things into. Male-to-male jumper wires are the
most common and what you likely will use most often. When connecting two ports on a breadboard, a male-
to-male wire is what you will need.
IOT Flood Monitoring and Avoidance 19

3.3 FLOAT SENSOR

A float switch definition is: It is a type of contact liquid level sensor which uses a float to operate a
switch within a tank. This switch is also known as a level sensor. These switches play a key role in
controlling other devices like pumps & alarms when a level of liquid increases or drops to a particular point.
The float switch symbol is shown below. These switches range from small sizes to large sizes. Float switches
come in two different styles: magnetic (Electromagnetic) and Mechanical float type.

Fig 3.7 Switch Symbol

Construction of Float Switch


The construction of this electromagnetic switch can be done with a stem, reed switch, and permanent
magnet.

Fig 3.8 Construction of Float Sensor

Stem
The stem of the switch is a plastic part that connects the switch to the keycap directly. The stem can be
plastic or metal depending on the requirement.
IOT Flood Monitoring and Avoidance 20

Reed Switch
The reed switch is hermetically sealed within a stem of the float switch. These are most frequently
designed with stainless steel or plastic. The water float covers a sealed magnet to move up & down the stem
length when a level of fluid increases and decreases.

Permanent Magnet
A permanent magnet in a switch moves consistently with the level of fluid on a guide tube. A reed
contact is connected in the guide tube which is energized throughout the non-magnetic walls of the float by
the float magnet approach.

Float Switch Working Principle

The working of a float switch is based on the principle of buoyancy i.e., when there is no liquid in
contact with the float, it floats on top of the liquid surface and triggers an alarm signal, when there is enough
liquid in contact with float, it submerges itself into liquid and stops alarming. The principle of operation is
the same for the style of float switches but works depending on their construction of it. Let’s see how both
works.

3.4 HUMIDITY SENSOR

Humidity sensors are devices used to measure humidity levels in the air. Relative humidity sensors
also measure air temperature, but they are not effective for temperatures above 100 degrees Celsius.
Humidity sensors, often referred to as hygrometers, are low-cost, sensitive electronic devices designed to
measure air humidity. Humidity can be quantified as relative humidity, absolute humidity, or specific
humidity. Based on the type of humidity they measure; these sensors are classified as Relative Humidity
sensors or Absolute Humidity sensors.

Furthermore, humidity sensors can be categorized according to the method they use to measure
humidity. These include Capacitive Humidity Sensors, Resistive Humidity Sensors, and Thermal
Conductivity Humidity Sensors.

When selecting a humidity sensor, key factors to consider include accuracy, linearity, reliability,
repeatability, and response time.
IOT Flood Monitoring and Avoidance 21

Fig 3.9 Humidity Sensor

Working Principle of Humidity Sensors


Relative humidity sensors typically contain a humidity sensing element and a thermistor to measure
temperature. In the case of a capacitive sensor, the sensing element is a capacitor. The relative humidity
values are calculated by measuring changes in the electrical permittivity of the dielectric material within the
capacitor.
For resistive sensors, low-resistivity materials are used, and these materials are placed on top of two
electrodes. The change in the resistivity of the material is used to determine the change in humidity.
Examples of resistive materials used include salt, solid electrolytes, and conductive polymers. Thermal
conductivity sensors, on the other hand, measure absolute humidity values.

3.5 TEMPERATURE SENSOR

The DTH11 is a 1-wire programmable temperature sensor from Maxim Integrated. It is commonly
used to measure temperature in harsh environments such as chemical solutions, mines, or soil. The sensor is
ruggedly constructed and can also be purchased with a waterproof option, which simplifies the mounting
process. The sensor has a wide temperature measurement range from -55°C to +125°C, with a reasonable
accuracy of ±0.5°C. Each DTH11 sensor has a unique address and only requires a single pin on the
microcontroller to transfer data, making it an excellent choice for measuring temperature at multiple points
without consuming many digital pins on the microcontroller.

Pin Configuration

No. Pin Name Description

1 Ground Connects to the ground of the circuit


IOT Flood Monitoring and Avoidance 22

No. Pin Name Description

2 Vcc Powers the sensor, can be 3.3V or 5V

3 Data Outputs the temperature value, which can be read using the 1-wire method

Fig 3.10 Temperature Sensor

DTH11 Sensor Specifications

 Type: Programmable Digital Temperature Sensor

 Communication: 1-Wire protocol

 Operating Voltage: 3V to 5V

 Temperature Range: -55°C to +125°C

 Accuracy: ±0.5°C

 Output Resolution: Programmable from 9-bit to 12-bit

 Unique 64-bit Address: Enables multiplexing of multiple sensors

 Conversion Time: 750ms at 12-bit resolution

 Programmable Alarm Options: Allows setting temperature thresholds

 Available Forms: To-92, SOP, and waterproof options


IOT Flood Monitoring and Avoidance 23

3.6 BUZZER

An audio signaling device like a beeper or buzzer may be electromechanical or piezoelectric or


mechanical type. The main function of this is to convert the signal from audio to sound. Generally, it is
powered through DC voltage and used in timers, alarm devices, printers, alarms, computers, etc. Based on
the various designs, it can generate different sounds like alarm, music, bell & siren.

Fig 3.11 Buzzer


The pin configuration of the buzzer is shown in fig 3.11. It includes two pins namely positive and
negative. The positive terminal of this is represented with the ‘+’ symbol or a longer terminal. This terminal
is powered through 6Volts whereas the negative terminal is represented with the ‘- ‘symbol or short terminal
and it is connected to the GND terminal.

Specifications

The specifications of the buzzer include the following.

 Color is black

 The frequency range is 3,300Hz

 Operating Temperature ranges from – 20° C to +60°C

 Operating voltage ranges from 3V to 24V DC

 The sound pressure level is 85dBA or 10cm

 The supply current is below 15mA


IOT Flood Monitoring and Avoidance 24

3.7 LED

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a pn-junction diode, which
emits light when activated. When a suitable voltage is applied to the leads, electrons can recombine with
electron holes within the device, releasing energy in the form of photons. This effect is called
electroluminescence, and the colour of the light (corresponding to the energy of the photon) is determined
by the energy band gap of the semiconductor.

An LED is often small in area (less than 1mm) and integrated optical components may beed to
shape its radiation pattern.

Fig 3.12 LED

3.8 LCD DISPLAY


LCD (Liquid Crystal Display) is a type of flat panel display which uses liquid crystals in its primary
form of operation. LEDs have a large and varying set of use cases for consumers and businesses, as they can
be commonly found in smartphones, televisions, computer monitors and instrument panels.

LCDs were a big leap in terms of the technology they replaced, which include light-emitting diode
(LED) and gas-plasma displays. LCDs allowed displays to be much thinner than cathode ray tube (CRT)
technology. LCDs consume much less power than LED and gas-display displays because they work on the
principle of blocking light rather than emitting it. Where an LED emits light, the liquid crystals in an LCD
IOT Flood Monitoring and Avoidance 25

produces an image using a backlight. As LCDs have replaced older display technologies, LCDs have begun
being replaced by new display technologies such as OLEDs.

Fig 3.13 LCD Display


Working of LCD

A display is made up of millions of pixels. The quality of a display commonly refers to the number of
pixels; for example, a 4K display is made up of 3840 x2160 or 4096x2160 pixels. A pixel is made up of three
subpixels; a red, blue and green—commonly called RGB. When the subpixels in a pixel change color
combination, a different color can be produced. With all the pixels on a display working together, the display
can make millions of different colors. When the pixels are rapidly switched on and off, a picture is created.

The way a pixel is controlled is different in each type of display; CRT, LED, LCD and newer types of
displays all control pixels differently. In short, LCDs are lit by a backlight, and pixels are switched on and off
electronically while using liquid crystals to rotate polarized light. A polarizing glass filter is placed in front
and behind all the pixels, the front filter is placed at 90 degrees. In between both filters are the liquid crystals,
which can be electronically switched on and off

LCDs are made with either a passive matrix or an active-matrix display grid. The active-matrix LCD
is also known as a thin film transistor (TFT) display. The passive matrix LCD has a grid of conductors with
pixels located at each intersection in the grid. A current is sent across two conductors on the grid to control
the light for any pixel. An active matrix has a transistor located at each pixel intersection, requiring less
current to control the luminance of a pixel. For this reason, the current in an active-matrix display can be
switched on and off more frequently, improving the screen refresh time. Some passive matrix LCDs have
dual scanning, meaning that they scan the grid twice with current in the same time that it took for one scan in
the original technology. However, active matrix is still a superior technology out of the two.
IOT Flood Monitoring and Avoidance 26

3.9 ULTRASONIC SENSOR

An ultrasonic sensor is an electronic device that measures the distance of a target object by emitting
ultrasonic sound waves and converts the reflected sound into an electrical signal. Ultrasonic waves travel
faster than the speed of audible sound (i.e. the sound that humans can hear). Ultrasonic sensors have two
main components: the transmitter (which emits the sound using piezoelectric crystals) and the receiver
(which encounters the sound after it has travelled to and from the target).

In order to calculate the distance between the sensor and the object, the sensor measures the time it takes
between the emission of the sound by the transmitter to its contact with the receiver. The formula for this
calculation is D = ½ T x C (where D is the distance, T is the time, and C is the speed of sound ~ 343
meters/second). For example, if a scientist set up an ultrasonic sensor aimed at a box and it took 0.025
seconds for the sound to bounce back, the distance between the ultrasonic sensor and the box would be:

D = 0.5 x 0.025 x 343

or about 4.2875 meters.

Fig 3.14 Ultrasonic Sensor Diagram


IOT Flood Monitoring and Avoidance 27

CHAPTER 4
SOWFWARE REQUIREMENTS
4.1 ARDUINO IDE
IDE stands for Integrated Development Environment‖: it is an official software introduced by
Arduino.cc, that is mainly used for editing, compiling and uploading the code in the Arduino Device. Almost
all Arduino modules are compatible with this software that is an open source and is readily available to
install and start compiling the code on the go.

Arduino Sketch

Arduino sketch is the name that Arduino uses for a program. It's the unit of code that is uploaded to,
and run on an Arduino board. A basic Arduino sketch consists of two functions:

setup() loop()

Writing Sketch

Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the
text editor and are saved with the file extension.ino. The editor has features for cutting/pasting and for
searching/replacing text. The message area gives feedback while saving and exporting and also displays
errors. The console displays text output by the Arduino Software (IDE), including complete error messages
and other information. The bottom righthand corner of the window displays the configured board and serial
port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open
the serial monitor.

The two required parts or functions enclose blocks of statements are: void setup()

statements;

void loop()

Statements;

}
IOT Flood Monitoring and Avoidance 28

Where setup() is the preparation, while loop() is the execution. Both functions are required for the
program to work. The setup function should follow the declaration of any variable at the very beginning of
the program. It is the first function to run in the program, it runs only once and is used to set pin Mode or
initialize serial communication. The loop function follows next and includes the code to be executed
continuously - reading inputs, triggering outputs, etc. This function is the core of all Arduino program and
does the bulk of the work

Fig 4.1 Arduino IDE Software

The Arduino Integrated Development or Arduino software contains a text editor for writing code. A
message area, a text console, a tool bar with buttons for common functions and a series of menus. It connects
to Arduino hardware to upload programs and communicate with them.

4.2 THINGSPEAK
ThingSpeak is a platform that offers a variety of services specifically designed for creating IoT
applications. It enables real-time data collection, visualizes the data through charts, and provides the ability
to create plugins and apps for interaction with web services, social networks, and other APIs. Each of these
features will be explored in detail below.
IOT Flood Monitoring and Avoidance 29

At the heart of ThingSpeak is the ‘ThingSpeak Channel’. A channel stores the data sent to ThingSpeak and
consists of the following components:

 8 fields for storing data of any type – These fields can store data from sensors or embedded devices.

 3 location fields – These can store latitude, longitude, and elevation, which are particularly useful for
tracking a moving device.

 1 status field – A brief message describing the data stored in the channel.

To use ThingSpeak, we need to sign up and create a channel. Once a channel is created, we can send
data, let ThingSpeak process it, and retrieve it as needed. Let's begin by signing up and setting up a channel
on ThingSpeak.

Fig 4.2 Thingspeak Overview

ThingSpeak Apps

ThingSpeak offers a range of apps that simplify integration with web services, social networks, and other
APIs. Below are some of the apps provided by ThingSpeak:

 ThingTweet – This app allows you to post messages to Twitter through ThingSpeak. Essentially, it
acts as a Twitter proxy, redirecting your posts to Twitter.

 ThingHTTP – This app enables you to connect to web services and supports HTTP methods such as
GET, PUT, POST, and DELETE.
IOT Flood Monitoring and Avoidance 30

 TweetControl – With this app, you can monitor your Twitter feeds for a specific keyword and
process requests when that keyword is found. Once detected, you can use ThingHTTP to connect to a
web service or trigger a specific action.

 React – This app lets you send a tweet or trigger a ThingHTTP request when a channel meets a
specified condition.

 TalkBack – Use this app to queue up commands and allow a device to act on these queued
commands.

 TimeControl – This app allows you to schedule a ThingTweet, ThingHTTP, or TalkBack action at a
specific time in the future or at a specified time on certain days of the week.

Fig 4.3 Thingspeak API key


IOT Flood Monitoring and Avoidance 31

CHAPTER 5
RESULTS AND DISCUSSIONS

Fig 5.1 Project Set up


Integrating features of all the hardware components used have been developed in it. Presence of
every module has been reasoned out and placed carefully, thus contributing to the best working of the unit.
Thus, the project has been successfully designed and tested. It is performing its operation successfully. The
results or records of the testing are represented in form of graphs and are observed in the thingspeak
application. The results are as follows:
IOT Flood Monitoring and Avoidance 32

Fig 5.2 Water safety results 1


The fig 5.2 shows the field chart of the flood safety level. As the numbers are high the cause of flood is low
and it is safe and field 1 chart shows the temperature levels.

Fig 5.3 Flood alert indication


IOT Flood Monitoring and Avoidance 33

In fig 5.3 we can see that as the water level is safe it indicates green color in the app which means that there
will be no occurrence of floods.

Fig 5.4 Flood detection records


The fig 5.4 shows the recorded values of water level, temperature and humidity. This will help determine
whether the floods will occur or not.
IOT Flood Monitoring and Avoidance 34

CHAPTER 6
ADVANTAGES AND CHALLENGES

6.1 ADVANTAGES
1. Early Detection and Prevention:
 The system provides real-time monitoring of water levels, temperature, and humidity, allowing for
early detection of potential flood risks. This can help in preventing or mitigating the impacts of floods
by alerting authorities or individuals ahead of time.

2. Cost-Effective:

 Using affordable components such as NodeMCU, water level sensors, and other environmental
sensors, this system is relatively inexpensive to deploy compared to traditional flood monitoring
systems. It makes flood monitoring accessible to a wider range of communities and regions.

3. Real-Time Monitoring:

 The system offers continuous real-time data collection and analysis, ensuring that any sudden
changes in environmental conditions (water level rise, temperature fluctuation, or humidity change)
are immediately detected and responded to, potentially saving lives and property.

4. Remote Data Access:

 By integrating ThinkSpeak, the data can be remotely accessed from anywhere via the internet. This
makes it easier for authorities or users to monitor flood-prone areas without having to be physically
present at the site, enhancing the efficiency of monitoring efforts.

5. Alert Mechanism:

 The integration of a buzzer in the system provides a local audible alarm whenever the water level or
other environmental factors exceed a set threshold, alerting individuals in the area to evacuate or take
action immediately.

6. Scalability:

 The system is scalable, meaning more sensors or additional units can be easily added to cover larger
areas or more locations. This flexibility allows for a broader coverage of flood-prone regions without
significant infrastructure changes.
IOT Flood Monitoring and Avoidance 35

7. Low Power Consumption:

 The NodeMCU microcontroller is energy-efficient, enabling continuous operation of the monitoring


system for extended periods with minimal power consumption, which is ideal for areas without
constant access to electricity.

8. Data Analysis and Trends:

 With ThinkSpeak integration, the system can not only provide real-time monitoring but also store
historical data, which can be analyzed to identify trends, seasonal patterns, and correlations between
weather variables and flooding events. This historical data is valuable for making informed decisions
about flood prevention measures.

6.2 CHALLENGES

1. Accuracy of Sensors:

 The reliability and accuracy of water level, temperature, and humidity sensors can vary depending on
environmental conditions and sensor calibration. Inaccurate readings could lead to false alarms or
missed warnings, reducing the effectiveness of the system.

2. Environmental Factors:

 Harsh weather conditions such as high winds, heavy rain, or extreme temperatures could damage or
interfere with the sensors, affecting the overall functionality of the system. Protecting the hardware
from environmental damage is essential.

3. Limited Range of Sensors:

 The water level sensors might only be effective for a specific range of water heights, which may limit
their ability to monitor extreme flooding conditions. Scaling the system to cover wider floodplains
may require additional sensors and infrastructure.

4. Internet Connectivity:

 Since ThinkSpeak relies on an internet connection for data analysis and storage, any loss of internet
connectivity in remote or rural flood-prone areas could hinder the ability to monitor and respond to
flood events. Backup communication methods need to be considered
IOT Flood Monitoring and Avoidance 36

CHAPTER 7

CONCLUSION AND FUTURE SCOPE

7.1 CONCLUSION

The Flood Observatory System is designed as an intelligent device capable of transmitting real-time
water level data from remote locations to a monitoring station, regardless of time or distance. This system
operates as a standalone unit, requiring no additional devices or systems to function. Its built-in self-
monitoring ensures efficient and reliable performance at the monitoring station. In the event of a failure, such
as issues with the sensor unit or power supply, the system will notify personnel at the monitoring station in
real time. The Flood Observatory System can also be connected to a visual and audio unit, providing
warnings and alerts to users through text displays or a traffic light system during flooding events. The
system's implementation cost is minimal compared to the significant efficiency and value it offers in
preventing damage and saving lives. Its practicality helps reduce the financial impact of floods and provides
critical support for flood-prone areas, ensuring safety and mitigating potential disasters. The system was
specifically developed for monitoring and alerting in remote, high-risk flood zones, safeguarding both people
and infrastructure.

7.2 FUTURE SCOPE

Sensors play a crucial role in the Flood Observatory System, and further research into wireless sensor
technology would be beneficial for replacing the current sensors. Accurate and precise detection of water
levels will enhance the data collection process for the monitoring station. Flood alert information can be
displayed on LED boards for road users, strategically placed in key locations for safety purposes. This
information should be transmitted wirelessly in real-time from the measurement site. A potential power
source for the sensors and centralized control unit is solar energy. If powered by solar cells, the Flood
Observatory System would be easy to install and maintain. Solar power also offers a cost-effective energy
solution, particularly when the system is deployed in remote areas. To ensure sustainability, the design of the
circuits and control unit should focus on minimizing power consumption during operation.
IOT Flood Monitoring and Avoidance 37

CHAPTER 8

REFERENCES

1. H. N. Do, M. Vo, V. Tran, P. V. Tan, and C. V. Trinh, “An Early Flood Detection System Using

Mobile Networks,” International Conference on Advanced Technologies for Communications (ATC),

pp. 599–603, 2015.

2. S. N. Sakib, T. Ane, N. Matin, and M. S. Kaiser, “An Intelligent Flood Monitoring System for

Bangladesh Using Wireless Sensor Network,” International Conference on Informatics, Electronics

and Vision (ICIEV), pp. 979–984, 2016.

3. M. Mousa, X. Zhang, and C. Claudel, “Flash Flood Detection in Urban Cities Using Ultrasonic and

Infrared Sensors,” IEEE Sensors Journal, vol. 16, no. 19, pp. 7204–7216, 2016.

4. M. Khalaf, A. J. Hussain, D. Al-jumeily, P. Fergus, and I. O. Idowu, “Advance Flood Detection and

Notification System based on Sensor Technology and Machine Learning Algorithm,” pp. 105–108,

2015.

5. K. R. Dashpute, V. B. Gaikwad, and S. S. Sawkar, “Flood detection using iot,” no. 2, pp. 1289–1292,

2018.

6. B. K. Durga, A. Ece, S. Peter, and S. E. College, “Design of Early Warning Flood Detection

Systems,” vol. 5, no. 4, pp. 794–799, 2018.

7. THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS - By Muhammed Ali Mazidi,

Janice Gillispie Mazidi

8. Basic Electronics by Regan

9. Fundamentals of Electronics by Ubauld

10. WWW.ATMEL.COM

11. WWW.NATIONAL.COM

12. WWW.MICROCONTROLLER.NET

13. WWW.8051PROJECTS.INF
IOT Flood Monitoring and Avoidance 38

CHAPTER 9

APPENDIX

SOURCE CODE

#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>

// LCD setup (I2C address 0x27, 16 columns, 2 rows)


LiquidCrystal_I2C lcd(0x27, 16, 2);

// Pin configuration
const int flowSensorPin = 27; // GPIO pin for water flow sensor
const int floatSwitchPin = 26; // GPIO pin for float switch
const int trigPin = 18; // GPIO pin for ultrasonic sensor Trig
const int echoPin = 19; // GPIO pin for ultrasonic sensor Echo
const int dhtPin = 32; // GPIO pin for DHT sensor
const int ledPin = 2; // GPIO pin for Green LED
const int buzzerPin = 4; // GPIO pin for Buzzer

// ThingSpeak credentials
const char *ssid = "123456789"; // WiFi SSID
const char *pass = "123456789"; // WiFi password
const char *server = "api.thingspeak.com";
String apiKey = "1AZ1IZJEGE9B0Y5G";

// DHT Sensor setup


#define DHTTYPE DHT11 // Change to DHT22 if you're using it
DHT dht(dhtPin, DHTTYPE);
IOT Flood Monitoring and Avoidance 39

// Variables for water flow sensor


volatile int pulseCount = 0;
float flowRate = 0.0;
const float calibrationFactor = 4.5; // Adjust based on your sensor

// Timer for flow sensor


unsigned long lastTime = 0;

// Ultrasonic sensor variables


long duration;
float distance;

// Interrupt service routine (ISR) for flow sensor


void IRAM_ATTR pulseCounter() {
pulseCount++;
}

void playSiren(int durationMs, int frequency) {


for (int i = 0; i < durationMs / 100; i++) {
ledcAttachPin(buzzerPin, 0); // Attach the buzzer pin to LEDC channel 0
ledcWriteTone(0, frequency); // Play tone at the specified frequency
delay(100);
ledcWriteTone(0, 0); // Stop the tone
delay(100);
}
}

void setup() {
IOT Flood Monitoring and Avoidance 40

// Start Serial communication


Serial.begin(115200);

// Setup pins
pinMode(flowSensorPin, INPUT_PULLUP); // Flow sensor
pinMode(floatSwitchPin, INPUT_PULLUP); // Float switch
pinMode(trigPin, OUTPUT); // Ultrasonic Trig pin
pinMode(echoPin, INPUT); // Ultrasonic Echo pin
pinMode(ledPin, OUTPUT); // Green LED
pinMode(buzzerPin, OUTPUT); // Buzzer

// Initialize DHT sensor


dht.begin();

// Initialize LCD
lcd.init();
lcd.backlight();
lcd.clear();

// Attach interrupt to flow sensor


attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);

// Initialize LEDC (PWM) for buzzer


ledcSetup(0, 2000, 8); // Channel 0, 2kHz frequency, 8-bit resolution

// Connect to WiFi
Serial.print("Connecting to WiFi...");
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
IOT Flood Monitoring and Avoidance 41

delay(500);
Serial.print(".");
}
Serial.println("Connected to WiFi");
}

void loop() {
// Reverse the float switch logic
bool floatState = digitalRead(floatSwitchPin); // Direct logic (no negation)

// LED and buzzer control based on float switch state


if (floatState) { // Float switch is ON
digitalWrite(ledPin, LOW); // Turn off LED
playSiren(500, 1000); // Play siren sound
} else { // Float switch is OFF
digitalWrite(ledPin, HIGH); // Turn on LED
ledcWriteTone(0, 0); // Turn off buzzer
}

// Measure distance using ultrasonic sensor


digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH, 30000); // Timeout after 30ms
distance = (duration > 0) ? duration * 0.034 / 2 : -1; // Check if duration is valid

// Calculate flow rate every second


IOT Flood Monitoring and Avoidance 42

unsigned long currentTime = millis();


if (currentTime - lastTime >= 1000) {
flowRate = (pulseCount / calibrationFactor) / 60.0; // Calculate flow rate
pulseCount = 0; // Reset pulse count
lastTime = currentTime;
}

// Read temperature and humidity


float temperature = dht.readTemperature();
float humidity = dht.readHumidity();

// Send data to ThingSpeak


WiFiClient client;
if (client.connect(server, 80)) {
String url = String("GET /update?api_key=") + apiKey +
"&field1=" + String(temperature) +
"&field2=" + String(humidity) +
"&field3=" + String(distance) +
"&field4=" + String(flowRate) +
"&field5=" + String(floatState) + " HTTP/1.1\r\n" +
"Host: " + server + "\r\n" +
"Connection: close\r\n\r\n";
client.print(url);
client.stop();
Serial.println("Data sent to ThingSpeak successfully.");
} else {
Serial.println("Failed to connect to ThingSpeak.");
}
IOT Flood Monitoring and Avoidance 43

// Print sensor values to Serial Monitor


Serial.print("Float Switch: ");
Serial.println(floatState ? "ON" : "OFF");
Serial.print("Ultrasonic Distance: ");
if (distance >= 0) {
Serial.print(distance);
Serial.println(" cm");
} else {
Serial.println("Out of range");
}
Serial.print("Temperature: ");
if (!isnan(temperature)) {
Serial.print(temperature);
Serial.println(" °C");
} else {
Serial.println("Error reading temperature");
}
Serial.print("Humidity: ");
if (!isnan(humidity)) {
Serial.print(humidity);
Serial.println(" %");
} else {
Serial.println("Error reading humidity");
}

// Display data on LCD


lcd.setCursor(0, 0); // First row
lcd.print("T:");
if (!isnan(temperature)) {
IOT Flood Monitoring and Avoidance 44

lcd.print(temperature, 1); // Show 1 decimal place


lcd.print("C ");
} else {
lcd.print("-- ");
}
lcd.print("H:");
if (!isnan(humidity)) {
lcd.print(humidity, 1); // Show 1 decimal place
lcd.print("%");
} else {
lcd.print("--%");
}

lcd.setCursor(0, 1); // Second row


if (floatState) {
lcd.print("Flood Detected ");
} else {
lcd.print("Safe ");
}

// Short delay to stabilize readings


delay(500);
}

You might also like