Two Peak detection and extraction of timing information in arduino

Thread Starter

Goverdhan R

Joined Mar 10, 2016
I want to use arduino to detect peak and extract timing information. As shown in image attached i want ST,T1,DT to be detected using arduino. Detealis about signal frequency:1-2Hz, Some noise exists. So how can i detect ST,t1,DT.



Joined Jun 19, 2012
Feed the signal into an ADC, write some code to detect peaks an slope reversals.
Read a timer to calculate the time values.

You may need an analog low pass before the ADC, to filter out the noise.
Sample it at a much higher rate to increase your timing resolution.


Joined May 4, 2013
Your signal looks like a EKG waveform. If it is then the peak for the QRS is usually greater than the T wave peak. But, I think in some cases, the T wave can actually be greater than the QRS. Also, sometimes the T wave can be inverted from the QRS. These abnormalities could make your measurements trickier to do.

Note also that the heart rate can be higher than 2 Hz and lower than 1 Hz. I have had my heart rate close to 180 BPM (not fun) and my resting rate has been as low as 50 BPM.


Joined May 15, 2016
IMHO arduino is not the best choice. I would actually consider faster boards with much better ADCs . Maybe ST Nucleo F446 (eight quit)


Joined Jun 28, 2014
I have had my heart rate close to 180 BPM (not fun) and my resting rate has been as low as 50 BPM.
I once had a heart monitor. I used it to keep my heart rate below 145 when I jog as was recommended to improve cardiovascular system. I also used the monitor to learn calming down at rest. After some training I could lower my heart rate to 30. I would guess other people could go even lower.


Joined Apr 11, 2010
Collect a lot of data. A simple sketch can perform an analog read and write the time and value to the console. Grab that data and analyze it with a spreadsheet. As far as I can see, you need the minimum value, an error value for the minimum, the peak value and error range. The slope of the last n-m points and the slope of the last n points, to see if the curve is increasing or decreasing (n and m determined experimentally. Then you have enough data to write an algorithm for your three values.

I'd use case statements to implement three different situations. 1) Calculating ST, 2) Calculating T1 and 3) Calculating DT

You'd use the techniques/ values developed in your test program in performing the calculations in the three cases defined above.


Joined Sep 22, 2013
Why not record the change in the polarity of the signal with a timer? You will need a little dead band to prevent false starts.
Start a timer1 at the positive change at ST. When the polarity changes to negative, Stop timer1 and start timer2. Store timer1, reset timer1. This stored timer1 value is the length (time) of ST.
When the signal gets about half way thru T1.....the polarity will change. Stop timer2. Start timer1. Store timer2 and reset timer2. When the polarity of T1 changes at the end of T1, Stop timer1. Start timer2. Store timer1. Reset timer1. Add timer1's new stored value to timer2 stored value. The result is the length (time) of T1.
The signal will change polarity again at the beginning of ST. Stop timer2 and start timer1 again for beginning of next ST. Store timer2. reset timer2. Add the stored timer2 value to the ST value......this is your DT value.

This will only work for the signal that you showed. But one can play with the dead band and use multiple timers.

Hardware speed is what limits you.

You did want just the time component and not the amplitude? Right? i.e......timing information.