Open tandroutsou opened 3 years ago
@tandroutsou, I didn't write the original code, I only adapted it for the Particle devices. You might want to explore the PulseSensor site for more information.
@pkourany thanks for your answer! Do you think that the following part should also be adapted (2048 instead of 512)? Because in the other places these values have been changed.
if (N > 2500){ // if 2.5 seconds go by without a beat
thresh = 512; // set thresh default
P = 512; // set P default
T = 512; // set T default
lastBeatTime = sampleCounter; // bring the lastBeatTime up to date
firstBeat = true; // set these to avoid noise
secondBeat = false; // when we get the heartbeat back
}
@tandroutsou, I believe setting the values to 2048 at the start is meant to cause the algorithm to fire and eventually get to the (N > 2500) statement which then resets the values to 512.
You may want to adjust the values up or down from 512 to see how the sensor responds. I am not sure why the code would not work after not using the sensor for some time. What else is your code doing?
One thing you might want to consider is using a MAX30102 pulse-oximeter sensor. It uses I2C and there are libraries available for the Particle devices in the Web IDE and Workbench and CLI.
Hi there! I am using Photon and Pulse Sensor for a project and the code isn't working as expected when I touch the sensor after a while. You need to touch the sensor twice in order to start calculating BPM again and sometimes it isn't working at all. I thought that the problem was that in the part of the code that 2.5 seconds without a beat have passed P,T and threshold are reinitialized to 512 and not 2048, which is their default value for Photon. I changed them but now BPM is calculated constantly, even when the sensor is not being touched. Could you help me with this issue?