Photoplethysmogram (PPG) signal time period measurement

Hello

I am working on a project that measures the heart rate in b.p.m. For this I am planning to use Arduino UNO. A PPG signal is basically a quasi-sine wave which needs to be filtered prior to measuring time period just for simplicity's sake.So, the PPG signal is passed through a peak detection circuit and a square wave whose voltage varies from -4V to +4V is resulted whose time period is to measured. Can someone please help me with finding the time period of the resulting square wave using arduino UNO? Any help is much appreciated.

Thanks in advance

Use a diode to limit the range to 0V..+4V. Use the pulseIn() function to measure the duration of either the HIGH or LOW side of the square wave in microseconds. Multiply by 2 to get the full duration. Divide into 1,000,000 to get pulses per second.

If the wave isn't actually 'square' (equal duration HIGH and LOW) measure both with two calls to pulseIn() and add the values together.

Thank you Mr.Johnwasser. This modified PPG(a square wave) in question, could be of varying time periods since the real time heart rate data is acquired which is not ideal most of the times(owing to arrhythmia and many other external factors) . What I am saying is, this wave could have cycles of duration say t1 for one cycle and t2 for the next cycle and so on and finding a "moving average" is our last resort. Can you please point me in that direction?

Please do not double post, I just replied on another post that is same as this one which I will writeoff now.

if the pulse is not vary from 0 to 4v then does it will show the output or not??? Because puse is -4 to +4 volt and i am measuring the high period so it is showing me output 0. Can anybody please help me??

if the pulse is not vary from 0 to 4v then does it will show the output or not??? Because puse is -4 to +4 volt

perhaps a Dc-Dc boost converter and linear regulator can work to bring the voltage in +ve ranges.