KY039 Arduino Heart rate code

I built one of these pulse rate sensors for a company whilst at university back in 1971. Using similar components that were then available - but the solution didn't include any processors!!

Key things to think about. The level of the signal you are interested in is 'swamped' by the level of "DC" voltage seen by the sensor. This "DC" offset voltage will vary enormously between people and also for the same person in different conditions (e.g. hot or cold, well or ill).

You should shield the sensor from external light - especially mains driven - which adds a further signal conditioning problem - that's why the ones used in (eg) hospitals clip over the finger. With care you should be able to get some readings but I suspect that the variations in output levels will make it difficult to detect accurately.

On my KY-039 the little yellow men put a red LED in wrong direction >:( Any questions?

HI all. I used the same code and get the output between 4080-4094. What should be the output of this sensor ? Is there any equation so I can convert this output numbers in regular pulse number , eg. Like 60-100.

this is my code. int ledPin = 13; int sensorPin = A0; int alpha = 0.75; //try with double int period = 1000; //double change = 0.0;

//double minval = 0.0; void setup () { pinMode(ledPin,OUTPUT); Serial.begin(9600); } void loop () { static int oldValue = 0; // static double oldChange = 0;

int rawValue = analogRead(A0); Serial.println(rawValue); digitalWrite(ledPin,HIGH); int value = alpha * oldValue + (1 - alpha) * rawValue;

// Serial.println(rawValue); Serial.println(" and, "); Serial.println (value);

digitalWrite(ledPin, LOW); oldValue = value;

delay (period); }

jurs: For correct sensor adjustment see my reply #27 and the picture I posted.

Your data with many, many 0 measurements show that the LED in your hardware is not correctly adjusted to send its beam to the IR sensor.

As far as the code is concerned, you are doing measurement of the raw sensor data in a given moment:

   int rawValue = analogRead (sensorPin);

And then you are doing a low-pass filtering ("smooting", "averaging") of the values:

   double value = alpha * oldValue + (1 - alpha) * rawValue;

So "rawValue" is a momentary value measured at a single moment. This number can change very quickly from one measure to the next.

And "value" is an filtered average value, created from several measured values. This number can change slowly from one measure to the next, as it is an average created from several measurements.

So when printing both you will see this in your data: - sometimes "rawValue" is higher than "value" - sometime "rawValue" is lower than "value"

If you'd do that correctly (LED adjustment, low-pass filter value), you could see that the speed of this change will be in the rhythm of the heartbeat.

Hi, But why the speed of this change will be in the rhythm of the heartbeat?