IoT-Based Water Quality Monitoring System Using ESP32 and K-Nearest Neighbor Algorithm - Fiqri Rizaldi Azlin Hasibuan; Man Vredus Zalukhu; Della Agnesia Simamora; Muhammad Irfan Fahmi (Journal of Artificial Intelligence and Software Engineering, 2026)
Conventional water monitoring is often time-consuming and hinders decision-making. Amidst IoT advancements, few systems feature automatic correction mechanisms. This study develops an IoT-based water monitoring system to read pH, temperature, and turbidity in real-time. The NodeMCU ESP32 is used as the main microcontroller connected to pH, DS18B20, and turbidity sensors. Data is collected every 15 minutes, uploaded to Firebase via Wi-Fi, and visualized on a web dashboard. The system implements the K-Nearest Neighbor (K-NN) algorithm with Euclidean Distance to categorize water as good, moderate, or poor. This result triggers an automatic pH-balancing pump actuator if the value falls outside the normal range (6.5–8.5). This laboratory-scale prototype proves that the synergy of ESP32, Firebase, and K-NN overcomes the weaknesses of manual methods, resulting in accurate, efficient, and sustainable water monitoring.