Implementation of On-Device Convolutional Neural Network Inference for Indoor Occupancy Detection on the ESP32-S3

Authors

  • Ade Aditya Ramadha Telecommunication Engineering Study Program, School of Electrical Engineering, Telkom University
  • Felix Corputty Telecommunication Engineering Study Program, School of Electrical Engineering, Telkom University
  • Naufal Hanan Lutfianto Telecommunication Engineering Study Program, School of Electrical Engineering, Telkom University

DOI:

https://doi.org/10.33019/

Keywords:

Convolutional Neural Network, Edge Computing, ESP32-S3, INT8 Quantization, Occupancy Detection

Abstract

Indoor occupancy detection is a key enabling technology for energy-efficient smart building management, as heating, ventilation, air conditioning, and lighting systems waste significant energy when conditioned spaces are unoccupied. This paper implements a compact Convolutional Neural Network (CNN) trained on the UCI Occupancy Detection Dataset and deployed entirely on the ESP32-S3 microcontroller using TensorFlow Lite Micro with INT8 post-training quantization, eliminating any cloud dependency. Models are trained under a leakage-controlled protocol on the designated training file, selected on the first test file, and evaluated on the held-out second test file; the INT8 quantizer is calibrated from an evenly spaced spread of training windows to avoid class bias. Twelve configurations spanning four filter capacities, (F₁,F₂) ∈ {(4,8),(8,16),(16,32),(32,64)}, and three temporal window lengths, W ∈ {15,30,60} minutes, are quantized, flashed, and measured on the device for tensor arena, flash footprint, inference latency, and held-out F1. All twelve configurations execute successfully: the best compact model, CNN(8,16) at  fifteen-minute window, reaches a held-out F1 of 0.959 using 4.2 KB of tensor arena and 1.24 ms per inference, with more than 320 KB of heap remaining free; the tensor arena across the full grid stays between 2.6 and 30 KB; and INT8 quantization changes F1 by at most ±0.021 relative to the floating-point baseline. These results demonstrate that on-device CNN occupancy detection is practical on  low-cost microcontroller, that a compact two-block architecture is sufficient to reach near-optimal accuracy, and that the full pipeline from leak-free training through representative INT8 calibration to on-device measurement is reproducible.

Downloads

Download data is not yet available.

References

[1] L. M. Candanedo and V. Feldheim, “Accurate occupancy detection of an office room from light, temperature, humidity and CO₂ measurements using statistical learning models,” Energy Build., vol. 112, pp. 28–39, 2016. doi: 10.1016/j.enbuild.2015.11.071

[2] P. Chaudhari, Y. Xiao, M. M.-C. Cheng, and T. Li, “Fundamentals, algorithms, and technologies of occupancy detection for smart buildings using IoT sensors,” Sensors, vol. 24, no. 7, p. 2123, 2024. doi: 10.3390/s24072123

[3] W. Shi, J. Cao, Q. Zhang, Y. Li, and L. Xu, “Edge computing: Vision and challenges,” IEEE Internet Things J., vol. 3, no. 5, pp. 637–646, 2016. doi: 10.1109/JIOT.2016.2579198

[4] W. Shi and S. Dustdar, “The promise of edge computing,” Computer, vol. 49, no. 5, pp. 78–81, 2016. doi: 10.1109/MC.2016.145

[5] S. Deng, H. Zhao, W. Fang, J. Yin, S. Dustdar, and A. Y. Zomaya, “Edge intelligence: The confluence of edge computing and artificial intelligence,” IEEE Internet Things J., vol. 7, no. 8, pp. 7457–7469, 2020. doi: 10.1109/JIOT.2020.2984887

[6] H. Choi, C. Y. Um, K. Kang, H. Kim, and T. Kim, “Application of vision-based occupancy counting method using deep learning and performance analysis,” Energy Build., vol. 252, art. no. 111389, 2021. doi: 10.1016/j.enbuild.2021.111389

[7] P. Warden and D. Situnayake, TinyML: Machine Learning with TensorFlow Lite on Arduino and Ultra-Low-Power Microcontrollers. Sebastopol, CA: O’Reilly Media, 2019.

[8] R. Sanchez-Iborra and A. F. Skarmeta, “TinyML-enabled frugal smart objects: Challenges and opportunities,” IEEE Circuits Syst. Mag., vol. 20, no. 3, pp. 4–18, 2020. doi: 10.1109/MCAS.2020.3005467

[9] P. P. Ray, “A review on TinyML: State-of-the-art and prospects,” J. King Saud Univ. Comput. Inf. Sci., vol. 34, no. 4, pp. 1595–1623, 2022. doi: 10.1016/j.jksuci.2021.11.019

[10] A. Elhanashi, P. Dini, S. Saponara, and Q. Zheng, “Advancements in TinyML: Applications, limitations, and impact on IoT devices,” Electronics, vol. 13, no. 17, p. 3562, 2024. doi: 10.3390/electronics13173562

[11] N. N. Alajlan and D. M. Ibrahim, “TinyML: Enabling of inference deep learning models on ultra-low-power IoT edge devices for AI applications,” Micromachines, vol. 13, no. 6, p. 851, 2022. doi: 10.3390/mi13060851

[12] Y. Abadade, A. Temouden, H. Bamoumen, N. Benamar, Y. Chtouki, and A. S. Hafid, “A comprehensive survey on TinyML,” IEEE Access, vol. 11, pp. 96892–96922, 2023. doi: 10.1109/ACCESS.2023.3294111

[13] Espressif Systems, ESP32-S3 Technical Reference Manual, ver. 0.4, 2023.

[14] R. David et al., “TensorFlow Lite Micro: Embedded machine learning on TinyML systems,” in Proc. 4th MLSys Conf., pp. 800–811, 2021.

[15] C. Banbury et al., “MLPerf Tiny benchmark,” in Proc. NeurIPS 2021 Track Datasets Benchmarks, 2021.

[16] A. Osman, U. Abid, L. Gemma, M. Perotto, and D. Brunelli, “TinyML platforms benchmarking,” in ApplePies 2021, LNEE vol. 866. Cham: Springer, 2022. doi: 10.1007/978-3-030-95498-7_20

[17] I. Rodriguez-Conde, C. Campos, and F. Fdez-Riverola, “Horizontally distributed inference of deep neural networks for AI-enabled IoT,” Sensors, vol. 23, no. 4, p. 1911, 2023. doi: 10.3390/s23041911

[18] V. Tsoukas, A. Gkogkidis, E. Boumpa, and A. Kakarountas, “A review on the emerging technology of TinyML,” ACM Comput. Surv., vol. 56, no. 10, pp. 1–37, 2024. doi: 10.1145/3661820

[19] Z. Wang, W. Yan, and T. Oates, “Time series classification from scratch with deep neural networks: A strong baseline,” in Proc. IJCNN, 2017, pp. 1578–1585. doi: 10.1109/IJCNN.2017.7966039

[20] B. Jacob et al., “Quantization and training of neural networks for efficient integer-arithmetic-only inference,” in Proc. IEEE/CVF CVPR, 2018, pp. 2704–2713. doi: 10.1109/CVPR.2018.00286

[21] D. Fährmann, F. Boutros, P. Kubon, and N. Damer, “Ubiquitous multi-occupant detection in smart environments,” Neural Comput. Appl., vol. 36, no. 6, pp. 2941–2960, 2024. doi: 10.1007/s00521-023-09162-z

[22] R. Banner, Y. Nahshan, and D. Soudry, “Post training 4-bit quantization of convolutional networks for rapid-deployment,” in Proc. NeurIPS, 2019.

[23] K. Zhao et al., “Distribution adaptive INT8 quantization for training CNNs,” in Proc. AAAI, vol. 35, no. 4, pp. 3483–3491, 2021. doi: 10.1609/aaai.v35i4.16462

[24] J. A. Armenta-Garcia, F. F. Gonzalez-Navarro, J. Caro-Gutierrez, and C. I. Garcia-Reyes, “Tools and Methods for Achieving Wi-Fi Sensing in Embedded Devices,” Sensors, vol. 25, no. 19, art. no. 6220, 2025. doi: 10.3390/s25196220

Downloads

Published

18.10.2026

How to Cite

[1]
A. A. Ramadha, F. Corputty, and N. H. Lutfianto, “Implementation of On-Device Convolutional Neural Network Inference for Indoor Occupancy Detection on the ESP32-S3”, JurnalEcotipe, vol. 13, no. 2, pp. 283–292, Oct. 2026, doi: 10.33019/.