Keywords: Drainage Monitoring, Internet of Things, Sensor, Gas Monitoring, Firebase, Real time monitoring
One of the systems involved in maintaining the environment of the urban city clean and healthy is the drainage system. Among the problems associated with the blocked drainage system are the stagnant water, flood, bad odor, and emission of gases. The process of manual inspection is one of the processes that help in checking the status of the drain. The process involves the physical inspection of the drain after some certain periods of time. Thus, it is necessary to have an automated system that will help in monitoring the status of the drain.
It is possible to use the Internet of Things (IoT) technology in monitoring the drainage system since it requires continuous monitoring of the status of the drain. The IoT device collects the data collected from the sensors and transmits it through the network. In the current project, ESP32 will be the IoT device that connects to the internet and transmit the data. The sensor used in measuring the depth of the drain in order to indicate the extent of the blockage is the HC SR04 Ultrasonic Sensor. The suggested system will be made up of the web dashboard through which the operator will be able to view the sensor readings as well as the drain status in a real time manner. In the suggested system, local LEDs have been used in order to provide an indication about the presence of any blockage or excessive amount of gas. The objective of this research work is to design a cost effective smart drain monitoring system that will help in monitoring the condition of the drain, detecting the presence of any blockage and excessive amount of gas and storing as well as visualizing the data through Firebase database and web dashboard.
An existing work (Naim et al., 2026) [1] has designed IoT based flood detection system with real-time data logging and notifications. However, the system mostly concentrates into flood monitoring as opposed to drain blockage and gas detection. Another work (Kumar et al., 2025) [2] has proposed a smart drainage monitoring system based on ESP for monitoring water accumulation. The system provides cloud based monitoring without providing any mechanism for toxic gas detection. An IoT based sewage monitoring system (Maruthupandi et al., 2024) [3] has been designed in the past for blockage detection. The system provides alerts based on threshold without GPS location identification and cloud dashboard visualization facility.
An IoT based manhole monitoring system (Islam et al., 2024) [4] using ultrasonic and gas sensors for cloud and web monitoring has been proposed in the past. However, location identification using GPS facility was not included in the system. A LoRaWAN based water-flow monitoring system[5] concentrates on monitoring flow anomalies and leakage as opposed to drain blockage. A similar work which was based on IoT and GIS (Vishalsanker et al., 2024) [6] based water pipeline surveillance system using flow and pressure sensors with LoRa communication. However, it focuses on pipeline leakage rather than drain blockage and gas detection.
Dayana R. et al.[7] has proposed a web-based smart manhole monitoring system for smart-city maintenance. Hazardous gas monitoring facility was not provided. The authors Abinaya K. et al. (Sujithra et al., 2022) [8] proposed an IoT based manhole monitoring system, which provide automatic alerts; however, the sensing parameters were limited. Roshan A. et al. (Bharathi et al., 2023) [9] used ultrasonic, water level, tilt and MQ2 gas sensors for monitoring the manholes and drainage; however the system was equipped with GSM without any GPS based location facility for alerts. Vaishali B. Niranjane et al.[10] provided an IoT based manhole monitoring system equipped with water flow, temperature and tilt sensors through ThingSpeak, however, the system had no gas sensing capability.
| Model | Features | Technology/ communction | Output/ Limitation | ||
| FDS | Flood detection and real time data logging |
| Real time flood detection and data recording. Focuses mainly on flood monitoring | ||
| SDPS | Smart drainage and flood prevention |
| Water accumulation monitoring Does not focus on gas detection | ||
| SBD | Sewage monitoring and blockage detection |
| Blockage monitoring Limited dashboard visualization | ||
| MMS | Manhole monitoring and safety detection |
| Remote manhole monitoring No GPS based location identification | ||
| WFM | Water flow monitoring and anomaly detection |
| Flow anomaly detection Focuses on water flow rather than blockage | ||
| PWDS | Pipeline surveillance and leak detection |
| Leakage monitoring Designed for pipelines rather than drains | ||
| WSMM | Smart manhole monitoring and cleaning |
| Web based monitoring Limited hazardous gas monitoring | ||
| I-MMDS | Manhole monitoring and detection |
| Automatic alert system Uses limited sensing parameters | ||
| IMDMS | Manhole and drainage monitoring |
| Multiparameter monitoring No GPS based alert location | ||
| MDS | Manhole detection and monitoring |
| IoT based monitoringNo dedicated gas sensing |
Based on previous researches, the use of IoT systems have been proven to increase the efficiency of the drainage system and the manholes using the real time sensing capability and remote alert mechanism. However, majority of the existing IoT systems are only capable of monitoring one factor, whether it is the water level, flow or leakages. In some cases, wherein multiple sensors are used, these can be limited to technologies such as GSM, LoRaWAN and certain clouds. The proposed system will combine the ultrasonic sensing for measuring distances and gas sensing using ESP32. The data from the sensors will be sent through WiFi to Firebase, and an LED will serve as a local alert mechanism.
The above system will be utilized to detect drain clogging and presence of harmful gases using IoT Technology. The whole system methodology will involve the collection of sensor readings, processing of sensor data, detection of blockage, data transfer through Firebase and the web monitoring process. The ESP32 will act as the central processing unit which receives and analyzes the data from the HC SR04 ultrasonic sensor and MQ2 gas sensor.
The system continually gathers the data of the drain through the use of two sensors. The HC SR04 ultrasonic sensor is used to measure the distances in the drain, while the MQ2 is used to measure the presence of any harmful gas. The sensor data of the ultrasonic distance and gas are obtained by the ESP32 at specified time intervals The sensor data are compared with predefined threshold values.. Based on the obtained data, the drain state can be normal, warning, blockage or poisonous gas state.
The important factors adopted in the proposed system are as follows:

| Algorithm 1: Sensor Data Collection |
Input:
Output:
Algorithm:
|
The values obtained from the HC SR04 ultrasound sensor and MQ2 gas sensor are based upon the state of the drain. The values of the HC SR04 and MQ2 are used by the ESP32 in deciding whether any potential obstructions are there as well as any hazardous gas. The values are compared with the threshold value in order to classify the state of the drain currently. In accordance with the status category, the LED alarm as well as the status update is sent to the Firebase database. This process is represented by Algorithm 2.
| Algorithm 2: Drain condition detection from sensor readings |
Input:
Output:
Algorithm:
|
The identified drain state was utilized to provide real time local and remote monitoring. Upon the occurrence of the sensor values identifying an anomalous state, the LED glows to notify the user of the issue visually. Additionally, the ESP32 transmits the sensor values and the state of the drain over WiFi to the Firebase Realtime Database. The obtained information is then used by the web dashboard in order to provide continuous monitoring. As such, the current drain state and the sensor readings can be kept up to date. The features that could be extracted from the sensors data collected using the proposed system were chosen depending on the features which could be used to classify the condition of the drains. The ultrasonic distance data and the MQ2 gas data were considered the most important features from the sensors because the distance data was related to the condition of the drains while the gas data referred to the amount of poison gas.
The proposed methodology utilizes the sensor values of the ultrasonic and gas sensors to monitor and detect the status of the drain. This is performed by continuously capturing the sensor values with the ESP32 and processing it according to the threshold levels. The measured distance by the ultrasonic sensor assists in detecting the blockages while the gas sensor values from MQ2 detect if there are any harmful gas levels. The combination of the processed sensor values will determine the status of the drain. The data collected from the ultrasonic sensor will be used to classify whether the drain pipe is blocked or not. HC SR04 Ultrasonic sensor is used to sense the distance between the sensor and the obstruction or surface of the water. The distance sensed by the ultrasonic sensor will be compared with the threshold distances. If the distance sensed is normal, it will be considered as drain is normal. Otherwise, the drain pipe might be blocked.

The analysis process of the data from the gas sensors is utilized to identify whether there are any harmful gases present in the drain. The MQ2 sensor senses the gas level and sends the sensor value to the ESP32. The value of gas detected is compared with the predefined threshold values. The value in the normal range reveals that the situation is safe, whereas the increase in the value reveals the warning situation. If the gas level goes beyond the critical threshold, it is detected as toxic gas situation, and the LEDs are switched on to reveal the warning.

Hybridized classification stage utilizes the results that are derived from the ultrasonic sensor and MQ2 gas sensor. The ESP32 considers the condition of both sensors in classifying the drain status. The system recognizes the drain condition as Normal as sensor values are normal. In case any of the sensors is found to be exceeding the warning threshold, the condition of the drain is classified as Warning. When the blockage or gas level is found to have crossed the critical threshold, the system classifies the condition of the drain as Blockage / Toxic Gas. The classified sensor data above is incorporated together with Firebase Realtime Database for the continuous monitoring and recording of the data. After the process of classifying the drain status by the ESP32, using the data collected by the ultrasonic and gas sensors, the data and status are uploaded to Firebase with the help of a WiFi. The latest data gathered which includes the distance, gas value, and drain status, is recorded in the database. The database is accessed by the web based application where it gets the data and presents the status of the drain.
In order to effectively monitor the drain in real time, ESP32 with Firebase Realtime Database will be used. Data gathered from the sensors will be continually processed by the ESP32. The ultrasonic sensor will gather distance values, while the MQ2 gas sensor will collect gas values. The sensor values collected will be helpful in ascertaining the drain status. ESP32 will process the data that is collected from the sensors and will compare it with the threshold ones. Based on the values, one will be able to identify the drain status as normal, warning, blockage or toxic gas. In case there are any abnormalities, the LED will be turned ON. The data processed by ESP32 will be uploaded into the Firebase through a WiFi connectivity. The data that will be uploaded to the database will encompass the distance, gas value and drain status. Web dashboard will get the data from the Firebase and will showcase the current values of the sensors and the drain status.

The complete system consists of the process of acquiring sensor data, preprocessing, extracting features, classifying drain condition, transmitting data to Firebase and monitoring this data using dashboard. The full process of drain condition classification is given in Algorithm 3 and the steps for transmitting and monitoring the classified sensor data using Firebase is given in Algorithm 4. Firstly, ultrasonic and gas sensor data is acquired using ESP32. The analysis of the distance value is helpful in concluding any kind of blockage whereas analysis of gas value concludes whether there are harmful gas conditions. These two analyses help in concluding the status of the drain. The result that has been classified is transmitted through Firebase together with the respective sensor values.
| Algorithm 3: Drain condition detection using ESP32 |
Input: The sensor input values of ultrasonic distance D and gas value G Output: The condition of the drain as Normal, Warning, or Blockage/Toxic Gas
|
| Algorithm 4: Real Time Drain Monitoring with Firebase |
Input: Distance D, Gas G, Classified Status of the Drain S Output: Stored data of sensors and new drain status in Firebase
|
The proposed Smart Drain Blockage Detection and Monitoring System was designed and developed using ESP32, HC SR04 ultrasonic sensor, MQ 2 gas sensor, LED, Firebase Realtime Database, and web dashboard. Different drain conditions were experimented in order to test for the blockage and presence of harmful gases.
The performance of the proposed Smart Drain Blockage Detection and Monitoring System was determined through the readings from the sensors that were attached to ESP32. The HC SR04 ultrasonic sensor was used to measure the distance inside the drain, whereas MQ 2 sensor was employed to measure harmful gases. The readings from the sensors were processed by the system, and accordingly it classified the drain condition based on threshold values. In case of normal condition, the system showed Normal status. However, when there was any obstacle or gas concentration level increased, the system generated appropriate warning messages.
The sensor data was uploaded to Firebase Real time Database using Wi Fi. The website dashboard displayed the last distance, gas value, and drain status, thus it was possible to monitor remotely the drain conditions. Based on the experiment, it is possible to state that the proposed solution can provide continuous monitoring of sensors, obstruction detection, hazardous gas detection, Firebase database upload, and dashboard visualization in real time.
| Drain State | Detection state | LED status | Firebase update |
| Normal state | Normal | OFF | Yes |
| Warning state | Warning | ON | Yes |
| Blocked state | Blocked | ON | Yes |
| High gas state | Toxic Gas | ON | Yes |
| Approach | Ultrasonic Sensing | Gas Sensing | Real Time Sensing | Firebase | Alert Using LED | |||||
| Conventional Inspection | No | No | No | No | No | |||||
| No | No | Yes | Sometimes | No | |||||
| Yes |
|
|
|
| |||||
| Manhole Monitoring | Yes | Yes | Yes | Sometimes | Yes | |||||
| Proposed System | Yes | Yes | Yes | Yes | Yes |

.


The proposed system was compared to conventional inspection, water level monitoring, Internet of Things (IoT) based drain monitoring, and manhole monitoring systems according to the list of characteristics shown in Table 3. The comparison is based on ultrasonic sensing, gas sensing, real time sensing, Firebase based monitoring, and LED based warnings. The conventional inspection technique does not provide continuous monitoring through sensors, whereas water level monitoring techniques concentrate only on water conditions. IoT based drain and manhole monitoring provide real time sensing, but utilize other techniques of sensing and cloud based monitoring. The proposed solution involves ultrasonic, gas, and real time sensing, Firebase based data storage, and LED based warning techniques. The comparison provides information on the characteristic set of the proposed system. Thus, the results prove that the proposed solution incorporates several monitoring functions of continuous drain condition monitoring.
In the proposed Smart Drain Blockage Detection and Monitoring System project, an IoT based model was used to monitor the status of the drain in real time. In the system, the ESP32 acquires the data from the HC SR04 ultrasonic sensor and MQ2 gas sensor to identify the potential blockage and presence of hazardous gas. Then the data is sent in the Firebase Realtime Database through Wi Fi. The LED was used as an indicator to provide information about the abnormal status of the drain. Therefore, the suggested system can be utilized in continuous monitoring of the drain, detection of drain blockage, identification of the presence of hazardous gases, and remote viewing of the sensor data. It is a cost effective approach for monitoring the status of the drainage system without regular inspection.