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!
Pulse sensor (Product ID: 1093) output
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
- barshatriplee
- Posts: 200
- Joined: Wed Mar 22, 2023 10:11 am
Re: Pulse sensor (Product ID: 1093) output
What value do you see when nobody wears the sensor?
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
Re: Pulse sensor (Product ID: 1093) output
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.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Pulse sensor (Product ID: 1093) output
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?
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
Re: Pulse sensor (Product ID: 1093) output
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.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Pulse sensor (Product ID: 1093) output
What is the range when sensing pulses?
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
Re: Pulse sensor (Product ID: 1093) output
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.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Pulse sensor (Product ID: 1093) output
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
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
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
Re: Pulse sensor (Product ID: 1093) output
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.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Pulse sensor (Product ID: 1093) output
If maximum resolution is not critical, you can always expand the range in software. But that would not address the clipping issue.
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
Re: Pulse sensor (Product ID: 1093) output
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.
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.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Pulse sensor (Product ID: 1093) output
You could track the signal over time and adjust the lower limit of your raw range dynamically.
- Systembolaget
- Posts: 335
- Joined: Wed Mar 08, 2017 1:01 pm
Re: Pulse sensor (Product ID: 1093) output
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.
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;
}
}
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Pulse sensor (Product ID: 1093) output
Sounds like a workable solution. Thanks for the update.
Please be positive and constructive with your questions and comments.