Heartbeat Sensor

Arduino Compatible Finger Heartbeat Detection Sensor Module use’s Infrared LED and Optical Transistor’s to detect pulsation in fingers.

Parts Needed

-OR-

This is the code that comes with the sensor. This is strange on how this is currently working. Specially wired according to specs found digging around. Watch my video or check out the images that show why I would leave the power unplugged from the sensor

int sensorPin = 0;
double alpha = 0.75;
int period = 100;
double change = 0.0;
double minval = 0.0;
void setup ()
{
  Serial.begin (9600);
}
void loop ()
{
    static double oldValue = 0;
    static double oldChange = 0;
 
    int rawValue = analogRead (sensorPin);
    double value = alpha * oldValue + (1 - alpha) * rawValue;
 
    Serial.print (rawValue);
    Serial.print (",");
    Serial.println (value);
    oldValue = value;
 
    delay (period);
}

Image of the pins on the sensor

Heartbeat sensor pins

The first image is a frequency image with power hooked to the middle terminal. The second image is the Fritzing hookup. Because I did not have heartbeat sensor I improvised.

Heartbeat Sensor Freq With power
Fritzing Heartbeat sensor with power

The first image is a frequency image with OUT power hooked to the middle terminal. The second image is the Fritzing hookup with no power. Because I did not have heartbeat sensor I improvised.

Heartbeat Sensor Freq with out power
Fritzing Heartbeat sensor with OUT power

So I decided to play a bit and write some simple code to check the top positions of the frequency. Once you do this you can do simple math based on how many 60,000 milliseconds/milliseconds it took to get to the next high point. This is very basic code but my results were close to real heart beat I had.

int sensorPin = 0; // pin the S is connected into
int period = 150; //how often it checks a signal
int periodtotal = 0; //total time between highs
int nextone = 0; // used to know if I should reset or not. watching data it stays at 1023 for a couple times...
void setup ()
{
  Serial.begin (115200);
}
void loop ()
{
  int rawValue = analogRead (sensorPin);
  //Serial.println(rawValue);
 if(rawValue == 1023)
 {
   if(nextone == 0)
   {
     periodtotal=0;
     nextone = 1;
   }else
   {
   periodtotal = periodtotal + period;
   }
 }
 else
 {
  nextone = 0;
  periodtotal = periodtotal + period;
 }
      Serial.print("periodtotal:");
      Serial.println(periodtotal);
      Serial.print("BPM:");
      Serial.println(60000/periodtotal); 
}

Leave a Reply

Your email address will not be published. Required fields are marked *