IOTFlood: hardware and software platform using internet of things to monitor floods in real time

Floods are responsible for a high number of human and material losses every year. Monitoring of river levels is usually performed with radar and pre-configured sensors. However, a major flood can occur quickly. This justifies the implementation of a real-time monitoring system. This work presents a hardware and software platform that uses Internet of Things (IoTFlood) to generate flood alerts to agencies responsible for monitoring by sending automatic messages about the situation of rivers. Research design involved laboratory and field scenarios, simulating floods using mockups, and later tested on the Mundaú River, state of Alagoas, Brazil, where flooding episodes have already occurred. As a result, a low-cost, modular and scalable IoT platform was achieved, where sensor data can be accessed through a web interface or smartphone, without the need for existing infrastructure at the site where the IOTFlood solution was installed using affordable hardware, open source software and free online services for the viewing of collected data.


INTRODUCTION
Floods are responsible for a high number of human and material losses every year. It is estimated that, worldwide, 20 million people suffer annually from the effects of this environmental phenomenon, to include 270 thousand in Brazil (Christofidis et al., 2019). The adverse effects of seasonal floods in riverside communities and in cities bordering river basins, such as deaths, destruction of houses and crops, loss of material goods and long periods of homelessness, are the main social consequences caused by the alteration of the hydrological regime (Cristaldo et al., 2018;Franco et al., 2018).
However, it is possible to reduce these impacts through the adoption of preventive measures, which involve the constant monitoring of river levels very close to inhabited areas, using equipment that performs the measurement of data in a continuous and reliable way. Monitoring can be manually performed, with daily records from observers, using linimetric rules available at hydrometric stations to measure rainfall volume, level and flow of rivers, or automatically through float, ultrasonic and water column pressure sensors, which remotely transmit data to software (ANA, 2011;Pereira et al., 2020).
Recently, the Internet of Things (IoT) has emerged as a global computing infrastructure through the adoption of technologies that transmit and convert data obtained from different devices, including digital sensors, allowing the autonomous exchange of useful information through technologies such as radio frequency identification (RFID), wireless sensor networks (WSN), cloud computing (Farooq et al., 2015).
The prediction of natural disasters, such as floods, is one of the IoT applications, as it allows adequate monitoring of variables inherent to the environment. However, there are two significant disadvantages of using smart sensors across isolated areas such as riverbeds: component cost and battery life, since they commonly require periodic supervision to check status and battery replacement (Farooq et al., 2015). Fortunately, the evolution of sensor engineering has allowed the creation of low-cost implementation and maintenance projects.
In Brazil, the northeastern region is considered the most economically vulnerable area and also one of the most susceptible to flooding episodes during the rainy season (Pereira et al., 2018). In the states of Alagoas and Pernambuco, the hydrographic basin of the Mundaú River stands out in the region.With a surface area of 4126 km 2 , 52.2% of which located in the state of Pernambuco and 47.8% in the state of Alagoas, it is the water system most used in irrigation, fishing, supply and transportation activities (Freire and Natenzon, 2019).
Approximately half of municipalities that make up this hydrographic basin are located in the state of Alagoas. Most of the urban areas of these municipalities are located on plains, which have repeatedly suffered from floods (1914,1941,1969,1988,1989,2000,2010), revealing the vulnerability of the region in relation to events of this nature (Monte et al., 2016). According to Fragoso Júnior et al. (2010) and Freire and Natenzon (2019), in the last extreme episode, which occurred in 2010, in just 3 days of heavy rain, 26 municipalities in Alagoas were declared in the state of public calamity and another 34 in the state of emergency, causing 55 deaths and leaving almost 150 thousand people homeless. Such a scenario indicates the need for constant and effective monitoring, with accurate and real-time hydrological measurements along the river.
According to Alagoas (2020), in hydro-meteorological stations present in the state, there are twenty-six monitoring points of rivers using radar and level sensors which send, via GPRS and satellite, hourly information on level and flow for viewing the intensity of rising rivers. However, a major flood can occur in a few minutes, justifying the implementation of a realtime monitoring system. In view of this gap, it is understood that environmental technologies and innovations using digital sensors, integrating hardware and software, can be inserted in the scenario of monitoring rivers in order to generate instant data, helping decision-making by competent bodies.
For these reasons, the Mundaú River served as a test scenario for this research, which features a flood monitoring system, called IOTFlood, composed of surface sensors that collect data on atmospheric pressure, river elevation level, rain occurrence, temperature and geolocation, represented in Figure 1. In the proposal, a low energy consumption microcontroller was used to read data from sensors and transmit them via LoRaWAN® -an open-standard communication protocol that governs LoRa® networks and uses radio frequency for long-range transmissions with minimum energy consumption -for a remote gateway, connected to the Internet, which sends received data to a server in the cloud. This station, in addition to having an open implementation architecture with integrated low-cost software and hardware solution, has the following advantages: (i) possibility of installation in remote locations and without access to the Internet or cellular signal; (ii) long transmission range (reaching tens of kilometers); (iii) access to data over the Internet; (iv) creation of graphs showing data variation, with possibility of generating alarms to notify situations requiring attention, making it possible to take preventive actions; (v) easy installation and use; and (vi) long battery life, eliminating the need for power banks to achieve this longevity.
Before the development of the IOTFlood solution, a literature review was carried out in search of related works in order to support the appropriate choice of its hardware and software components.
In the work of Tose (2012), a prototype was developed for monitoring sewage stations with Arduino connected to temperature, humidity and gas sensors, using communication technology without ZigBee for data transmission. However, this is a high-cost approach with low reach (due to the operation frequency) and very sensitive to interference from other devices, with low battery autonomy and dependence on a computer located near the prototype's installation site. IotFlood differentiates itself by having a significantly longer transmission range, running on battery and the possibility of operating without the need for a nearby computer. Helal (2018) described the construction of a prototype, called EstAcqua, of an environmental and oceanographic station with low-cost surface and submerged sensors, with low-cost hardware, using wireless data transmission via LoRaWAN and open source software with low power consumption and long transmission range. EstAcqua has illuminance, atmospheric pressure, humidity and external and underwater temperature sensors. IotFlood differentiates itself by being applied to the monitoring of floods in lagoons and rivers, having as reference level location (GPS), rainfall, ultrasonic, temperature and pressure sensors.
Oliveira (2017) reported the creation of a geomagnetic station using Internet of Things concepts with a web interface for viewing online data. The magnetometer has temperature sensors to help with measurements made and stores them in a database on a micro SD card. IotFlood differentiates itself by using LoRaWAN for data transmission, having low energy consumption and being focused on environmental and oceanographic monitoring. Tzortzakis et al. (2017) used Atmega328 microcontrollers with transmission cards without LoRa to collect environmental data in cities and transmit them via LoRa to a gateway that in turn forwards data to an IoT server using GPRS. The devices that collected data were powered by a battery and solar plate. IotFlood is differentiated by the use of nodes exposed to the environment, transmission of data close to the ground and the use of LoRaWAN in sending collected data.
As observed in the aforementioned works, solutions are usually for short range, and depend on a nearby computer to obtain data from sensors or on an external power source to energize the equipment. Thus, a differential of the architecture proposed in this work is its adherence to IoT, where data from sensors can be accessed through web interface or cell phone, without the need for existing infrastructure at the IoTFlood installation site using low-cost hardware, open source software and free online services for viewing collected data.
Section 2 presents the research methodological procedure, which consisted of laboratory experiments and field tests, as well as hardware and software components used. Section 3 presents the IOTFlood platform and discussions on collected data. Finally, conclusions and suggestions for future works are presented.

MATERIALS AND METHODS
This applied research adopted the Design Science Research Methodology (DSRM) as methodological procedure (Peffers et al., 2007), which consists of the production of a technological artifact in six stages: problem identification and motivation; definition of the objectives for the solution; design and development; demonstration; evaluation and communication. The problem identification stage referred to the need for real-time flood detection. The objective was to implement hardware and software architecture to adequately support the services provided for in the project. In design and development, a test mockup was used, called the "aquarium", whose graphical representation is shown in Figure 2, which contextualizes all ten elements of the laboratory environment scenario. Demonstration and evaluation of the proposal were carried out in laboratory and field environments. The aquarium, built for the laboratory test environment, measuring 100 centimeters in length by 50 centimeters in height and 70 centimeters in width and capacity to store 350 liters of water, proposed to represent, without using scales, a situation of river bed and bank, with the usual decline to simulate the field environment, with reading of variables by means of sensors. The experiment was carried out with manipulation of variables such as water flow and rain occurrence and quantity, simulated with a shower installed in the corner of the mockup. It is also important to note that the tests were carried out in order to demonstrate that the modularity of the IOTFlood architecture allows different sensor configurations to be coupled to the proposed solution.

IOTFlood solution hardware
The first challenge in designing the IOTFlood platform hardware was deciding which sensors are best suited to monitor water in the event of flooding. The most common level sensor technologies include ultrasound, guided wave radar and pressure transducers. The microcontroller most suitable to the proposal was chosen, which consists of a small and independent computer that is housed in a single integrated circuit. The option for IOTFlood was LoPy4 due to its low cost, memory capacity, integrated LoRa® chip and embedded MicroPyton language. Fipy, which consists of a native MicroPython development board, was chosen as a gateway to enable the option of connecting via Wi-Fi or operator chip, thus allowing an extra standard connection mode with the possibility of operating in places difficult to access.
Printed Circuit Boards (PCI) were designed with the implementation of two independent and auxiliary circuits to integrate the microcontroller connected to the sensors. The field environment board was more compact, since it only needed to perform level (analog and digital), temperature, pressure, and rain indication and intensity readings. The laboratory board carried out the same field environment measurements; however, it displays a visual signaling through LEDs that need to be activated by relays. Figure 3 describes the materials used in the IOTFlood hardware.  The characteristics of the different sensors used in the research are detailed below: • HC-SR04 ultrasonic distance sensor: capable of measuring distances from 2cm to 4m with great accuracy. In IOTFlood, it was used to measure the distance from the sensor to the water blade.
• Neo6m GPS module: compatible with several flight controller modules, making it ideal for drones. The serial interface is 3.3V. It was used in research to indicate positioning, latitude, longitude, date and time of displacement in relation to the object.
• BMP280 pressure and temperature sensor: it is a barometer, which was used to measure atmospheric pressure and temperature. In addition, this sensor can also inform the approximate altitude of the location where it is installed. The BMP280 module works with I2C or SPI interfaces and 3V voltage, and its low energy consumption allows it to work for long periods on battery power, being suitable for projects such as drones, weather stations, devices with GPS, clocks, etc; • 9SS18 rain sensor: It monitors a variety of climatic conditions such as rain or snow, and was used in IOTFlood to capture the rainfall incidence. When the climate is dry, the sensor output is in high state and in low state when in the presence of rain; • LA16M-40 level sensor: The sensor indicates via ON / OFF signal when the water level has been reached, being installed on the internal side of the test tank. For each water level to be detected, it was necessary to install a sensor at the desired point in the test tank and on the bridge in the field. Four sensors were used in both. These data on the water level, when captured and presented in dashboards, signal to the agency about the risk of flooding. In addition, they send warning signs by text message to the email of those responsible for environmental monitoring.
• Harmony XB7 beacons: This Harmony XB7 monoblock line is composed of buttons, switches and control unit beacons, which simplifies acquisition and installation in power distribution machines and applications, being used in IOTFlood to visually indicate upon ignition of buttons at each water level detected by sensors installed in the test tank.

IOTFlood solution software
To promote the integration and real-time visualization of data generated by sensors through an application for users, The Things Network (TTN) and Cayenne platforms were adopted because they are free and worldwide references in IoT projects.
The TTN platform is an open cloud-based network (network server) that globally connects LoRaWAN gateways and provides a set of tools to create low-cost, safe and scalable IoT applications. In turn, Cayenne is a free software platform that allows building, prototyping and sharing connected devices from IoT projects. Cayenne also provides an online dashboard and an app version for smartphones so that users can remotely monitor and control their IoT projects. The platform has a database with hundreds of LoRaWAN devices from different manufacturers, which automatically allows identifying a new sensor added to the application, whose data is captured and loaded on the user's dashboard.
The software embedded in IOTFlood was programmed in the MicroPython language in two modules, one for reading information from sensors and the other for transmission to the gateway through the LoRa network. The gateway handles data received from devices and forwards them to the TTN, where integration with the Cayenne server is performed to allow users to view information collected from sensors.

Solution architecture
The IoTFlood solution was designed to be used in two scenarios: laboratory and field. The laboratory environment simulated a flood scenario through the projected model called "aquarium". In the field environment, IOTFlood could be tested in a natural environment, that is, in a river where several flooding episodes have already occurred.
In both environments, the IOTFlood architecture was divided into four modules formed by: data transmitting devices, data receiver, Cloud IoT (network) and the visualization interface for the user, as shown in Figure 4. It should be noted that the difference between the IOTFlood architecture developed for laboratory and field was that, in the first environment, LEDs (light emitting diode) were used, which only work with 220V alternating voltage supply, while in the second environment, the hardware intended for the field was designed to provide 5V continuous voltage through a battery without the use of LEDs. In turn, data read from sensors are transmitted to the gateway, which forwards them to the TTN cloud for integration with Cayenne, which are made available to the user.

RESULTS AND DISCUSSION
Results were achieved in the two environments designed for the research. To evaluate the functionalities and the fulfillment of requirements for collection, transmission and processing of the prototype data, the following tests were performed on the solution architecture: (i) laboratory simulation aiming to analyze the behavior of the prototype in place with controlled variables for simulations; (ii) installation on the Mundaú River aiming to analyze the behavior of the prototype in natural environment.
Laboratory results involved the analysis of simulated data on monitoring pressure, humidity, temperature and flood levels. Sensor data were sent to the gateway located 10 meters away from the sensing control device (endpoint), which was connected to the laboratory's Wi-Fi network. The endpoint was coupled to an electrical box following the pattern of the twophase and three-phase model, as shown in Figure 5, which also shows how data are made available online to the user in web and mobile versions. The occurrences of water reaching the predetermined levels caused the LED lights to turn on, signaling relevant simulation events.  IOTFlood: hardware and software platform using … Rev. Ambient. Água vol. 16 n. 4, e2675 -Taubaté 2021 Figure 6 presents the graphs of data captured by sensors during laboratory tests, whose analyses and discussions are described below: • Barometer sensor: on Day 16, it was possible to notice a slight increase in atmospheric pressure (Point A). On the other days, tests confirmed a drop in pressure levels in the environment; • Analog Distance Sensor (level): simulations of raising and lowering of the river level were carried out by adding water through a shower and removal with the aid of a hose (Points B, C, D, E); • Temperature Sensor: in the first days, tests were carried out at night and then during the day, which explains variation in ambient temperature (Point F); • Ultrasonic Distance Sensor: as in the environment, there were routine simulations of river elevation through the addition of water, reaching different elevations and respective removal, symbolizing level reductions (Points G, H, I, K, L and M); • Rain Intensity Sensor: using sensor to identify rain occurrence and intensity, this phenomenon was simulated with the use of shower (Points M, N, O, P, Q and R); • Rainy Weather Sensor: with a sensor installed just below the shower, it was possible to simulate in real time the variation of weather without rain and with light and intense rains (Points S, T, U, V and X). Since all IOTFlood hardware and software were adequately tested in laboratory simulations, we proceeded to monitoring and communication tests for validation in the real environment. The chosen stretch of the Mundaú River is located in the city of União dos Palmares, state of Alagoas, which has already undergone major flood events (Freire and Natenzon, 2019). In addition to monitoring pressure, humidity, temperature and flood levels, data indicating the location of the equipment on the map were also collected. Data captured by sensors were transmitted to the gateway, located 15 meters away from the endpoint and connected to a cell phone's Wi-Fi network. The electrical box with the devices was fixed at the base of the main river bridge, as shown in Figure 7.   In the field environment, tests took place between 10:00 am and 06:30 pm. The results are discussed below: • Barometer sensor: from Point A to point B, there was a decrease in atmospheric pressure due to the milder temperature in late afternoon, followed by a slight increase at Point C; • Temperature sensor: there was an increase in temperature (Points D and E) from morning until late afternoon, with a decrease (Point F) in early evening.
• Ultrasonic Distance sensor: no rise in the Mundaú River level was observed, but a slight reduction (Points H and I) of a few centimeters in the river level was observed at dusk; • Rainy Weather sensor: there was no incidence of rain on the day of tests; • Analog Distance sensor (level): as observed in the ultrasonic sensor, there was no rise in the Mundaú River level; however, there was a slight reduction (Points O and P) of a few centimeters at dusk. They were composed of four sensors separated by a distance of fifty centimeters assembled on a structure with height of two meters and fifty centimeters from the river level; • Rain Intensity sensor: there was no incidence of rain on the day of tests.
Data captured from a natural environment met expectations for validating the proposed architecture. The functioning of sensors in procedures of capturing and sending remote data occurred properly in the connection established in the field, with the endpoint sending data to the gateway every 10 seconds. Figure 9 presents a comparison of the performance of materials used in IOTFlood, especially sensors, during laboratory and field experiments.

CONCLUSIONS
The IOTFlood platform was built to capture data from a set of sensors for the environmental monitoring of river levels in real time, with high battery autonomy and long transmission range. Data collected by IOTFlood are transmitted to an Internet of Things server in the cloud and made available for user viewing. Tests carried out in the laboratory and in the field demonstrated that the LoRa technology met the architecture purpose, which was to transmit data to a gateway located up to 1.5 km away.
The IoT server in the cloud allows the creation of graphs for viewing collected data, making it available both via web and mobile, in addition to allowing the creation of alarms to warn for the occurrence of anomalous situations. In addition, it is possible to configure the Cayenne application to send specific alert messages by E-mail or by the Short Message Service (SMS) according to the monitoring of sensors.
Regarding project costs, which included a list with twelve materials, including gateway and endpoint, after several tests to select more suitable sensors, LEDs and other components, architecture with accessible value was reached, as proposed in this research, totaling approximately U$ 300.00.
This study presented limitations regarding the capture of data in the real environment, as sensors were exposed for only one day. Although the meteorological service indicated that it would be a rainy day, rain did not occur, making it impossible to accurately check rain sensors. In addition, the time taken to install and remove materials on the bridge and due monitoring to avoid theft problems also prevented the procedure from being repeated on other days.
Further studies should explore the IOTFlood platform in different seasons and other stretches of the Mundaú River, with more variations of wind intensity, current and water level, submitting the solution architecture to other uncontrolled environmental variables.