vrano714 / max30102-tutorial-raspberrypi

This repository is unofficial porting of Arduino sample code of MAXRESDEF117#(max30102) HR/SpO2 sensor
56 stars 28 forks source link

Spo2 and Hrcalc #4

Open Aj12384 opened 4 years ago

Aj12384 commented 4 years ago

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

vrano714 commented 4 years ago

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?

Aj12384 commented 4 years ago

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.

vrano714 commented 4 years ago

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

Aj12384 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Hi, I just added two comments on github.

On Tue, Apr 7, 2020 at 11:52 PM vrano notifications@github.com 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 .

vrano714 commented 4 years ago

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

Aj12384 commented 4 years ago

Here is what I did.

Aj12384 commented 4 years ago

image

Aj12384 commented 4 years ago

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

Aj12384 commented 4 years ago

image

Aj12384 commented 4 years ago

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

vrano714 commented 4 years ago

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