IR Pulse Sensor Help

Hello,

I bought an IR Pulse Sensor from ebay for a few £ and I can't seem to get it to give a reading that is representative of a heartbeat.
(here is the link: http://www.ebay.co.uk/itm/281259154674?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2648)
This might be because I am placing my finger in the wrong place? or could be a problem with my code/ circuit.

Here is an image showing the circuit I am using, as well as an image of the "keyes heartbeat sensor":

The code I am using is:

int ledPin=13;
int sensorPin=0;

double alpha=0.75;
int period=20;
double change=0.0;

void setup()
{
pinMode(ledPin,OUTPUT);
}

void loop()
{
static double oldValue=0;
static double oldChange=0;
int rawValue=analogRead(sensorPin);
double value=alpha*oldValue+(1-alpha)*rawValue;
change=value-oldValue;

digitalWrite(ledPin,(change<0.0&&oldChange>0.0));

oldValue=value;
oldChange=change;
delay(period);

Serial.println(change);

}

Thanks!

Code is not in code tags and there is no link to the used hardware. Please read the sticky post at the top of the forum.

Sorted it, thanks

This might be because I am placing my finger in the wrong place? or could be a problem with my code/ circuit.

Your finger should be placed between the LED and the sensor plate below it. If you did that correctly and the sensor works, the LED on pin 13 should blink at each heartbeat.

In the serial monitor you should get positive and negative values alternating in about the same rate as your heart beats.

In the serial monitor you should get positive and negative values alternating in about the same rate as your heart beats.

Hi, it is showing positive and negative values in the Serial Monitor ranging from around -50 up to around 0.4.

The problem is though, i'm not entirely sure how this sensor works but it seems to be picking something else up other than a pulse (maybe sunlight?) But it continues even after a finger is removed from the sensor.

I am using this data in processing to visualize the pulse and it isn't so clear because of the noise in the signal.

I don't know how exactly this sensor works as the don't provide schematics for it (and we see again, that you should never buy anything from a supplier that doesn't provide datasheets or equivalent documentation for their products).

I guess that the LED emits some light that goes through your finger and the sensor detects how much of it went through. That value probably changes in the rhythm of the heart beat. Have you tried covering the sensor and your finger in it so that no sun or synthetic light is reaching it? I would expect the sunlight not to have a high impact but synthetic light has. Usually these kinds of sensors are in a kind of part-finger-glove to keep away external light sources.