TinyML-Based Stress Detection Using Time-Domain HRV Features and a Lightweight DNN on ESP32

Deteksi Stres Berbasis TinyML Menggunakan Fitur HRV Domain Waktu dan DNN Ringan pada ESP32

Authors

  • Sarmayanta Sembiring Universitas Sriwijaya
  • Kemahyanto Exaudi Universitas Sriwijaya
  • Abdurahman - Universitas Sriwijaya
  • Jorena Universitas Sriwijaya
  • Hadir Kaban Universitas Sriwijaya
  • M. Buffon Prima Universitas Sriwijaya
  • Rahmat Fadli Isnanto Universitas Sriwijaya

DOI:

https://doi.org/10.25134/ilkom.v20i2.624

Keywords:

TinyML, Stress Detection, Heart Rate Variability, MAX30102, ESP32, TinyML, Stress Detection, Heart Rate Variability, MAX30102, ESP32

Abstract

Stress is a psychophysiological condition that requires continuous and objective monitoring. However, existing wearable stress detection systems often rely on cloud-based processing or computationally intensive algorithms, limiting their applicability for real-time inference on resource-constrained embedded devices. This study presents a TinyML-based framework for real-time stress detection using the MAX30102 sensor and an ESP32 microcontroller. The proposed framework integrates four time-domain Heart Rate Variability (HRV) features (BPM, SDNN, RMSSD, and pNN50), a lightweight Deep Neural Network (DNN), full INT8 TensorFlow Lite quantization, and on-device inference to enable efficient edge-based stress classification. The DNN model was trained and evaluated using the WESAD dataset. Experimental results showed that a decision threshold of 0.70 yielded the best classification performance, achieving an accuracy of 82% and an F1-score of 0.63 for the stress class. The quantized TensorFlow Lite INT8 model preserved 100% prediction compatibility between the Python and ESP32 implementations. Furthermore, the MAX30102 sensor achieved a BPM measurement accuracy of 98.74%, while the HRV feature extraction implemented on the ESP32 produced results consistent with the reference calculations. These findings demonstrate that the proposed end-to-end TinyML framework enables accurate and computationally efficient HRV-based stress detection on resource-constrained microcontrollers, providing a practical foundation for real-time wearable edge-health monitoring

Downloads

Download data is not yet available.

References

[1] Y. Segono, E. Y. M. Hutagalung, H. G. Simbolon, N. I. Us, and A. Ridwan, “IoT-Based Stress Monitoring Using CNN for HRV-GSR Analysis,” Sinkron, vol. 10, no. 1, pp. 621–637, 2026, doi: 10.33395/sinkron.v10i1.15671.

[2] A. Abu-Samah et al., “Deployment of TinyML-Based Stress Classification Using Computational Constrained Health Wearable,” Electron., vol. 14, no. 4, p. 687, Feb. 2025, doi: 10.3390/electronics14040687.

[3] P. Ganesan, Y. R. Thota, H. Shehata, and T. Nikoubin, TinyML Based Stress Detection utilizing PPG Signals: A Lightweight Approach for Smart Wearable Devices, vol. 1, no. 1. Association for Computing Machinery, 2025. doi: 10.1145/3716368.3735274.

[4] A. Calvo, J. Martin, and C. Martin, “Early Detection of Chronic Stress Using Wearable Devices: A Machine Learning Approach with the WESAD Database,” in International Conference on Information and Communication Technologies for Ageing Well and e-Health, ICT4AWE - Proceedings, 2025, pp. 189–196. doi: 10.5220/0013209700003938.

[5] G. Tyulepberdinova, M. Kunelbayev, G. Amirkhanova, M. Tokhtassyn, and A. Amirkhanov, “Development of a Stress Monitoring System Architecture for Heart Rate Measurement,” Eng. Technol. Appl. Sci. Res., vol. 15, no. 6, pp. 29551–29565, 2025, doi: 10.48084/etasr.13150.

[6] R. Al Abdi, S. AlKaabi, S. Elsifi, and J. Yousaf, “Mental Stress Detection Using Physiological Sensors and Artificial Intelligence: A Review,” Sensors, vol. 26, no. 5, pp. 1–31, 2026, doi: 10.3390/s26051616.

[7] A. Pinge, V. Gad, D. Jaisighani, S. Ghosh, and S. Sen, “Detection and monitoring of stress using wearables: a systematic review,” Front. Comput. Sci., vol. 6, no. c, Dec. 2024, doi: 10.3389/fcomp.2024.1478851.

[8] K. M. Dalmeida and G. L. Masala, “HRV Features as Viable Physiological Markers for Stress Detection Using Wearable Devices,” Sensors, vol. 21, no. 8, p. 2873, Apr. 2021, doi: 10.3390/s21082873.

[9] Wadeea Alnufaily, Ramasamy Srinivasagan, Purushothaman R, and Mohammed Alnaeem, “Stress Detection from Photoplethysmography Signals Using Multi-Domain Heart Rate Variability Analysis,” J. Comput. Biomed. Informatics, vol. 10, no. 02, Mar. 2026, doi: 10.56979/1002/2026/1234.

[10] Y. Haque et al., “State-of-the-Art of Stress Prediction from Heart Rate Variability Using Artificial Intelligence,” Cognit. Comput., vol. 16, no. 2, pp. 455–481, Mar. 2024, doi: 10.1007/s12559-023-10200-0.

[11] M. Bahameish, T. Stockman, and J. Requena Carrión, “Strategies for Reliable Stress Recognition: A Machine Learning Approach Using Heart Rate Variability Features,” Sensors, vol. 24, no. 10, pp. 1–21, 2024, doi: 10.3390/s24103210.

[12] Y. Y. Tsai, Y. J. Chen, Y. F. Lin, F. C. Hsiao, C. H. Hsu, and L. De Liao, “Photoplethysmography-based HRV analysis and machine learning for real-time stress quantification in mental health applications,” APL Bioeng., vol. 9, no. 2, pp. 1–22, 2025, doi: 10.1063/5.0256590.

[13] J. A. Mortensen, M. E. Mollov, A. Chatterjee, D. Ghose, and F. Y. Li, “Multi-Class Stress Detection Through Heart Rate Variability: A Deep Neural Network Based Study,” IEEE Access, vol. 11, no. May, pp. 57470–57480, 2023, doi: 10.1109/ACCESS.2023.3274478.

[14] S. Heydari and Q. H. Mahmoud, “Tiny Machine Learning and On-Device Inference: A Survey of Applications, Challenges, and Future Directions,” Sensors, vol. 25, no. 10, 2025, doi: 10.3390/s25103191.

[15] T. F. of the E. S. of C. the N. A. S. of P. Electrophysiology, “Heart rate variability: standards of measurement, physiological interpretation, and clinical use,” Circulation, vol. 93, no. 5, pp. 1043–1065, 1996.

[16] F. Shaffer and J. P. Ginsberg, “An Overview of Heart Rate Variability Metrics and Norms,” Front. Public Heal., vol. 5, no. September, pp. 1–17, 2017, doi: 10.3389/fpubh.2017.00258.

[17] B. Kołakowski, P. Noga, P. Mańczak, and M. Nowak, “Comparative analysis of methods for calculating HRV values on heart rate monitoring devices,” TASK Q., vol. 29, no. 2, 2025.

[18] M. M. Taye, “Understanding of Machine Learning with Deep Learning: Architectures, Workflow, Applications and Future Directions,” Computers, vol. 12, no. 5, p. 91, Apr. 2023, doi: 10.3390/computers12050091.

[19] I. H. Sarker, “Deep Learning: A Comprehensive Overview on Techniques, Taxonomy, Applications and Research Directions,” SN Comput. Sci., vol. 2, no. 6, pp. 1–20, 2021, doi: 10.1007/s42979-021-00815-1.

[20] R. Immonen and T. Hämäläinen, “Tiny Machine Learning for Resource-Constrained Microcontrollers,” J. Sensors, vol. 2022, pp. 1–11, Nov. 2022, doi: 10.1155/2022/7437023.

[21] Schmidt, P., Reiss, A., Duerichen, R., Marberger, C., & Van Laerhoven, K. (2018, October). Introducing wesad, a multimodal dataset for wearable stress and affect detection. In Proceedings of the 20th ACM international conference on multimodal interaction (pp. 400-408).

[22] Van Gent, P., Farah, H., Van Nes, N., & Van Arem, B. (2019). HeartPy: A novel heart rate algorithm for the analysis of noisy signals. Transportation research part F: traffic psychology and behaviour, 66, 368-378.

Downloads

Published

10-07-2025

How to Cite

Sarmayanta Sembiring, Kemahyanto Exaudi, -, A., Jorena, Hadir Kaban, M. Buffon Prima, & Rahmat Fadli Isnanto. (2025). TinyML-Based Stress Detection Using Time-Domain HRV Features and a Lightweight DNN on ESP32: Deteksi Stres Berbasis TinyML Menggunakan Fitur HRV Domain Waktu dan DNN Ringan pada ESP32. NUANSA INFORMATIKA, 20(2), 110–122. https://doi.org/10.25134/ilkom.v20i2.624

Similar Articles

1 2 > >> 

You may also start an advanced similarity search for this article.