Wireless Sensor Networks (WSNs) have been adopted in various environmental pollution monitoring applications. As an important environmental field, water quality monitoring is a vital process to ensure the sustainable, important feeding of and as a life-maintaining source for many living creatures. To conduct this process efficiently, the integration of lightweight machine learning technologies can extend its efficacy and accuracy. WSNs often suffer from energy-limited devices and resource-affected operations, thus constraining WSNs’ lifetime and capability. Energy-efficient clustering protocols have been introduced to tackle this challenge. The low-energy adaptive clustering hierarchy (LEACH) protocol is widely used due to its simplicity and ability to manage large datasets and prolong network lifetime. In this paper, we investigate and present a modified LEACH-based clustering algorithm in conjunction with a K-means data clustering approach to enable efficient decision making based on water-quality-monitoring-related operations. This study is operated based on the experimental measurements of lanthanide oxide nanoparticles, selected as cerium oxide nanoparticles (ceria NPs), as an active sensing host for the optical detection of hydrogen peroxide pollutants via a fluorescence quenching mechanism. A mathematical model is proposed for the K-means LEACH-based clustering algorithm for WSNs to analyze the quality monitoring process in water, where various levels of pollutants exist. The simulation results show the efficacy of our modified K-means-based hierarchical data clustering and routing in prolonging network lifetime when operated in static and dynamic contexts.