K-Nearest Neighbor Algorithm for Intelligent Monitoring and Control System Integration in Renewable Energy Applications
DOI:
https://doi.org/10.31961/eltikom.v9i2.1565Keywords:
biogas monitoring, IoT, k-nearest neighbor, methane prediction, predictive controlAbstract
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.
Downloads
References
[1] M. Wahyu Kurniawati, A. Nur Rizkia Putri, and C. Firdaus Ivana, “Pemanfaatan limbah sayur dan kotoran sapi sebagai sumber energi terbarukan vegetable waste and cow dung utilization as a renewable energy source.” [Online]. Available: https://ejournal.pnc.ac.id/index.php/jppl
[2] A. Putri, M. G. Gumay, and A. Pemanfaatan, “Konferensi Nasional Sistem Informasi 2018 STMIK Atma Luhur Pangkalpinang,” 2018.
[3] A. Amalia et al., “Prediksi kualitas udara menggunakan algoritma k-nearest neighbor.” [Online]. Available: https://data.jakarta.go.id/.
[4] Zhang, Y., Li, Y., & Wang, X. (2020). Application of K-Nearest Neighbors Algorithm in Biogas Prediction. Renewable Energy, 145, 1234-1240. DOI: 10.1016/j.renene.2019.06.015.
[5] M. Junus, D. F. Putradi, F. A. Soelistianto, M. A. Anshori, and R. Ardiansyah, “Internet of things enabled landfill pollution gas monitoring,” Indonesian Journal of Electrical Engineering and Computer Science, vol. 37, no. 1, pp. 48–55, Jan. 2025, doi: 10.11591/ijeecs.v37.i1.pp48-55.
[6] R. Nurfarida Mukti, A. Salsabilla, A. Salsabila Muamar, E. Cahya Prima, and M. Nurul Hana, “Biogas effectiveness test from household waste (vegetable waste) with cow dung starter and em4 indonesian journal of multidiciplinary research,” Indonesian Journal of Multidiciplinary Research, vol. 1, no. 1, pp. 73–78, 2021, doi: 10.17509/xxxx.vxix.
[7] H. Setyawati, S. A. Sari, D. Nathania, and N. Zahwa, “The effect of variations of vegetable solid waste types (cabbage, mustard, lettuce) and em4 levels on composting with fermentation process.”
[8] Medilla Kusriyanto, “Rancang bangun kendali suhu dan tekanan pada ekstraktor soxhlet terintegrasi pembatas waktu ekstraksi menggunakan mikrokontroller atmega 16,” Journal of Islamic University of Indonesia, vol. Vol.19, No.1, 2013, doi: https://doi.org/10.20885/.v19i1.4408.
[9] Y. Zaky Jacoeb, R. Yasirandi, and M. M. Qusyairi, “Implementasi teknologi dan proses produksi biogas sebagai pengendalian limbah di area RRA,” e-Proceeding of Engineering, vol. Vol.12, No.1, Feb. 2025.
[10] . S., “Sistem kendali dan monitoring kelembapan, suhu, dan ph pada proses dekomposisi pupuk kompos dengan kendali logika fuzzy,” Telekontran : Jurnal Ilmiah Telekomunikasi, Kendali dan Elektronika Terapan, vol. 8, no. 2, pp. 154–164, Apr. 2021, doi: 10.34010/telekontran.v8i2.4710.
[11] K. Diantoro, R. Rahmadewi, J. Teknik Elektro Universitas Singaperbangsa Karawang, and K. H. Jl Ronggowaluyo Telukjambe Timur -Karawang, “Implementasi sensor MQ 4 dan sensor DHT 22 pada sistem kompos pintar berbasis IoT (SIKOMPI).”
[12] R. E. Putri, I. P. Maharani, and I. Putri, “Real-time monitoring system for temperature, humidity, and ph for composting process,” Jurnal Teknik Pertanian Lampung (Journal of Agricultural Engineering), vol. 14, no. 2, p. 380, Mar. 2025, doi: 10.23960/jtep-l.v14i2.380-390.
[13] M. Junus, S. Wahyudi, and C. Author, “Technoeconomic study of hybrid energy systems for use in public buildings in Malang, Indonesia,” 2021.
[14] R. F. Karunia Dewi, Obert, and R. Gusmana, “Implementasi metode K-Nearest Neighbor (KNN) dalam pengelompokan status ekonomi warga,” Journal of Big Data Analytic and Artificial Intelligence, vol. Vol. 4, No. 1, 2018.
[15] M. M. Baharuddin, H. Azis, and T. Hasanuddin, “Analisis performa metode k-nearest neighbor untuk identifikasi jenis kaca,” ILKOM Jurnal Ilmiah, vol. 11, no. 3, pp. 269–274, Dec. 2019, doi: 10.33096/ilkom.v11i3.489.269-274.
[16] E. Purnama Dewi, J. Sumarsono, and I. Gusti Made Kompyang, “Pengembangan akuisisi data pada sistem pemantauan biogas berbasis IoT development of data acquisition biogas monitoring system based on IoT,” vol. 11, no. 1, p. 2024.
[17] B. R. Japutra, S. A. C. Luthfi, B. Handoko, and M. Rayhan, “Pemanfaatan kotoran ternak dengan penambahan limbah pasar sebagai energi alternatif untuk pembangkit listrik tenaga biogas di desa Sibrama Kabupaten Banyumas,” Jurnal Abdi Masyarakat Indonesia, vol. 4, no. 4, pp. 769–776, Jun. 2024, doi: 10.54082/jamsi.1169.
[18] A. A. Nur Rohman, R. Hidayat, and F. Rizky Ramadhan, “Pemrograman mesin smart bartender menggunakan software arduino ide berbasis microcontroller ATmega2560,” Prosiding Seminar Nasional Teknik Elektro, 2021.
[19] M. Mungkin, H. Satria, J. Yanti, and G. A. Boni Turnip, “Perancangan sistem pemantauan panel surya polycrystalline menggunakan teknologi web firebase berbasis iot polycrystalline solar panel monitoring system design using iot-based firebase web technology,” Journal of Information Technology and Computer Science (INTECOMS), vol. 3, no. 2, 2020.
[20] A. Refalista et al., “Pengunaan sensor MQ-2,4,7,135 dan ESP32 untuk air pollution monitoring berbasis internet of things,” Jurnal TICOM: Technology of Information and Communication, vol. 12, no. 1, 2023.
[21] L. Nurdini, R. D. Amanah, and A. N. Utami, “Prosiding seminar nasional teknik kimia ‘kejuangan’ pengolahan limbah sayur kol menjadi pupuk kompos dengan metode takakura”.
[22] O. K. Wardani, R. T. W. Broto, F. Arifan, J. P. Sudarto, K. Semarang, and J. Tengah, “Pembuatan mikroorganisme lokal berbasis limbah organik sebagai aktivator kompos di desa sikunang, kecamatan kejajar, kabupaten wonosobo,” Oktober, 2021.
[23] M. Junus, Marjono, Aulanni’am, and S. Wahyudi, “Modelling, simulation, and enhancement of hybrid renewable energy systems for purification utilization,” International Energy Journal 23 (June 2023) 71 – 82, 2023.
[24] A. Z. M. Badruddin, M. A. Al-Ghamdi, and F. N. Ani, “Application of K-nearest neighbors (KNN) machine learning for prediction of biogas production,” Bioresource Technology, vol. 390, p. 129708, Apr. 2024, doi: 10.1016/j.biortech.2024.129708.
[25] P. S. Arul et al., “Low-cost methane and hydrogen gas sensor system for safety monitoring in industrial environments,” Sensors and Actuators Reports, vol. 2, no. 1, p. 100032, Mar. 2020, doi: 10.1016/j.snr.2020.100032.
[26] M. Rajasekar, A. Kumaravel, and N. Nallusamy, “Design and implementation of an IoT based low-cost portable biogas analyzer,” Renewable Energy, vol. 138, pp. 460–469, Aug. 2019, doi: 10.1016/j.renene.2019.01.099.
[27] T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd ed. New York: Springer, 2009.
[28] L. Breiman, “Random forests,” Machine Learning, vol. 45, no. 1, pp. 5–32, 2001, doi: 10.1023/A:1010933404324.
[29] J. H. Friedman, “Greedy function approximation: A gradient boosting machine,” Annals of Statistics, vol. 29, no. 5, pp. 1189–1232, 2001, doi: 10.1214/aos/1013203451.
[30] J. Demšar, “Statistical comparisons of classifiers over multiple data sets,” Journal of Machine Learning Research, vol. 7, pp. 1–30, Jan. 2006.
[31] A. M. Arifin, S. P. Putra, and T. W. Wibowo, “Comparison of machine learning algorithms for prediction of methane gas production in anaerobic digestion,” International Journal of Renewable Energy Development, vol. 11, no. 2, pp. 389–399, 2022, doi: 10.14710/ijred.2022.42945.
[32] Z. Wang, Y. Zhang, L. Yang, and H. Chen, “Methane production from anaerobic digestion of food waste: A review focusing on the role of pH and microbial community,” Bioresource Technology, vol. 341, p. 125795, 2021, doi: 10.1016/j.biortech.2021.125795.
[33] J. Zhang, H. Chen, Q. Huang, and D. Chen, “Effect of pH control on anaerobic digestion of kitchen waste for biogas production,” International Biodeterioration & Biodegradation, vol. 105, pp. 153–159, 2015, doi: 10.1016/j.ibiod.2015.09.010.
[34] A. K. Singh and D. K. Tiwari, “Impact of operational parameters on biogas production from biomass: A review,” Energy Sources, Part A: Recovery, Utilization, and Environmental Effects, vol. 43, no. 4, pp. 463–481, 2021, doi: 10.1080/15567036.2019.1618984.
[35] H. Kumar, S. K. Sharma, and R. S. Dhillon, “Internet of Things (IoT) based smart biogas plant monitoring and controlling system,” Materials Today: Proceedings, vol. 49, pp. 276–281, 2022, doi: 10.1016/j.matpr.2021.07.168.
[36] S. K. Raut, M. M. Rahman, and M. M. Hassan, “IoT-based methane gas detection and automatic control system for biogas plants,” Sensors, vol. 21, no. 12, p. 4201, 2021, doi: 10.3390/s21124201.
[37] S. Mandal, S. Dutta, and P. Banerjee, “Low-Cost IoT-Based Biogas Plant Monitoring System,” International Journal of Renewable Energy Research, vol. 12, no. 3, pp. 1158–1167, 2022.
[38] M. Ahmad, A. Latif, and R. M. Noor, “Economic Analysis of Biogas Production for Rural Electrification,” Renewable Energy, vol. 182, pp. 456–466, 2022.
[39] B. P. Singh and P. Kumar, “Performance Evaluation of Biogas Plants Under Different Feedstocks and Environmental Conditions,” Energy for Sustainable Development, vol. 65, pp. 12–21, 2021.
[40] Y. Zhang, L. Wang, and X. Li, “Adaptive Machine Learning Models for Environmental Prediction in IoT Systems,” IEEE Internet of Things Journal, vol. 9, no. 15, pp. 13827–13837, 2022.
Downloads
Published
Issue
Section
License
Copyright (c) 2025 Mochammad Junus, Laily Nur Fa‘izah, Mohd Noor, Indra Lukmana Putra

This work is licensed under a Creative Commons Attribution 4.0 International License.
All accepted papers will be published under a Creative Commons Attribution 4.0 International (CC BY 4.0) License. Authors retain copyright and grant the journal right of first publication. CC-BY Licenced means lets others to Share (copy and redistribute the material in any medium or format) and Adapt (remix, transform, and build upon the material for any purpose, even commercially).

