WorldFamousElectronics / PulseSensorStarterProject

The Best Way to Get Started with your PulseSensor and Arduino
http://www.pulsesensor.com
52 stars 36 forks source link

PulseSensor-RaspberryPi - BPM 3-times too high? #16

Closed webster1501 closed 11 months ago

webster1501 commented 3 years ago

Dear team,

first of all my appreciation for what you are doing here with the PulseSensor and the code you are providing!

My setup includes a RaspberryPi 3b and I have the MCP3008 ADC sitting in between the sensor and my SPI port (8). Everything is working fine, beside the fact, that my BPM appears approximately 3 times higher than in reality (I measured it with a commercial product). I am providing a sample output below.

Any idea what the root cause of this might can be ?

Best Thomas

sampleCounter Signal BPM IBI sampleIntervalMs
746 828 164 364 42
787 899 164 364 41
827 1023 164 364 40
866 1023 164 364 39
904 655 164 364 38
943 1023 164 364 39
981 600 164 364 38
1019 561 164 364 38
1057 862 192 311 38
1095 643 192 311 38
1133 1023 192 311 38
1171 927 192 311 38
1208 711 192 311 37
1245 428 192 311 37
1282 335 192 311 37
1318 752 192 311 36
1354 912 202 297 36
1389 1023 202 297 35
biomurph commented 3 years ago

@webster1501 Are you using the example code that we provide without modification? This is the Pulse Sensor + C example, correct? It'e been a while since I've had my rig set up, but I can attempt to replicate your results. I do believe that I made the original work using the Pi 3b. I have that and 4 here in my lab. We have been using the uAlarm, which at the time of making was not recommended for future designs. It looks like the sampleIntervalMs is too long a time. 27 milliSeconds is not the target sample timing.

Also, please edit your initial post to reduce the amount of data you are listing in the table for readability of this issue. Thanks!

webster1501 commented 3 years ago

Hi,

thanks for the quick reply.

  1. I reduced the the table size of my initial post.
  2. I'm using the code which you provided her on GitHub: https://github.com/WorldFamousElectronics/Raspberry_Pi/tree/master/PulseSensor_Processing_Pi/PulseSensor_Processing_Pi

I'm curious to hear if you can replicate my observation, and what redesign suggestions you may have. I have also a PI 4 in my fundus, if you think it makes sense to use this instead of my 3b?

Best Thomas

biomurph commented 3 years ago

Oh, you're using the Processing Sketch. Well, that is likely not super accurate in the first place, but you may have some luck in improving by adding P2D to your size() funcion size(<width>,<height>,P2D);

In a nutshell, the accurate BPM relies on accurate sample timing. Because the Processing Sketch is running on top of the RasPi OS, there is no telling when the sketch goes through each loop and hence, when the sample is taken from the Pulse Sensor. In this case, we're trying to fix that by using the frameRate variable that should be giving us some tighter timing of when the sample is taken. It may be better to use the millis() function? Don't know, haven't tested it.

Is there anything else running on your Pi? I kind of remember that I had to close all other applications.

Also, try using the C example in the repo and see if you get better results.

webster1501 commented 3 years ago

Hi Joel,

I tried it with the C example, with the same results. I just ordered an Arduino to see the differences between it and RasPi. I'll post my findings here as soon as I have them.

biomurph commented 3 years ago

Interesting. Please do add to this issue with any new findings. I will also post if I can replicate your results.

webster1501 commented 3 years ago

Hi Joel,

me again. I did the Pulse Sensor + Arduino + Pi setup after I received my Arduino Uno, worked like a charm immediately.

Unfortunately - for me - with the same result. This is the output I got: 16:16:46.134 -> 230,260,387 16:16:46.134 -> 230,260,377 16:16:46.168 -> 230,260,623 16:16:46.201 -> 230,260,623 16:16:46.201 -> 230,260,623 16:16:46.234 -> 230,260,626 16:16:46.267 -> 230,260,768 16:16:46.267 -> 230,260,774 16:16:46.300 -> 230,260,775 16:16:46.300 -> 230,260,833 16:16:46.333 -> 230,260,829 16:16:46.366 -> 230,260,822 16:16:46.366 -> 230,260,816 16:16:46.407 -> 230,260,936

Don't know exactly what columns represents what value, bit I assume the 1st column (230) is the BPM. When I watch the LED though I realize that it is blinking with an estimated frequency of 1,2 HZ which would mean a realistic BPM of around 70-90 BPM ?

Strange, isn't it ?

Best Thomas

biomurph commented 3 years ago

Hi Thomas,

Yes it is quite strange indeed! AT this point, for the sake of due diligence, can you share a screenshot of the pulse wave you are getting? Also, a pic of your hardware setup, including your Pulse Sensor.

I'm in the weeds today, but I can get setup to try and replicate your problem within a week.

webster1501 commented 3 years ago

Hi Joel,

first of all - no hurry! For me this is just something I want to demonstrate in my company and the schedule is end of May.

Below the requested images:

image image

Enjoy the weekend! Best Thomas

biomurph commented 3 years ago

Hi Thomas,

Thanks for the pictures! The first thing that I have to say is that you have unfortunately purchased a clone of our Pulse Sensor. Our Pulse Sensor has Red, Black, and Purple wires, and the three holes on the edge are not plated like yours are. Sorry to say that I won't be able to help you troubleshoot if the problem lies in the sensor functionality as I have no idea what that board is made with.

Please support the original makers of Open Source Hardware by purchasing legit parts. You can get the Pulse Sensor on our website www.pulsesensor.com Also on Adafruit, SparkFun, Mouser, and Digikey.

webster1501 commented 3 years ago

This makes sense to me, and I wasn't aware of that I purchased a clone of the original one. Wasn't on purpose. I will definitely support the original makers, and will order some immediately.

Thank you so much so far for your support, I'll keep you posted once the original ones have arrived!

Best Thomas

biomurph commented 3 years ago

Thanks Thomas! Please let me know where you got the clone? We also sell on Amazon.

webster1501 commented 3 years ago

Just ordered the one from your company, and I'm a bit scared that clones are underway.

This is the one I ordered: https://www.amazon.de/MissBirdler-Kardiometer-Heartbeat-Herzschlag-Prototyping/dp/B01MSLQQK9/ref=sr_1_1?dchild=1&keywords=missbirdler+pulse+sensor&qid=1619796609&sr=8-1

biomurph commented 3 years ago

Clones have been among us for a long time.

We are unfortunately not represented in Amazon EU.

webster1501 commented 3 years ago

That's why I apparently didn't find the original one...