RRHR: Embedded Algorithm for Heart Rate and Heart Rate Variability Detection in Wearable Devices, Using Raw ECG Data Between R-R Peaks
Abstract
1. Introduction
2. Materials and Methods
2.1. ADC (Analog -to -Digital Conversion)
2.2. Bandpass Filter
2.3. Adaptive Filter
2.4. Squaring
2.5. Identifying R-Peak, R-R Interval and ECG Raw Data
| Algorithm 1: Identifying R-peak, RR interval and ECG raw data |
| Input: ECG samples after noise removal Output: R-Peak, R-R interval, data between R-R intervals // Initialize: 01 C ← 1080//Number of samples 02 DPTR ← 0000H//16-bit register for Data Pointer—ranges from 0 to 65,536—initialized with starting memory address of ECG data 03 P ← 0//Highest peak Y-axis value 04 N ← 0//Number of R-Peaks 05 R ← 0//Number of ECG raw data in R-R interval 06 Threshold ← 1 // Threshold to avoid missing R-Peaks // Finding Highest R-peak Value 07 WHILE (C > 0) DO Current Data ← Fetch ECG sample pointed by DPTR IF (Current Data >= P) THEN P ← Current Data//Store highest R-peak ENDIF C ← C – 1 DPTR ← DPTR + 1 END WHILE // Find R-R interval 08 DPTR ← 0000H 09 C ← 1080 10 WHILE (C > 0) AND (N < = 2) Current Data ← Fetch ECG sample pointed by DPTR IF P is in the range [Current Data − Threshold, Current Data + Threshold] THEN N ← N + 1 ENDIF R ← R + 1 C ← C − 1 DPTR ← DPTR + 1 END WHILE // Calculate HR = (Sampling Frequency × 60)/R-R interval; Sampling rate = 360 11 HR ← (360 × 60)/R 12 END |
3. Results
3.1. Experimental Overview
3.2. Hardware Platform for Implementation
3.3. Experiment 1
3.4. Experiment 2
3.5. Experiment 3
4. Discussion
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Khayatzadeh, M.; Zhang, X.; Tan, J.; Liew, W.S.; Lian, Y. A 0.7-v 17.4-/spl mu/w 3-lead wireless ecg soc. IEEE Trans. Biomed. Circuits Syst. 2013, 7, 583–592. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Nemati, E.; Deen, M.J.; Mondal, T. A wireless wearable ECG sensor for long-term applications. IEEE Commun. Mag. 2012, 50, 36–43. [Google Scholar] [CrossRef] [Scilit]
- Zahid, M.U.; Kiranyaz, S.; Ince, T.; Devecioglu, O.C.; Chowdhury, M.E.H.; Khandakar, A.; Tahir, A.; Gabbouj, M. Robust R-peak detection in low-quality holter ECGs using 1D convolutional neural network. IEEET Trans. Biomed. Eng. 2022, 69, 119–128. [Google Scholar] [CrossRef] [Scilit]
- Pandit, D.; Zhang, L.; Liu, C.; Chattopadhyay, S.; Aslam, N.; Lim, C. A lightweight QRS detector for single lead ECG signals using a max-min difference algorithm. Comput. Methods Programs Biomed. 2017, 144, 61–75. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Hao, Z.; Zhang, X.; Gao, L.; Li, J.; Liu, J.; Lai, Z. A Filter Design Method Based on Evolutionary Learning for R-Peak Detection in Portable ECG Testing Devices. Biomed. Signal Process. Control 2024, 88, 105649. [Google Scholar] [CrossRef] [Scilit]
- Davies, H.J.; Hammour, G.; Zylinski, M.; Nassibi, A.; Stanković, L.; Mandy, D.P. The Deep-Match Framework: R-Peak Detection in Ear-ECG. IEEE Trans. Biomed. Eng. 2024, 71, 2014–2021. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Liu, F.; Liu, C.; Jiang, X.; Zhang, Z.; Zhang, Y.; Li, J.; Wei, S. Performance Analysis of Ten Common QRS Detectors on Different ECG Application Cases. J. Healthc. Eng. 2018, 2018, 9050812. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Rodriguez, V.H.; Medrano, C.; Plaza, I. Embedded System Based on an ARM Microcontroller to Analyze Heart Rate Variability in Real Time Using Wavelets. Wirel. Commun. Mob. Comput. 2018, 2018, 9138578. [Google Scholar] [CrossRef] [Scilit]
- Raj, S.; Ray, K.C. Sparse Representation of ECG Signals for Automated Recognition of Cardiac Arrhythmias. Expert Syst. Appl. 2018, 105, 49–64. [Google Scholar] [CrossRef] [Scilit]
- D’Aloia, M.; Longo, A.; Rizzi, M. Noisy ECG Signal Analysis for Automatic Peak Detection. Information 2019, 10, 35. [Google Scholar] [CrossRef] [Scilit]
- Laudato, G.; Oliveto, R.; Scalabrino, S.; Colavita, A.; De Vito, L.; Picariello, F.; Tudosa, I. Identification of R-peak occurrences in compressed ECG signals. In Proceedings of the 2020 IEEE International Symposium on Medical Measurements and Applications (MeMeA), Bari, Italy, 1 June–1 July 2020; IEEE: New York, NY, USA, 2020; pp. 1–6. [Google Scholar]
- Gupta, V.; Mittal, M. Efficient R-peak detection in electrocardiogram signal based on features extracted using Hilbert transform and Burg method. J. Inst. Eng. (India) Ser. B 2020, 101, 23–34. [Google Scholar] [CrossRef] [Scilit]
- Gupta, V.; Mittal, M.; Mittal, V. R-peak detection-based chaos analysis of ECG signal. Analog Integr. Circuits Signal Process. 2020, 102, 479–490. [Google Scholar]
- Mehri, M.; Calmon, G.; Odille, F.; Oster, J. A deep learning architecture using 3D vectorcardiogram to detect R-peaks in ECG with enhanced precision. Sensors 2023, 23, 2288. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Karri, M.; Annavarapu, C.S.R. A real-time embedded system to detect QRS-complex and arrhythmia classification using LSTM through hybridized features. Expert Syst. Appl. 2023, 214, 119221. [Google Scholar] [CrossRef] [Scilit]
- Maurya, J.P.; Kumar, V.; Trivedi, V.K.; Shrivastava, A. An Optimized Machine Learning Model for R and T Peak Detection in ECG Signal. In Proceedings of the 2024 International Conference on Artificial Intelligence and Quantum Computation-Based Sensor Application (ICAIQSA), Nagpur, India, 20–21 December 2024; IEEE: New York, NY, USA, 2024; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
- Jiménez-Ocaña, A.A.; Pantoja, A.; Armañac, P.; Bailón, R.; Laguna, P.; Giraldo, L.F. Stress detection using heart rate variability and respiratory signals derived from a single lead ECG. IEEE Trans. Biomed. Eng. 2026, 1–12. [Google Scholar] [CrossRef] [Scilit]
- Chen, H.; Maharatna, K. An automatic R and T peak detection method based on the combination of hierarchical clustering and discrete wavelet transform. IEEE J. Biomed. Health Inform. 2020, 24, 2825–2832. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Razavi, S.R.; Doost Mohammadi, M.H. R-peak Detection in Electrocardiogram Signals Using Continuous Wavelet Transform. Int. J. Bioautomation 2017, 21, 165. [Google Scholar]
- Pan, J.; Tompkins, W.J. A Real-Time QRS Detection Algorithm. IEEE Trans. Biomed. Eng. 1985, BME-32, 230–236. [Google Scholar] [CrossRef] [Scilit]
- Siswanti, Y.W.; Yazid, M.; Setiawan, R. Comparison of 10 QRS Detection Methods for Heartbeat Detection on Portable ECG Systems. In Proceedings of the 2020 International Conference on Computer Engineering, Network, and Intelligent Multimedia (CENIM), Surabaya, Indonesia, 17–18 November 2020; IEEE: New York, NY, USA, 2020; pp. 58–63. [Google Scholar] [CrossRef] [Scilit]
- Rahman, M.; Augustyniak, P.; Olejarczyk, E. The QRS Detection Using the Modified Pan-Tompkins Algorithm. In Proceedings of the 2024 IEEE International Workshop on Metrology for Industry 4.0 & IoT (MetroInd4.0 & IoT), Florence, Italy, 29–31 May 2024; IEEE: New York, NY, USA, 2024; pp. 328–332. [Google Scholar] [CrossRef] [Scilit]
- Balta, D.; Akyemiş, E.M. Arrhythmia detection using Pan Tompkins algorithm and Hilbert transform with real-time ECG signals. Acad. Perspect. Procedia 2021, 4, 307–315. [Google Scholar] [CrossRef] [Scilit]
- Al-Jabbar, A.; Entisar, Y.; Mohamedsheet Al-Hatab, M.M.; Qasim, M.A.; Fathel, W.R.; Fadhil, M.A. Clinical Fusion for Real-Time Complex QRS Pattern Detection in Wearable ECG Using the Pan-Tompkins Algorithm. Fusion Pract. Appl. 2023, 12, 172–184. [Google Scholar] [CrossRef] [Scilit]
- Tueche, F.; Mohamadou, Y.; Djeukam, A.; Kouekeu, L.C.N.; Seujip, R.; Tonka, M. Embedded Algorithm for QRS Detection Based on Signal Shape. IEEE Trans. Instrum. Meas. 2021, 70, 1–12. [Google Scholar] [CrossRef] [Scilit]
- Orlandic, L.; De Giovanni, E.; Arza, A.; Yazdani, S.; Vesin, J.; Atienza, D. REWARD: Design, Optimization, and Evaluation of a Real-Time Relative-Energy Wearable R-Peak Detection Algorithm. In Proceedings of the 2019 41st Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), Berlin, Germany, 23–27 July 2019; IEEE: New York, NY, USA, 2019; pp. 3341–3347. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Kaur, A.; Agarwal, A.; Agarwal, R.; Kumar, S. A novel approach to ECG R-peak detection. Arab. J. Sci. Eng. 2019, 44, 6679–6691. [Google Scholar]
- Wang, L.; Hao, J.; Zhou, T.H. ECG multi-emotion recognition based on heart rate variability signal features mining. Sensors 2023, 23, 8636. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Kouekeu, L.C.N.; Mohamadou, Y.; Djeukam, A.; Tueche, F.; Tonka, M. Embedded QRS 630 Complex Detection Based on ECG Signal Strength and Trend. Biomed. Eng. Adv. 2022, 3, 100030. [Google Scholar] [CrossRef] [Scilit]
- Rodrigues, T.; Samoutphonh, S.; Silva, H.; Fred, A. A Low Complexity R-Peak Detection Algorithm with Adaptive Thresholding for Wearable Devices. In Proceedings of the 2020 25th International Conference on Pattern Recognition (ICPR), Milan, Italy, 10–15 January 2021; IEEE: New York, NY, USA, 2020; pp. 1–8. [Google Scholar] [CrossRef] [Scilit]
- Wang, R.; Veera, S.C.M.; Asan, O.; Liao, T. A Systematic Review on the Use of Consumer-Based ECG Wearables on Cardiac Health Monitoring. IEEE J. Biomed. Health Inform. 2024, 28, 6525–6537. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Xu, X.; Cai, Q.; Zhao, Y.; Wang, G.; Zhao, L.; Lian, Y. A 2.66 μW clinician-like cardiac arrhythmia watchdog based on P-QRS-T for wearable applications. IEEE Trans. Biomed. Circuits Syst. 2022, 16, 793–806. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Bittharia, K.; Tiwari, P.; Saxena, S.; Design, V.; Vidyapith, B. R-Peak Detection of ECG Signal Using Thresholding Method. Int. Res. J. Eng. Technol. (IRJET) 2019, 6, 2223–2234. [Google Scholar]
- Zhou, Z.; Wang, Y.; Cheng, X.; Wang, J. Evolution of Heart Rate Variability (HRV) Analysis Methodologies (2000–2025): From Task Force Standards to Wearables, AI, and Clinical Translation. Biomed. Signal Process. Control 2026, 123, 110575. [Google Scholar] [CrossRef] [Scilit]
- Gu, M.; Zhang, Y.; Wen, Y.; Ai, G.; Zhang, H.; Wang, P.; Wang, G. A lightweight convolutional neural network hardware implementation for wearable heart rate anomaly detection. Comput. Biol. Med. 2023, 155, 106623. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Mu, S.; Liao, S.; Tao, K.; Shen, Y. Intelligent fatigue detection based on hierarchical multiscale ECG representations and HRV measures. Biomed. Signal Process. Control 2024, 92, 106127. [Google Scholar] [CrossRef] [Scilit]
- Wang, B.X.; Brennand, E.; Le Page, P.; Mitchell, A.R. Heart rate variability in cardiovascular disease diagnosis, prognosis and management. Front. Cardiovasc. Med. 2026, 12, 1680783. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Alimbayeva, Z.; Alimbayev, C.; Ozhikenov, K.; Bayanbay, N.; Ozhikenova, A. Wearable ECG Device and Machine Learning for Heart Monitoring. Sensors 2024, 24, 4201. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Chen, C.; Chuang, C. A QRS Detection and R Point Recognition Method for Wearable 654 Single-Lead ECG Devices. Sensors 2017, 17, 1969. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Silva, L.; Silva, S.; Souza, L.; Azevedo, K.; Guedes, L.; Fernandes, M. A New and Light-657 weight R-Peak Detector Using the TEDA Evolving Algorithm. Mach. Learn. Knowl. Extr. 2024, 6, 736–750. [Google Scholar] [CrossRef] [Scilit]









| Sensitivity | ~87–98% (ability to detect true heartbeats) |
| Precision | ~97–99% (correctness of detected peaks) |
| F1 Score | ~90–99% |
| Accuracy | ~82–97% |
| GT beats | 2274 |
| Calculated beats | 2015 |
| MAE | 8.85 BPM |
| RMSE | 11.36 BPM |
| Mean GT HR | ⩰75.38 BPM |
| Mean calculated HR | ⩰66.79 BPM |
| GT beats | 2274 |
| Record (MIT- BIH) | R-R Interval | R-R (s) | HR GT (BPM) (HRx) | Measured HR (BPM) (HRy) | Error (|HRx − HRy| | R-R Data Using HRx (RRx) | R-R Data Using HRy (RRy) | Average (RRx, RRy) RRavg | HR Based on RRavg (HRz) | Error |
|---|---|---|---|---|---|---|---|---|---|---|
| 100 | R2:R3 | 0.778 | 77.14 | 72.97 | 4.17 | 280.01 | 296.01 | 288.00 | 75.00 | ±2.085 |
| R3:R4 | 0.881 | 73.79 | 70.82 | 3.15 | 292.01 | 304.99 | 298.5 | 72.36 | ±1.575 | |
| R4:R5 | 0.792 | 75.79 | 75.00 | 0.79 | 284.99 | 288.00 | 286.49 | 75.39 | ±0.395 | |
| R5:R6 | 0.792 | 75.79 | 83.08 | 7.29 | 284.99 | 259.99 | 272.49 | 79.26 | ±3.645 | |
| 102 | R2:R3 | 0.850 | 70.59 | 72.26 | 1.65 | 305.99 | 298.92 | 302.455 | 71.41 | ±0.825 |
| R3:R4 | 0.836 | 71.76 | 68.79 | 2.97 | 301.00 | 313.99 | 307.495 | 70.24 | ±1.475 | |
| R4:R5 | 0.817 | 73.47 | 76.60 | 3.13 | 293.99 | 281.98 | 287.99 | 75.00 | ±1.565 | |
| R5:R6 | 0.825 | 72.73 | 73.22 | 0.49 | 296.98 | 295.00 | 295.99 | 72.97 | ±0.245 | |
| 105 | R2:R3 | 0.714 | 84.05 | 84.71 | 0.66 | 256.98 | 254.98 | 255.988 | 84.37 | 0.33 |
| R3:R4 | 0.736 | 81.51 | 78.26 | 3.25 | 264.99 | 276.00 | 270.500 | 79.85 | 1.625 | |
| R4:R5 | 0.725 | 82.76 | 84.71 | 1.95 | 260.99 | 254.98 | 257.991 | 83.70 | 0.975 | |
| R5:R6 | 0.986 | 60.85 | 79.12 | 18.28 | 354.97 | 273.00 | 313.987 | 68.79 | 09.14 | |
| 107 | R2:R3 | 0.839 | 71.52 | 70.13 | 1.39 | 302.01 | 307.99 | 305.006 | 70.18 | 0.695 |
| R3:R4 | 0.850 | 70.59 | 69.90 | 0.69 | 305.99 | 309.01 | 307.502 | 70.24 | 0.345 | |
| R4:R5 | 0.878 | 68.35 | 66.67 | 1.69 | 316.02 | 323.98 | 320.001 | 67.49 | 0.845 | |
| R5:R6 | 0.869 | 69.01 | 36.36 | 32.65 | 312.99 | 594.05 | 453.528 | 47.62 | 16.325 |
| SF 400 | SF 1000 | SF 10000 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Clinical | Proposed RRHR | Clinical | Proposed RRHR | Clinical | Proposed RRHR | ||||||
| RR mm | HR | RR Data | HR | RR mm | HR | RR Data | HR | RR mm | HR | RR Data | HR |
| 1 | 1500 | 16 | 1500 | 1 | 1500 | 40 | 1500 | 1 | 1500 | 400 | 1500 |
| 2–3 | 150–500 | 42 | 571.42 | 2–3 | 150–500 | 105 | 571.42 | 2–3 | 150–500 | 1050 | 571.42 |
| 5–6 | 300–250 | 92 | 260.86 | 5–6 | 300–250 | 230 | 260.86 | 5–6 | 300–250 | 2300 | 260.86 |
| 8–9 | 185.5–166.66 | 134 | 179.10 | 8–9 | 185.5–166.66 | 335 | 179.10 | 8–9 | 185.5–166.66 | 3350 | 179.10 |
| 13–14 | 115.38–107.14 | 218 | 110.09 | 13–14 | 115.38–107.14 | 545 | 110.09 | 13–14 | 115.38–107.14 | 5450 | 110.09 |
| 15 | 100 | 240 | 100 | 15 | 100 | 600 | 100 | 15 | 100 | 6000 | 100 |
| 20 | 75 | 320 | 75 | 20 | 75 | 800 | 75 | 20 | 75 | 8000 | 75 |
| 25 | 60 | 400 | 60 | 25 | 60 | 1000 | 60 | 25 | 60 | 10,000 | 60 |
| 44–45 | 34.09–33.33 | 706 | 33.99 | 44–45 | 34.09–33.33 | 1765 | 33.99 | 44–45 | 34.09–33.33 | 17,650 | 33.99 |
| 125 | 12 | 2000 | 12 | 125 | 12 | 5000 | 12 | 125 | 12 | 50,000 | 12 |
| 1500 | 1 | 24,000 | 1 | 1500 | 1 | 60,000 | 1 | 1500 | 1 | 600,000 | 1 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Ramachandran, R.; Rajaram, K. RRHR: Embedded Algorithm for Heart Rate and Heart Rate Variability Detection in Wearable Devices, Using Raw ECG Data Between R-R Peaks. Appl. Sci. 2026, 16, 7576. https://doi.org/10.3390/app16157576
Ramachandran R, Rajaram K. RRHR: Embedded Algorithm for Heart Rate and Heart Rate Variability Detection in Wearable Devices, Using Raw ECG Data Between R-R Peaks. Applied Sciences. 2026; 16(15):7576. https://doi.org/10.3390/app16157576
Chicago/Turabian StyleRamachandran, Ravichandar, and Kanchana Rajaram. 2026. "RRHR: Embedded Algorithm for Heart Rate and Heart Rate Variability Detection in Wearable Devices, Using Raw ECG Data Between R-R Peaks" Applied Sciences 16, no. 15: 7576. https://doi.org/10.3390/app16157576
APA StyleRamachandran, R., & Rajaram, K. (2026). RRHR: Embedded Algorithm for Heart Rate and Heart Rate Variability Detection in Wearable Devices, Using Raw ECG Data Between R-R Peaks. Applied Sciences, 16(15), 7576. https://doi.org/10.3390/app16157576

