**Automated Monitoring System for River Water Level and Water Quality Assessment using Telegram Bot API**

Received Date: \*date

Accepted Date: \*date

Published Date: \*date

**HIGHLIGHTS**

  - Monitoring system is a method that can be used to stay updated on the river water status

  - Ultrasonic sensor used soundwave to detect the water surface area

  - pH sensor used two electrodes in the sensor to measures the pH level

  - Telegram application is a cloud-based instant messaging service that is free and open source.

ABSTRACT

*Technology has advanced to the point that it can assist people in their daily lives. Human beings may benefit from this development in a variety of ways. Progress in river water monitoring is also one of them. There are many advantages in improving the river water monitoring system. The objective of this project is to develop an automated system for monitoring river water levels and quality with push notification features. Internet of Things (IoT) was implemented in this research by using NodeMCU as a microcontroller to connect both ultrasonic sensors and pH sensors to the Internet. An ultrasonic sensor is used to read the water level, and a pH sensor is used to read the water pH values. The results show the successful output from all of 10 time attempts to obtain more accurate test results. The results will be averaged to be analysed and concluded from the test. All the tests include testing for the accuracy of the ultrasonic sensor, the accuracy of the pH sensor, and the performance of the internet connection using integrated Wi-Fi module in NodeMCU microcontroller. The system test also shows that it performs perfectly with the requirement needed to send the real-time status of the water level, water quality and an alert to the user using the Telegram Bot API. This research can help to increase the level of awareness of the river water monitoring system. This research was done by looking at people's problems in the vicinity of the river area by producing a system tool that helps to monitor the river water in real-time status.*

***Keywords:*** ***monitoring system, NodeMCU, ultrasonic sensor, pH sensor, telegram, real-time status***

# INTRODUCTION 

# A river was a naturally flowing, typically freshwater watercourse that flowed towards an ocean, sea, lake, or another river. Rivers had been a source of food since time immemorial, especially to the locals. However, rivers could also be caused harm to local people, such as floods and pollution. The flood was the most destroying catastrophic event experienced in Malaysia. Flood regularly occurs on the east coast of peninsular Malaysia caused by heavy rains brought by the northeast monsoon winds, especially in Kelantan, Terengganu, and Pahang. Sometimes these floods brought great destruction and harm to the government to repair the damage suffered. 

# Current method or system warning through siren caused someone who lived far away from the siren unable to hear the siren. In addition, the problem was that the surrounding residents did not take the warning siren seriously. It was discovered that the siren's crisis cautioning sounded could not be separated from the sounds utilized during its typical activity (non‐emergency cases) and, in this manner, had neglected to react to it during a real crisis (Flood Risk Management, 2019).

# Human activities, especially in manufacturing and development, had caused pollution to the river, causing ecosystem damage and harming humans. For example, Sungai Langat water was unsafe to drink without being treated first due to synthetic pollution from pointed and non-point pollution sources, even though it was one of the critical water sources in Selangor, Malaysia. Besides that, low awareness of water quality could endanger our health in the future. There was a cycle when toxins were in the water. Toxins moved from the water used by animals and plants that humans ate until the contaminants entering the food chain (Rafia Afroz & Ataur Rahman ,2017). This was because people did not know about the level of water quality.

# Some of the previous work that relates to this research are Real-Time Water Level Detection from Anton Prafanto and Edy Budiman (2018). The system would use the component ultrasonic as a sensor and NodeMCU as a microcontroller. NodeMCU was used because it was similar to the Arduino microcontroller with output and input but a little advance with the built-in wi-fi. NodeMCU was used to upload data to the monitoring platform in real-time. The other similar research is from Natividad and Mendez (2018) who had proposed a flood monitoring and early warning system. The proposed project had used an ultrasonic sensor, Arduino, and gsm module in that project. In that project, two devices combined were ultrasonic sensors to quantify the range of the water level, an Arduino microcontroller to process the data from the sensor, and a GSM module to send the information. This project used an ultrasonic sensor to recognize water level and used a GSM module to send an alarm message or water level status to the computer as a server. 

#  Additional similar work also showed from Daigavane & Gaikwad (2017) who had developed a water quality monitoring system based on IoT. The proposed project had used a pH sensor, turbidity sensor, temperature sensor, flowed sensor, wi-fi module, and Arduino module. This project was comprised of a few sensors that were associated with the core processor. The core processor was getting to the sensor esteems and handling them to move the information through the web. Arduino was utilized as a core processor. Data from the sensor could be seen via the web used a wi-fi server and computer.

# METHODOLOGY 

The waterfall model of methodology will be implemented in this project. The first phase is the initiation phase, which looks at the plausibility and feasibility information related to the river water monitoring systems of the project. Next is the planning phase that was conducted based on the information gathered in the beginning phase. This phase would collect and plan all the necessary information, such as hardware and software, to create the proposed project architecture. In the development phase, all hardware will be assembled and set up as the proposed system. The next phase will then involve the testing that will be evaluated to see the performance of the prototype system. All data and information will be combined into one report based on a specific writing method in the last phase. Every research finding in the documentation phase is explained and described precisely. The resulted of these evaluation findings will be analysed and documented in reports through certain methods.

**A. Proposed Architecture**

Figure 1 showed the general purpose of the system. This project was developed for monitored water levels and pH levels in real-time status. The project will be measured water level using an Ultrasonic sensor and measured pH level using a pH sensor connected to a microcontroller. The architecture started from the prototype, which is that all the data from both sensors will be sent to the NodeMCU to be analysed. The NodeMCU with built-in Wi-Fi will connect to the access point that has been configured to connect to the internet. The following process was continued in the HTTP API cloud server, and then the message was sent to a Telegram Bot API, which publishes it into a chatbot. Users then could easily monitor water conditions using the Telegram application on the phone or the computer.

![Diagram Description automatically generated](6118bc6fbd9ea_media/media/image1.png)

Figure 1: Automated Monitoring System for River Water Level and Water Quality Architecture

**B. Prototype Development**

Figure 2 showed that the schematic diagram that will be used in the project. For the prototype, NodeMCU ESP8266 version 3 will be used in this project as a microcontroller and as the component to transmit the data with its built-in wi-fi. Breadboard Power Supply Module will be used because NodeMCU only supplied 3.3V insist of 5V used by the sensor. The Ultrasonic sensor was used in the project for measured water level. Ultrasonic sensor transmitter will send the sound wave, and the receiver will act as a microphone to receive the echo from the sound wave. The distanced will be determined by measuring time lapses between the sending and receiving of the sound wave. Next, for water quality monitoring, a liquid pH sensor will be used for measured the pH level of water. LCD display was used to display the reading from ultrasonic sensor and pH sensor and the brightness of LCD will controlled by potentiometer.

For the source code, Arduino IDE software is used as a platform to write a code and uploaded the code to the microcontroller which is NodeMCU. The Telegram bot are created as a platform for the user to receive the information about the status of water level and pH level that also the user can access it from smartphone or computer.

![Diagram, schematic Description automatically generated](6118bc6fbd9ea_media/media/image2.jpeg)

Figure 2: Schematic diagram for the prototype

**EXPERIMENTAL RESULTS**

The system is evaluated by testing the performance of sensitivity prototype. This testing was conducted to see the output from the prototype through the LCD, and the result was sent to the telegram bot. The prototype supposed able to send the alert to the telegram bot when the water level exceeds the level set in the system and when the pH level was at alkali or acid level. The LCD would display the water level and the pH level with the status neutral, acid or alkali. Table 1 showed that the water monitoring system test result that conducted. The result showed that LCD display and Telegram bot has succeed to display a real-time reading from the ultrasonic sensor. The result also showed that the system was capable to send an alert to the user when the water level is exceeded above 11 cm that has been set in the system.

Table 1: water monitoring system push notification test result

<table>
<thead>
<tr class="header">
<th></th>
<th><blockquote>
<p><strong>Water Level (CM)</strong></p>
</blockquote></th>
<th><strong>LCD Display</strong></th>
<th><strong>Telegram Output</strong></th>
<th><strong>Resulted</strong></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><blockquote>
<p>1</p>
</blockquote></td>
<td><blockquote>
<p>4 CM</p>
</blockquote></td>
<td>Water Level: 4CM</td>
<td>Water Level: 8CM</td>
<td>success</td>
</tr>
<tr class="even">
<td><blockquote>
<p>2</p>
</blockquote></td>
<td><blockquote>
<p>8 CM</p>
</blockquote></td>
<td>Water Level: 8CM</td>
<td>Water Level: 4CM</td>
<td>success</td>
</tr>
<tr class="odd">
<td><blockquote>
<p>3</p>
</blockquote></td>
<td><blockquote>
<p>11 CM (Alert set)</p>
</blockquote></td>
<td>Flood Alert!!!</td>
<td><p>Danger water level!!!</p>
<p>Water level:11CM</p></td>
<td>success</td>
</tr>
<tr class="even">
<td><blockquote>
<p>4</p>
</blockquote></td>
<td><blockquote>
<p>17 CM</p>
</blockquote></td>
<td>Flood Alert!!!</td>
<td><p>Danger water level!!!</p>
<p>Water level:17CM</p></td>
<td>success</td>
</tr>
</tbody>
</table>

Figure 3 show the sample output from Telegram for water monitoring push notification. At the left in red highlighted, it showed the output system which was sent to the user. At the right in red highlighted, it showed the system was sending an alert to the user that the water is at the danger level.

![Graphical user interface, text, application, chat or text message Description automatically generated](6118bc6fbd9ea_media/media/image3.png)

Figure 3: output on the Telegram bot for water monitoring push notification

Table 2 showed the result from pH monitoring system test that had been conducted. An alert has been set if the pH level is below 6.5 and above 8.5. According to the Environmental Protection Agency (EPA) and World Health Organization (WHO), the acceptable pH range of drinking water is between 6.5 and 8.5. The system test successfully showed the LCD with the accurate real-time reading and successfully sent the information to Telegram user. The table also showed that the system success to send an alert when the pH level is below 6.5 or above 8.5 to the user.

Table 2: pH monitoring system push notification test result

<table>
<thead>
<tr class="header">
<th></th>
<th><blockquote>
<p><strong>PH Level</strong></p>
</blockquote></th>
<th><blockquote>
<p><strong>LCD Display</strong></p>
</blockquote></th>
<th><blockquote>
<p><strong>Telegram Output</strong></p>
</blockquote></th>
<th><blockquote>
<p><strong>Resulted</strong></p>
</blockquote></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td><blockquote>
<p>Vinegar</p>
</blockquote></td>
<td><blockquote>
<p>PH:2.55(Acid)</p>
</blockquote></td>
<td><blockquote>
<p>Water PH at Acidic level</p>
<p>PH:2.55</p>
</blockquote></td>
<td><blockquote>
<p>success</p>
</blockquote></td>
</tr>
<tr class="even">
<td>2</td>
<td><blockquote>
<p>Drink water</p>
</blockquote></td>
<td><blockquote>
<p>PH: 7.16(Normal)</p>
</blockquote></td>
<td><blockquote>
<p>PH: 7.16</p>
</blockquote></td>
<td><blockquote>
<p>success</p>
</blockquote></td>
</tr>
<tr class="odd">
<td>3</td>
<td><blockquote>
<p>Milk</p>
</blockquote></td>
<td><blockquote>
<p>PH: 6.95(Normal)</p>
</blockquote></td>
<td><blockquote>
<p>PH: 6.95</p>
</blockquote></td>
<td><blockquote>
<p>success</p>
</blockquote></td>
</tr>
<tr class="even">
<td>4</td>
<td><blockquote>
<p>Soap</p>
</blockquote></td>
<td><blockquote>
<p>PH:8.94(Alkali)</p>
</blockquote></td>
<td><blockquote>
<p>Water PH at Alkali level</p>
<p>PH:8.94</p>
</blockquote></td>
<td><blockquote>
<p>success</p>
</blockquote></td>
</tr>
</tbody>
</table>

Figure 5 showed that the system sent a real-time reading to the user. At the left in red highlighted, it showed the reading for the drinking water. At the right in red highlighted, it showed an alert that was sent from the system to the user because the pH is at the Alkali level.

> ![Graphical user interface, text, application, chat or text message Description automatically generated](6118bc6fbd9ea_media/media/image4.png)
> 
> Figure 4: output on a Telegram bot for pH monitoring push notification

**CONCLUSION**

The prototype system was successfully passed all the testing that had been conducted. The project's objective was successfully achieved which is to develop a system that could measure water level, and quality level of water and sent the information to the user using Telegram push notification features. The prototype succeeds all the tests that had been conducted. The reading of water level height used ultrasonic was accurate comparing to manual measurement. Using the pH sensor, the pH reading of different types of liquid could be obtained quickly and precisely. Although all the objectives had been fulfilled, this project had several limitations. Due to the covid-19 pandemic, the prototype system was not appropriately tested to the public or in real environment, where a face-to-face demo can’t be conducted. Instead, the demo was only shown to the respondents via video demonstration. For the future work, this system can be improved by testing the system in real environment so that the data collection can be more accurate more than the indoor simulation testing.

**REFERENCE**

Anton Prafanto, & Edy Budiman. (2019). A Water Level Detection: IoT Platform Based on Wireless Sensor Network. 2018 2nd East Indonesia Conference on Computer and Information Technology (EIConCIT), Makassar, Indonesia. https://doi.org/10.1109/EIConCIT.2018.8878559

L.Koval, Vaňuš, J., & Bilík, P. (2016). IFAC-PapersOnLine. Distance Measuring by Ultrasonic Sensor, 49(25), 153–158. https://doi.org/10.1016/j.ifacol.2016.12.026

Md.Tarikul Islam Juel, & Md. Sajid Ahmed. (2020, November). IoT Based Smart Watercraft System. 2020 IEEE Region 10 Symposium (TENSYMP), Dhaka, Bangladesh. https://doi.org/10.1109/TENSYMP50017.2020.9230992

Mohsen Nasirian. (2007). Journal of Applied Sciences. A New Water Quality Index for Environmental Contamination Contributed by Mineral Processing: A Case Study of Amang (Tin Tailing) Processing Activity, 7(20), 2977–2987. https://doi.org/10.3923/jas.2007.2977.2987

Mohammad Salah UddinChowdury, Talha Bin Emran, Subhasish Ghosh, Abhijit Pathak, Mohd. Manjur Alam, Nurul Absar, Karl Andersson, & Mohammad Shahadat Hossain. (2019). Procedia Computer Science. IoT Based Real-Time River Water Quality Monitoring System, 155, 161–168. https://doi.org/10.1016/j.procs.2019.08.025

Natividad, J. G., & Mendez, J. M. (2017, November). Flood Monitoring and Early Warning System Using Ultrasonic Sensor. International Conference on Information Technology and Digital Applications (ICITDA 2017), Yogyakarta, Indonesia. https://doi.org/10.1088/1757-899X/325/1/012020

Rafia Afroz, & Ataur Rahman. (2017). International Journal of Advanced and Applied Sciences. Health Impact of River Water Pollution in Malaysia, 4(5), 78–85. <https://doi.org/10.21833/ijaas>. 2017.05.014

Teddy Mantoro, & Wirawan Istiono. (2018). 2017 Second International Conference on Informatics and Computing (ICIC). 2017 Second International Conference on Informatics and Computing (ICIC), Jayapura, Indonesia. https://doi.org/10.1109/IAC.2017.8280602

Tarek Mohammad. (2009). Using Ultrasonic and Infrared Sensors for Distance Measurement. World Academy of Science, Engineering and Technology, Hong Kong.
