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

HRS3300 getting HRS data #5

Open
XlashDev opened this issue Sep 29, 2019 · 21 comments
Open

HRS3300 getting HRS data #5

XlashDev opened this issue Sep 29, 2019 · 21 comments

Comments

@XlashDev
Copy link

Did you get the HRS3300 working? I'm using c/c++ and had access to the register but i get too high values on HRS register like around 14k to 15k. At first I taught that the bpm value should be the one stored on that register because it has HRS engine already but not. If you have a code that I can base my code then that would be a great help. TIA.

@fanoush
Copy link
Owner

fanoush commented Sep 30, 2019

@atc1441 has good example here
https://github.com/atc1441/D6-arduino-nRF5/blob/master/libraries/D6Examples/examples/HeartRateTest/HeartRateTest.ino#L428

There are two parts of the problem:

  1. read raw values from the sensors - that is working and we have pretty good knowledge which registers from datasheet are needed.

  2. process raw data into heart rate - for this there is closed source static library for cortex M4 - it is not freely available but is provided by manufacturer free of charge (after signing NDA?) This library can be found in some github projects near the pxialg.h header file and works fine but it is not clear what is exact status of this library. However as I understand it with knowledge mentioned in 1. it is possible to have good approximation even without this library.

@fanoush
Copy link
Owner

fanoush commented Sep 30, 2019

Oh, just noticed that you talk about HRS3300, not PAH8001, sorry. Anyway, I searcher for it recently and found some very similar library also for HRS3300, it has similar calls to process raw data together with accelerometer data just like the pxialg API. But no, I didn't try to read it yet.

@fanoush
Copy link
Owner

fanoush commented Sep 30, 2019

search github for hrs3000 (not hrs3300) and you will find the project with example, there is also keil library there

@XlashDev
Copy link
Author

XlashDev commented Oct 1, 2019

Hello fanoush, yeah PAH8001 has already an engine built in so you just fetch the data. But with this HRS3300 only the raw values are stored on register. I misunderstood the datasheet or Must be lost from translation.

Anyway did search last night here in github and not showing any results on mobile. Searched again this morning on PC and found what you are pointing. Actually I'm using the arduino platform based so I need to port this to work with Arduino. Thank you very much fanoush! I'll start working on this. Closing this issue (not actually but a question).

@XlashDev XlashDev closed this as completed Oct 1, 2019
@fanoush
Copy link
Owner

fanoush commented Oct 1, 2019

OK, if you get something working, please don't hesitate to share. BTW which device you have?

I will keep this issue open for future progress since HRS3300 is not working yet and people searching for it later will see it and will not create another issue.

@fanoush fanoush reopened this Oct 1, 2019
@XlashDev
Copy link
Author

XlashDev commented Oct 1, 2019

I'm using a B57 Smart bracelet
https://www.amazon.com/Smart-Waterproof-smartwatch-Multiple-Wearable/dp/B07LB1VR1J

I can access all parts including the accelerometer raw values at this moment. With the HRS3300 I had written already a library to access enable and disable it and read the HRS and ALS register.

I spent the whole morning till this afternoon exploring the code but unfortunately based on my findings the source code in the kiel has dependencies that is not included on the whole project. I first started understanding the code and proceed with porting it with arduino but when I can't trace some extern functions I moved to SES to compile the whole project but I found out that it really has missing parts.

Based on the functions on that library it sends the HRS and ALS data to a function that calculates the BP and heart rate which is declared as extern function. Tried searching that function but I guess that is already proprietary as I can't find anything. I think their function is good even though I don't know yet what inside of it since they used the ALS in that function in calculating the BP and HR and there is also a function which take account the accel values in calculation.

My plan now is adapting my i2c code to the heart rate sensors that are read by analog which is common to manufacturers like adafruit and dfrobot.
readAnalog>>> value>>>calculate BPM
to
i2c read analog values written on register>>>value>>>calculate BPM

Or if you have other suggestions? Thanks again for the help.

@atc1441
Copy link

atc1441 commented Oct 1, 2019

Hi please share your current code with me i want to take a look at it.

I got some devices with this heartrate sensor

I can Look in about ten hours into it

@atc1441
Copy link

atc1441 commented Oct 1, 2019

Please try to send the raw data to serial and use the serial Plotter to watch how it looks

@XlashDev
Copy link
Author

XlashDev commented Oct 1, 2019

I have closed the device so I have no access to the serial UART port currently. Im debugging thru the ble UART. I'll try later this night with larger screen on ipad since I can't visualize it over the phone since the screen is too small.

Pardon the way this library is written since this is the first library I have made. I welcome corrections and suggestions. I uploaded it a moment ago.

https://github.com/corteXnzt/hrs3300_test

@XlashDev
Copy link
Author

XlashDev commented Oct 1, 2019

Here are some screenshots at 3ms interval. Lower than that I get some packet loss. Some looks like a pulse signal to me.
IMG_0482
IMG_0483

@atc1441
Copy link

atc1441 commented Oct 1, 2019

you could try to only send every 10th messaurement and then it should look better, or you could also take an averrage of the last 10 messauerements and only send that. just to see how it looks.

@atc1441
Copy link

atc1441 commented Oct 1, 2019

by the way, what happens if you change the width ?

@atc1441
Copy link

atc1441 commented Oct 1, 2019

First tests looking good

HRS3300

your data also looks good, but just with to less width i think

@atc1441
Copy link

atc1441 commented Oct 1, 2019

I made a basic HRS3300 library for Arduino/nRF52 please look here: https://github.com/atc1441/HRS3300-Arduino-Library.

you can replace the serial with bleserial and it should print the Heartrate to ble.

@fanoush
Copy link
Owner

fanoush commented Oct 1, 2019

Wow, very nice, thanks. So fortunately just the __hardfp_sqrt definition fix for Keil library was needed like with pah8001 library.

@atc1441
Copy link

atc1441 commented Oct 1, 2019

Not exactly. This time it was __hardfp_sqrt and not __hardfp_sqrtf so not for float, but yes kind of the same.

Also the hrs does not have a seperate define file for the library it is all within some other functions mixed up.

Made a short demo video: https://youtu.be/I8Ch9Db_a7M

@XlashDev
Copy link
Author

XlashDev commented Oct 2, 2019

So that what's missing with that library. Tested your library just now atc1441. This is good, haven't compared the BP yet with another smart band but by quick test I can read from 60-83 bpm. Thank you very much for immediate testing and library!

Question:
How did you edit the compiled lib? And I tried adding that on the segger embedded studio just in case I want to move away from arduino later on, now one of the error is >>undefined......\HRM\hrs3300_alg_dynamic.c:(i.Hrs3300_alg_send_data+0x5a): undefined reference to `__hardfp_sqrt'
which pertains to what you two are discussing.

@atc1441
Copy link

atc1441 commented Oct 2, 2019

No problem, i wanted to do it anyway, and now was the right time^^

The timing is quite importand, so you need to pull at exactly 40ms or another value, but everytime the same persiod.

I did not edit the compiled library, but it is possible to do it. extract the o file change the needed hex values in binary and combine it again with gcc ar or what it name was.

for the sqrt you need to add this somewhere: https://github.com/atc1441/HRS3300-Arduino-Library/blob/master/src/HRS3300lib.cpp#L4

@fanoush
Copy link
Owner

fanoush commented Oct 2, 2019

one could also add this one line __hardfp_sqrt method directly to the library, but it doesn't matter much as it is in the source that comes with it

@XlashDev
Copy link
Author

XlashDev commented Oct 2, 2019

The timing is quite importand, so you need to pull at exactly 40ms or another value, but everytime the same persiod.

Ok noted on this.

I added that line and the error is gone. Thanks again to both of you. Cheers!

@dariosalvi78
Copy link

Hello! Any plan to include this into the Espruino-compatible bundle?

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

4 participants