A real-time biogas monitoring and control system was developed by integrating the K-Nearest Neighbor (KNN) algorithm into an IoT-based framework for methane pressure prediction and automated control. The system uses an ESP32 microcontroller connected to temperature, gas, and pressure sensors (DHT22, MQ-4, MPX5700) to continuously collect data, with cloud connectivity provided through Firebase and Blynk platforms. The predictive model operates within a live feedback loop, allowing immediate actuation based on forecasted methane conditions. With an optimal parameter of k=4, the KNN model achieved 93.33% accuracy, supported by a mean absolute error (MAE) of 0.18 and a root mean square error (RMSE) of 0.21. A comparative evaluation with Random Forest and Gradient Boosting algorithms showed that, although these models yielded slightly higher accuracy, KNN provided superior computational effi-ciency for embedded deployment. The system maintained stable operation during tests involving sensor anomalies, network interruptions, and data noise. However, redundancy mechanisms and improved vali-dation strategies are recommended to enhance robustness. The findings demonstrate that methane pro-duction can be effectively predicted using temperature and pressure data, with further accuracy im-provements possible through additional process variables such as pH and fermentation age.
Copyrights © 2025