Pulse sensor (Product ID: 1093) output

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

At pulsesensor.com it says output 0.3V to Vcc, so that means values from 61 to 1023, when supplied with 5V.

However, with different people and slightly varying pressure, I always only obtain values from about 200 to 1023, and often the values are clipped at 1023. Is there a way to force the sensor to use the full 61 to 1023 range, without clipping?

Thanks!

User avatar
barshatriplee
 
Posts: 200
Joined: Wed Mar 22, 2023 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by barshatriplee »

What value do you see when nobody wears the sensor?

User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Re: Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

Without Vcc connected, sensor lying on a table as far away from other electronics as the wires permit, I obtain values oscillating around 75. With Vcc connected, sensor lying on a table as far away from other electronics as the wires permit, I obtain values oscillating around 525.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by adafruit_support_bill »

Looking at the schematic, changing VCC should change the output of the LED. What range of values do you see if powered from 3.3v?

User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Re: Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

When I power it from Vcc 3.3V of a Metro Mini (instead of the external 5V DC power supply that I used before, which also powers the Metro Mini and a servo), the output oscillates around 335, see screenshot below.
Skärmbild.png
Skärmbild.png (96.31 KiB) Viewed 1059 times

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by adafruit_support_bill »

What is the range when sensing pulses?

User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Re: Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

With 3.3V from the Metro Mini instead of an external 5V PSU, the values are about 220 to 620; the lower end did not change much at all, see screenshot.
Skärmbild.png
Skärmbild.png (243.47 KiB) Viewed 1053 times

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by adafruit_support_bill »

That's the only externally controllable variable from an electronics perspective. The sensor sensitivity & response is controlled by the filtering and feedback circuitry surrounding the OpAmp.

You might try contacting the designers of the device to see if they have any suggestions. There is an email address on their github repository: https://github.com/WorldFamousElectronics

User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Re: Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

Yeah, good idea. Using the full range would be great, if one uses the values for artistic purposes, to drive motors or linear actuators, etc. like in my case.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by adafruit_support_bill »

If maximum resolution is not critical, you can always expand the range in software. But that would not address the clipping issue.

User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Re: Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

How could I expand it down to 0 in code, though? Mapping won't work, because the low value fluctuates. It could be 240, it could be 190, it could be 220.

The clipping can only be solved when pressing the sensor too hard on the finger, then the range is from about 200 to 700 only. But that's no good solution, and difficult to replicate.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by adafruit_support_bill »

You could track the signal over time and adjust the lower limit of your raw range dynamically.

User avatar
Systembolaget
 
Posts: 336
Joined: Wed Mar 08, 2017 1:01 pm

Re: Pulse sensor (Product ID: 1093) output

Post by Systembolaget »

Realising that every new person putting the sensor on is different, I decided to establish the minimum and maximum values in setup() over 7 seconds, and that works well. The timer-interfering pulsesensor.com library isn't needed, a potentiometer allows adjusting the person's threshold value, and once the system is "ready" or "stable", pushing a button enables or disables a heartbeat indicator LED and servo for some nice clean output.
Skärmbild 06.png
Skärmbild 06.png (366.41 KiB) Viewed 1031 times

Code: Select all

#include <RunningMedian.h>
#include <Servo.h>

RunningMedian samples = RunningMedian(7);

Servo myServo;

// Variables that remain constant
const byte pinPulseSensor = A0;
const byte pinPotentiometer = A1;
const byte pinLED = 5;
const byte pinServo = 6;
const byte pinSwitch = 8;

// Variables that can change
byte lastSwitchState = HIGH;
byte indicatorState = false;
byte servoAngle = 90;
int sensorSignalMin = 1023;
int sensorSignalMax = 0;
int sensorSignal = 0;
int signalThreshold = 0;

void setup()
{
  pinMode (pinSwitch, INPUT_PULLUP);
  pinMode(pinLED, OUTPUT);
  myServo.attach(pinServo);
  
  while (millis() < 7000)
  {
    sensorSignal = analogRead(pinPulseSensor);

    if (sensorSignal > sensorSignalMax)
    {
      sensorSignalMax = sensorSignal;
    }

    if (sensorSignal < sensorSignalMin)
    {
      sensorSignalMin = sensorSignal;
    }
  }
  
  Serial.begin(115200);
  Serial.println("sensorSignal:,signalMedian:,signalThreshold:,servoAngle:");
}

void loop()
{
  checkSwitch();

  checkPotentiometer();

  sensorSignal = analogRead(pinPulseSensor);

  samples.add(sensorSignal);

  int signalMedian = samples.getMedian();

  servoAngle = map(signalMedian, sensorSignalMin, sensorSignalMax, 20, 160);
  
  servoAngle = constrain(servoAngle, 20, 160);

  Serial.print(sensorSignal);
  Serial.print(",");
  Serial.print(signalMedian);
  Serial.print(",");
  Serial.print(signalThreshold);
  Serial.print(",");
  Serial.println(servoAngle);

  if (indicatorState)
  {
    myServo.write(servoAngle);

    if (signalMedian >= signalThreshold)
    {
      digitalWrite(pinLED, HIGH);
    }
    else
    {
      digitalWrite(pinLED, LOW);
    }
  }

  delay(20);
}

void checkPotentiometer()
{
  signalThreshold = analogRead(pinPotentiometer);
}

void checkSwitch()
{
  byte switchState = digitalRead (pinSwitch);

  if (switchState != lastSwitchState)
  {
    if (switchState == LOW)
    {
      //
    }
    else
    {
      indicatorState = !indicatorState;
    }
    lastSwitchState = switchState;
  }
}

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Pulse sensor (Product ID: 1093) output

Post by adafruit_support_bill »

Sounds like a workable solution. Thanks for the update.

Locked
Please be positive and constructive with your questions and comments.

Return to “Wearables”