Pulse sensor (SEN-11574) value stability

Any ideas on how I can stabilize the values i get from the pulse sensor, Is there a code fix or is it a design flaw?
this is the particular sensor I'm playing around withhttps://www.sparkfun.com/products/11574

It is a fact of life that experimental data values fluctuate, so you need to make your particular concern clear.

Post the code, using code tags, and representative examples of the data in question.

Averaging is a standard approach to smoothing fluctuations.

Alright, its just a simple program to display the bpm calculated

#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <PulseSensorPlayground.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int PulseWire = 0;
const int LED = LED_BUILTIN;
const int BuzzerPin = 8; // Define the buzzer pin (change to your pin)
int Threshold = 550;

PulseSensorPlayground pulseSensor;

bool pulseDetected = false;

void setup() {
  lcd.begin(); // initialize the lcd
  Serial.begin(9600);
  pinMode(BuzzerPin, OUTPUT); // Set the buzzer pin as an OUTPUT

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Please Press ");
  lcd.setCursor(0, 1);
  lcd.print("Skin On Sensor ");
  pulseSensor.analogInput(PulseWire);
  pulseSensor.blinkOnPulse(LED);
  pulseSensor.setThreshold(Threshold);

  if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");
    //lcd.print("PulseSensor Ready");
  }
}

void loop() {
  if (pulseSensor.sawStartOfBeat()) {
    int myBPM = pulseSensor.getBeatsPerMinute();

    Serial.println("♥ A HeartBeat Happened !");
    Serial.print("BPM: ");
    Serial.println(myBPM);

    lcd.clear(); // Clear the LCD when a pulse is detected
    lcd.setCursor(0, 0);
    lcd.print("Pulse Detected ");
    lcd.setCursor(0, 1);
    lcd.print("BPM: ");
    lcd.print(myBPM);

    pulseDetected = true;

    // Beep the buzzer
    digitalWrite(BuzzerPin, HIGH);
    delay(200); // Beep duration
    digitalWrite(BuzzerPin, LOW);

    delay(4000); // Add a 1-second delay after displaying the BPM
  } else if (pulseDetected) {
    // If a pulse was detected previously, clear the flag and display the initial message
    pulseDetected = false;

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Please Press");
    lcd.setCursor(0, 1);
    lcd.print("Skin On Sensor ");
  }

  delay(100);
}

Based on the pressure and position of the fingers on the sensor, The values it outputs vary wildly
Here is the last copule of printouts from the serial monitor

22:27:13.552 -> ♥ A HeartBeat Happened !
22:27:13.552 -> BPM: 65
22:27:37.754 -> ♥ A HeartBeat Happened !
22:27:37.754 -> BPM: 59
22:27:43.517 -> ♥ A HeartBeat Happened !
22:27:43.517 -> BPM: 202
22:27:51.848 -> ♥ A HeartBeat Happened !
22:27:51.848 -> BPM: 26

Take a look at the timestamps. Does it make sense that 24 seconds should elapse between the report times for two measurements, then 6 and 4 seconds between two more?

It sounds like the sensor is not detecting regular heartbeats. Sparkfun usually has excellent getting started guides, so go through it carefully to see if there is something you missed.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.