A TinyML model for real-time water quality monitoring in resource-constrained distribution networks
Abstract
Access to clean and safe water remains a concern, particularly in Africa, where limited resources and monitoring challenges affect water quality management. Traditional monitoring depends on laboratory analysis of collected samples, making the process time-consuming, costly, and dependent on trained personnel and specialised equipment. Although Internet of Things (IoT) and machine learning (ML) technologies enable real-time monitoring, many existing solutions depend on cloud connectivity and computational resources, limiting their application in rural environments. This study developed a low-cost, real-time water quality monitoring system integrating IoT sensing with Tiny Machine Learning (TinyML) for on-device intelligence. Sensors measuring pH, turbidity, temperature, and total dissolved solids collected 100,800 observations from water sources across Kenya. Artificial Neural Network (ANN), Random Forest, Support Vector Machine, and Gradient Boosting models were evaluated. The ANN was selected and optimised using quantisation and TensorFlow Lite Micro for microcontroller deployment. The optimised TinyML model achieved 92.55% accuracy, compared with 94.2% before optimisation, while reducing RAM by 55% and ROM by 60% and achieving 1 ms inference latency. Validation against 30 laboratory-tested samples showed 99% classification agreement, demonstrating the feasibility of low-cost, real-time edge-based water quality monitoring under intermittent connectivity.