Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when there is no beat #6

Open
tandroutsou opened this issue May 24, 2021 · 3 comments
Open

Problem when there is no beat #6

tandroutsou opened this issue May 24, 2021 · 3 comments

Comments

@tandroutsou
Copy link

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?

@pkourany
Copy link
Owner

@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.

@tandroutsou
Copy link
Author

@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
}

@pkourany
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants