max30102-tutorial-raspberrypi icon indicating copy to clipboard operation
max30102-tutorial-raspberrypi copied to clipboard

Spo2 and Hrcalc

Open Aj12384 opened this issue 5 years ago • 13 comments

Hi, What do you mean after loading red and ir for the hrcalc code given in the readme?

Aj12384 avatar Apr 07 '20 20:04 Aj12384

Hi, Aj12384.

Did you mean this?

for i in range(37):
    print(hrcalc.calc_hr_and_spo2(ir[25*i:25*i+100], red[25*i:25*i+100]))

If so, the code is for getting HR/SpO2 by sliding 1 samples at an iteration. For example, the top 3 output lines correspond to

(-999, False, -999, False) # <- using ir[25:125], red[25:125]
(107, True, 99.43662599999999, True) # <- using ir[26:126], red[26:126]
(88, True, 99.519096, True) # <- using ir[27:127], red[27:127]

As you can see, the output values fluctuate. You may need to get average for more robust result.


If not, I could not get your question. Could you add some information?

vrano714 avatar Apr 08 '20 03:04 vrano714

No I mean that in the hrcalc, whenever I run the code, I do not seem so be getting any output. The code just runs.

Aj12384 avatar Apr 08 '20 03:04 Aj12384

You cannot see the output of hrcalc.calc_hr_and_spo2() in your environment, right?

Then, what happens if you use a variable, such as: output_value = hrcalc.calc_hr_and_spo2(ir[:100], red[:100]) and print that value: print(output_value).

vrano714 avatar Apr 08 '20 03:04 vrano714

It’s working but I’m just getting the same values over and over again. How do I get the actual bpm and spo2?

Aj12384 avatar Apr 08 '20 04:04 Aj12384

Hi again, can you tell me how to display the actual BPM and SPO2 for the actual hrcalc.py? The code just runs and nothing happens... is there a variable I should define?

Aj12384 avatar Apr 08 '20 04:04 Aj12384

Hi, I just added two comments on github.

On Tue, Apr 7, 2020 at 11:52 PM vrano [email protected] wrote:

You cannot see the output of hrcalc.calc_hr_and_spo2() in your environment, right?

Then, what happens if you use a variable, such as: output_value = hrcalc.calc_hr_and_spo2(ir[:100], red[:100]) and print that value: print(output_value).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vrano714/max30102-tutorial-raspberrypi/issues/4#issuecomment-610737211, or unsubscribe https://github.com/notifications/unsubscribe-auth/APDCXN7EUPXKLCNZYV7VBUTRLPYJJANCNFSM4MDNL67A .

Aj12384 avatar Apr 08 '20 04:04 Aj12384

Okay, please tell me what you did and what you got in detail. Paste your code or screenshot.

vrano714 avatar Apr 08 '20 05:04 vrano714

Here is what I did.

Aj12384 avatar Apr 08 '20 13:04 Aj12384

image

Aj12384 avatar Apr 08 '20 13:04 Aj12384

I want to be able to get the actual reading from the sensor continously

Aj12384 avatar Apr 08 '20 13:04 Aj12384

image

Aj12384 avatar Apr 08 '20 13:04 Aj12384

When I try to use this code, it runs but nothing else happens

Aj12384 avatar Apr 08 '20 13:04 Aj12384

Actually, read_sequential does read values (to the amount given as argument), but it does not run continuously (the method name may be confusing, sorry). If we want to read continuously, we have to run read_sequential many times.

Could you try the code below?

import max30102
import hrcalc

m = max30102.MAX30102()

for i in range(20): # try 20 times
    red, ir = m.read_sequential() # if nothing is passed, this reads 100 values
    print(hrcalc.calc_hr_and_spo2(ir, red))

I hope this works...

vrano714 avatar Apr 08 '20 14:04 vrano714