IoT-Based Home Electricity Monitoring and Consumption Forecasting using k-NN Regression for Efficient Energy Management
DOI:
https://doi.org/10.62411/jcta.13602Keywords:
Data mining, Internet of Things, k-NN algorithm, Prediction, SensorsAbstract
Electricity has emerged as an essential requirement in modern life. As demand escalates, electricity costs rise, making wastefulness a drain on financial resources. Consequently, forecasting electricity usage can enhance our management of consumption. This study presents an IoT-based monitoring and forecasting system for electricity consumption. The system comprises two NodeMCU micro-controllers, a PZEM-004T sensor for collecting real-time power data, and three relays that regulate the current flow to three distinct electrical appliances. The data gathered is transmitted to a web application utilizing the k-Nearest Neighbor (k-NN) algorithm to forecast future electricity usage based on historical patterns. We evaluated the system's performance using four weeks of electricity consumption data. The results indicated that predictions were most accurate when the user’s daily consumption pattern remained stable, achieving a Mean Absolute Error (MAE) of approximately 1 watt and a Mean Absolute Percentage Error (MAPE) ranging from 1% to 1.7%. Additionally, predictions were notably precise during the early morning hours (3:00 AM to 8:00 AM) when k=6 was employed. This study demonstrates the effectiveness of integrating IoT-based systems with machine learning for real-time energy monitoring and forecasting. Furthermore, it emphasizes the application of data mining techniques within embedded IoT environments, providing valuable insights into the implementation of lightweight machine learning for smart energy systems.References
Ministry of Energy and Mineral Resources Republic of Indonesia, Handbook of Energy & Economic Statistics of Indonesia 2021. 2021. [Online]. Available: https://www.esdm.go.id/assets/media/content/content-handbook-of-energy-and-economic-statistics-of-indonesia-2021.pdf
I. Rafiq, A. Mahmood, S. Razzaq, S. H. M. Jafri, and I. Aziz, “IoT applications and challenges in smart cities and services,” J. Eng., vol. 2023, no. 4, Apr. 2023, doi: 10.1049/tje2.12262.
S. Pallavi, J. D. Mallapur, and K. Y. Bendigeri, “Remote sensing and controlling of greenhouse agriculture parameters based on IoT,” in 2017 International Conference on Big Data, IoT and Data Science (BID), Dec. 2017, pp. 44–48. doi: 10.1109/BID.2017.8336571.
F. Meneghello, M. Calore, D. Zucchetto, M. Polese, and A. Zanella, “IoT: Internet of Threats? A Survey of Practical Security Vul-nerabilities in Real IoT Devices,” IEEE Internet Things J., vol. 6, no. 5, pp. 8182–8201, Oct. 2019, doi: 10.1109/JIOT.2019.2935189.
F. Wu, T. Wu, and M. R. Yuce, “Design and Implementation of a Wearable Sensor Network System for IoT-Connected Safety and Health Applications,” in 2019 IEEE 5th World Forum on Internet of Things (WF-IoT), Apr. 2019, pp. 87–90. doi: 10.1109/WF-IoT.2019.8767280.
A. Shi‐Nash and D. R. Hardoon, “Data Analytics and Predictive Analytics in the Era of Big Data,” in Internet of Things and Data Analytics Handbook, Wiley, 2017, pp. 329–345. doi: 10.1002/9781119173601.ch19.
C. C. Aggarwal, Data Mining. Cham: Springer International Publishing, 2015. doi: 10.1007/978-3-319-14142-8.
N. Afshan and R. K. Rout, “Machine Learning Techniques for IoT Data Analytics,” in Big Data Analytics for Internet of Things, Wiley, 2021, pp. 89–113. doi: 10.1002/9781119740780.ch3.
L. Wu, J. Leng, and S. Wu, “Intelligent Perception and Data Mining Technology of City Information Modeling CIM in Urban Renewal,” in 2024 3rd International Conference on Data Analytics, Computing and Artificial Intelligence (ICDACAI), Oct. 2024, pp. 627–632. doi: 10.1109/ICDACAI65086.2024.00120.
L. Sitanayah, A. Angdresey, and E. Kristalino, “A Real-Time Application for Road Conditions Detection based on the Internet of Things,” JOIV Int. J. Informatics Vis., vol. 6, no. 3, p. 629, Sep. 2022, doi: 10.30630/joiv.6.2.891.
L. Sitanayah, A. Angdresey, and E. Kristalino, “A sensor-based application for road conditions detection,” in Proceedings of the 18th Conference on Embedded Networked Sensor Systems, Nov. 2020, pp. 651–652. doi: 10.1145/3384419.3430437.
L. Sitanayah, A. Angdresey, and J. W. Utama, “A Low Cost Vehicle Counting System Based On The Internet of Things,” EPI Int. J. Eng., vol. 4, no. 1, pp. 14–20, Sep. 2021, doi: 10.25042/epi-ije.022021.03.
L. Sitanayah, A. Angdresey, and J. W. Utama, “An Internet of Things-based Vehicle Counting System,” in Proceedings of the 2021 International Conference on Embedded Wireless Systems and Networks, 2021, pp. 175–176. doi: 10.5555/3451271.3451292.
M. A. Araaf, K. Nugroho, and D. R. I. M. Setiadi, “Comprehensive Analysis and Classification of Skin Diseases based on Image Texture Features using K-Nearest Neighbors Algorithm,” J. Comput. Theor. Appl., vol. 1, no. 1, pp. 31–40, Sep. 2023, doi: 10.33633/jcta.v1i1.9185.
E. Brilliandy, H. Lucky, A. Hartanto, D. Suhartono, and M. Nurzaki, “Using Regression to Predict Number of Tourism in Indonesia based of Global COVID-19 Cases,” in 2022 3rd International Conference on Artificial Intelligence and Data Sciences (AiDAS), Sep. 2022, pp. 310–315. doi: 10.1109/AiDAS56890.2022.9918731.
C. C, “Prediction of Heart Disease using Different KNN Classifier,” in 2021 5th International Conference on Intelligent Computing and Control Systems (ICICCS), May 2021, pp. 1186–1194. doi: 10.1109/ICICCS51141.2021.9432178.
Q. Yunneng, “A new stock price prediction model based on improved KNN,” in 2020 7th International Conference on Information Science and Control Engineering (ICISCE), Dec. 2020, pp. 77–80. doi: 10.1109/ICISCE50968.2020.00026.
J. A. Ingio, A. S. Nsang, and A. Iorliam, “Optimizing Rice Production Forecasting Through Integrating Multiple Linear Regression with Recursive Feature Elimination,” J. Futur. Artif. Intell. Technol., vol. 1, no. 2, pp. 96–108, Aug. 2024, doi: 10.62411/faith.2024-17.
I. W. A. Suranata, I. N. K. Wardana, N. Jawas, and I. K. A. A. Aryanto, “Feature engineering and long short-term memory for energy use of appliances prediction,” TELKOMNIKA (Telecommunication Comput. Electron. Control., vol. 19, no. 3, p. 920, Jun. 2021, doi: 10.12928/telkomnika.v19i3.17882.
A. Angdresey, L. Sitanayah, and Z. M. P. Rumpesak, “An Electricity Consumption Monitoring and Prediction System Based on The Internet of Things,” in 2022 Seventh International Conference on Informatics and Computing (ICIC), Dec. 2022, pp. 1–6. doi: 10.1109/ICIC56845.2022.10007020.
A. Angdresey and J.-Q. Ooi, “Analyzing Multimodal Sensory Signals Using Unsupervised Machine Learning,” in 2023 International Conference on Computer, Control, Informatics and its Applications (IC3INA), Oct. 2023, pp. 301–306. doi: 10.1109/IC3INA60834.2023.10285741.
M. Weyrich and C. Ebert, “Reference Architectures for the Internet of Things,” IEEE Softw., vol. 33, no. 1, pp. 112–116, Jan. 2016, doi: 10.1109/MS.2016.20.
K. V. Sahukara, M. B. Ammisetty, G. S. K. G. Devi, S. Prathyusha, and T. S. Nikhita, “COVID-SAFE: IoT Based Health Monitoring System using RFID in Pandemic Life,” in 2021 IEEE International Conference on RFID Technology and Applications (RFID-TA), Oct. 2021, pp. 203–206. doi: 10.1109/RFID-TA53372.2021.9617312.
N. Alsbou, D. Price, and I. Ali, “IoT-Based Smart Hospital using Cisco Packet Tracer Analysis,” in 2022 IEEE International IOT, Electronics and Mechatronics Conference (IEMTRONICS), Jun. 2022, pp. 1–6. doi: 10.1109/IEMTRONICS55184.2022.9795743.
Y. Lu, J. An, and S. Shi, “Research on Smart Agriculture IoT System Based Heterogeneous Networking Technology,” in 2021 IEEE 4th International Conference on Information Systems and Computer Aided Education (ICISCAE), Sep. 2021, pp. 485–488. doi: 10.1109/ICISCAE52414.2021.9590756.
J. Baiense, E. Zdravevski, P. Coelho, I. M. Pires, and F. J. Velez, “Driving Healthcare Monitoring with IoT and Wearable Devices: A Systematic Review,” ACM Comput. Surv., vol. 57, no. 11, pp. 1–38, Nov. 2025, doi: 10.1145/3731595.
A. Angdresey, I. V. Masala, V. D. Kumenap, M. G. Sumampouw, K. A. Dame, and I. D. R. Riady, “A Communication Assistant Application for the Deaf,” in 2021 Sixth International Conference on Informatics and Computing (ICIC), Nov. 2021, pp. 1–6. doi: 10.1109/ICIC54025.2021.9633011.
K. R. Senthil, J. B, S. B, and N. T, “A Novel System For Blind, Deaf And Dumb People Assistant Using Raspberry Pi,” in 2022 IEEE North Karnataka Subsection Flagship International Conference (NKCon), Nov. 2022, pp. 1–6. doi: 10.1109/NKCon56289.2022.10126949.
L. Sitanayah, H. R. M. Joseph, and J. B. Sanger, “A Low-Cost Hydroponic Monitoring System with Internet of Things and Fuzzy Logic,” J. Comput. Theor. Appl., vol. 2, no. 3, pp. 441–455, Feb. 2025, doi: 10.62411/jcta.12059.
A. C. Onal, O. Berat Sezer, M. Ozbayoglu, and E. Dogdu, “Weather data analysis and sensor fault detection using an extended IoT framework with semantics, big data, and machine learning,” in 2017 IEEE International Conference on Big Data (Big Data), Dec. 2017, pp. 2037–2046. doi: 10.1109/BigData.2017.8258150.
L. Zhang, J. Zhang, Y. Chen, and S. Lao, “Hybrid Intrusion Detection Based on Data Mining,” in 2018 11th International Conference on Intelligent Computation Technology and Automation (ICICTA), Sep. 2018, pp. 299–301. doi: 10.1109/ICICTA.2018.00074.
A. Aneja, S. Sharma, P. Thapar, and S. Tiwari, “Optimizing Network Intrusion Detection with Hybrid DTRJ Model: A Data Mining Approach,” in 2024 International Conference on Electrical Electronics and Computing Technologies (ICEECT), Aug. 2024, pp. 1–5. doi: 10.1109/ICEECT61758.2024.10739005.
J. P. Ntayagabiri, Y. Bentaleb, J. Ndikumagenge, and H. El Makhtoum, “OMIC: A Bagging-Based Ensemble Learning Framework for Large-Scale IoT Intrusion Detection,” J. Futur. Artif. Intell. Technol., vol. 1, no. 4, pp. 401–416, Feb. 2025, doi: 10.62411/faith.3048-3719-63.
K. Cao, J. Wu, Q. Huang, and Y. Gan, “Optimization Study of KNN Classification Algorithm on Large-Scale Datasets: Real-Time Optimization Strategy Based on Balanced KD Tree and Multi-threaded Parallel Computing,” in 2023 4th International Conference on Intelligent Computing and Human-Computer Interaction (ICHCI), Aug. 2023, pp. 423–427. doi: 10.1109/ICHCI58871.2023.10277807.
S. Zhang, X. Li, M. Zong, X. Zhu, and R. Wang, “Efficient kNN Classification With Different Numbers of Nearest Neighbors,” IEEE Trans. Neural Networks Learn. Syst., vol. 29, no. 5, pp. 1774–1785, May 2018, doi: 10.1109/TNNLS.2017.2673241.
S. Allogba and C. Tremblay, “K-Nearest Neighbors Classifier for Field Bit Error Rate Data,” in 2018 Asia Communications and Pho-tonics Conference (ACP), Oct. 2018, pp. 1–3. doi: 10.1109/ACP.2018.8596133.
T. Van Nguyen, “Electricity Generation Cost Optimization Based on Lagrange Function and Local Search,” J. Comput. Theor. Appl., vol. 1, no. 2, pp. 104–114, Nov. 2023, doi: 10.33633/jcta.v1i2.9354.
N. K. Mon, “Optimizing Cloud Computing Performance by Integrating the Novel PSBR Service Broker Policy and Load Balancing Algorithms,” J. Comput. Theor. Appl., vol. 2, no. 2, pp. 212–221, Oct. 2024, doi: 10.62411/jcta.11221.
Y. Yin, L. Long, and X. Deng, “Dynamic Data Mining of Sensor Data,” IEEE Access, vol. 8, pp. 41637–41648, 2020, doi: 10.1109/ACCESS.2020.2976699.
M. Shakir and N. Rakesh., “Investigation on Air Pollutant Data Sets using Data Mining Tool,” in 2018 2nd International Conference on I-SMAC (IoT in Social, Mobile, Analytics and Cloud) (I-SMAC)I-SMAC (IoT in Social, Mobile, Analytics and Cloud) (I-SMAC), 2018 2nd International Conference on, Aug. 2018, pp. 480–485. doi: 10.1109/I-SMAC.2018.8653757.
A. Angdresey, L. Sitanayah, T. V. N. Kairupan, and T. M. I. Sumajow, “Implementation of the C4.5 Algorithm in the Internet of Things Applications,” 2024, pp. 53–74. doi: 10.1007/978-3-031-47590-0_4.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Apriandy Angdresey, Lanny Sitanayah, Zefanya Marieke Philia Rumpesak, Jing-Quan Ooi

This work is licensed under a Creative Commons Attribution 4.0 International License.













