Garmin Descent MK3i and Heart Rate

68 views
Skip to first unread message

Philippe B.

unread,
Jul 14, 2024, 1:16:17 PM (13 days ago) Jul 14
to Subsurface Divelog

I use a Garmin Descent MK3i for diving, and I follow the procedure described in Subsurface to integrate data from my dive computer (downloading the FIT file). Although it's sometimes a bit finicky, everything works well, and I can find almost all my data in Subsurface. I say almost, because it's impossible to get the heart rate data! I can see it in Garmin Connect and Garmin Dive, but despite my numerous attempts, I can't get the heart rate data to appear in Subsurface...

If anyone has any ideas, I'm open to suggestions!

Thank you in advance

Linus Torvalds

unread,
Jul 14, 2024, 1:32:33 PM (13 days ago) Jul 14
to subsurfac...@googlegroups.com
On Sun, 14 Jul 2024 at 10:16, Philippe B. <philippe...@gmail.com> wrote:
>
> I use a Garmin Descent MK3i for diving, and I follow the procedure
> described in Subsurface to integrate data from my dive computer
> (downloading the FIT file). Although it's sometimes a bit finicky,
> everything works well, and I can find almost all my data in
> Subsurface. I say almost, because it's impossible to get the heart
> rate data! I can see it in Garmin Connect and Garmin Dive, but despite
> my numerous attempts, I can't get the heart rate data to appear in
> Subsurface...

We have had issues with the Garmin FIT file heartrate thing before -
it seems that Garmin ends up encoding it different ways depending on
random things.

It did work at one time, but even that was only when using the optical
sensor on the Garmin itself (and long ago, on the Mk1).

If you use a chest strap, afaik the data is merged after-the-fact (no
transmission under water!) by Garmin, and the FIT file from the dive
computer doesn't contain it at all.

And I have this suspicion that there may have been a data format
change even for the optical sensor on the watch itself.

Things you can try:

- does the data change if you download the FIT file for the dive from
Garmin (as opposed to downloading it from the dive computer itself)

- I can try to take another look at this, if you have a dive with
heart rate data in the Garmin app, can you send me an email with the
FIT file for that dive _and_ a screenshot with the HR data visible so
that I have something to compare to?

No promises. The FIT file data format is somewhat odd to begin with,
and if the HR data is even encoded in the file you download from the
dive computer it might be in that annoying largely undocumented
"vendor specific format".

Linus

Philippe B.

unread,
Jul 14, 2024, 1:57:54 PM (13 days ago) Jul 14
to Subsurface Divelog
Thank you very much, Linus, for these clarifications. It is indeed a heart rate belt (it's not possible to wear the Garmin directly on my wrist with a 7mm wetsuit). Attached you will find, as requested, a FIT file from my dive yesterday and the corresponding screenshots (Garmin Connect).
NOTE : There is no change whether I use the FIT file from Garmin Connect or if I retrieve it directly.
Thank you in advance for anything you can do.

Philippe
16392953016.zip
HR Screenshot.jpg
global screenshot.jpg
HR + Depth + Temperature Screenshot.jpg

Linus Torvalds

unread,
Jul 14, 2024, 3:23:08 PM (13 days ago) Jul 14
to subsurfac...@googlegroups.com
On Sun, 14 Jul 2024 at 10:58, Philippe B. <philippe...@gmail.com> wrote:
>
> NOTE : There is no change whether I use the FIT file from Garmin Connect or if I retrieve it directly.

Ok, so I took a quick look, and your FIT file looks fairly normal.

But it does have that odd "message 233" thing that is entirely
undocumented. We've seen that msg type before - the data in that
doesn't seem to be any obvious HR data, though.

I do find a couple of new fields - your log has a "enhanced altitude"
field (why?) and a "po2" field that we haven't parsed before, but
neither of them look all that interesting.

Anyway, if the HR data is hiding in that FIT file, I can't find it.

But I suspect it isn't there, and it's actually that Garmin ends up
taking the heartrate from a separate place when it merges all the data
from the HR band in the cloud.

I might well be wrong, but the FIT parser doesn't seem to find any
likely place to hide it.

Linus

Linus Torvalds

unread,
Jul 14, 2024, 3:32:54 PM (13 days ago) Jul 14
to subsurfac...@googlegroups.com
On Sun, 14 Jul 2024 at 12:22, Linus Torvalds
<torv...@linuxfoundation.org> wrote:
>
>
> I do find a couple of new fields - your log has an "enhanced altitude"
> field (why?) and a "po2" field that we haven't parsed before, but
> neither of them look all that interesting.

The attached patch makes our FIT file debug logs a bit more
informative for your FIT file (by calling out those fields by name).

But doesn't actually bother using it (unless Garmin starts doing
rebreather tracking, the po2 field is literally just the same one we
can calculate using the depth and oxygen percentage).

Putting the patch here mainly for posterity, I'm not sure I'm even
going to commit it.

Linus
patch.diff

Philippe B.

unread,
Jul 15, 2024, 11:30:08 AM (12 days ago) Jul 15
to Subsurface Divelog
Thank you very much, Linus, for taking the time to look at my file. I'm afraid you are right, and that Garmin is doing everything to prevent us from using their data outside their own ecosystem. It's really a shame that this trend of trapping users within a system is becoming more and more prevalent.

Philippe B.

unread,
Jul 15, 2024, 3:30:39 PM (12 days ago) Jul 15
to Subsurface Divelog
Hi Linus,

Following your comments, I used this site https://www.fitfileviewer.com/ to see what was in the FIT file. And I found something interesting there: the heart rate data is indeed present (see the attached screenshot) ... there may be hope, knowing that with the site mentioned above, we can export in CSV format :-)
FIT Content.jpg

Linus Torvalds

unread,
Jul 15, 2024, 4:08:11 PM (12 days ago) Jul 15
to subsurfac...@googlegroups.com
On Mon, 15 Jul 2024 at 12:30, Philippe B. <philippe...@gmail.com> wrote:
>
> Following your comments, I used this site
> https://www.fitfileviewer.com/
> to see what was in the FIT file. And I found something interesting
> there: the heart rate data is indeed present (see the attached
> screenshot) ... there may be hope, knowing that with the site
> mentioned above, we can export in CSV format :-)

Ahh - actually, looking at that fitfileviewer output I went "odd, that
has an extra field in between the fields that I'm parsing".

Which made me then go look at the debug output from my garmin parser some more.

And it turns out that the reason I missed that field entirely was that
we exit early in some cases, and I hadn't added any debug output for
that case. So it all ended up being entirely hidden in my debug
output.

Let me go check. Because I now have a clue.

Linus

Linus Torvalds

unread,
Jul 15, 2024, 4:18:21 PM (12 days ago) Jul 15
to subsurfac...@googlegroups.com
On Mon, 15 Jul 2024 at 13:07, Linus Torvalds
<torv...@linuxfoundation.org> wrote:
>
> Let me go check. Because I now have a clue.

Bah. No.

We didn't print the value in the debug output because it was the
(defined) invalid value (ie "heartrate" in that record is 0xff.

How annoying. I thought I had missed something, but no, we
intentionally don't print out values that are marked invalid, and
there was no actual interesting data in the place that looked
promising.

It must be hiding somewhere else.

Linus

Linus Torvalds

unread,
Jul 15, 2024, 4:27:18 PM (12 days ago) Jul 15
to subsurfac...@googlegroups.com
On Mon, 15 Jul 2024 at 13:17, Linus Torvalds
<torv...@linuxfoundation.org> wrote:
>
> It must be hiding somewhere else.

Hmm. Your screenshot literally says "HR data merged".

I don't know where it's merged from, though.. Very strange.

I have to go back and do kernel work. It's the first day of the merge
window, and I'm swamped.

Linus

Philippe B.

unread,
Jul 16, 2024, 12:09:23 PM (11 days ago) Jul 16
to Subsurface Divelog
Pushing the tests a bit further, I found a small oddity in the FIT file.

When I decode the FIT file via the FIT File Viewer site (https://www.fitfileviewer.com/) by checking "USER MODE," I do find all the heart rate data (screenshot-1) under the label "HR data merged." I can export all the heart rate + dive data in CSV mode.
But! If I check the "DEVELOPER MODE" option, the heart rate data no longer appears at all ... I can only export the dive data, with the heart rate data completely missing (screenshot-2).

Very strange indeed..

Philippe

screenshot-1.jpg
screenshot-2.jpg

Linus Torvalds

unread,
Jul 16, 2024, 1:53:43 PM (11 days ago) Jul 16
to subsurfac...@googlegroups.com
On Tue, 16 Jul 2024 at 09:09, Philippe B. <philippe...@gmail.com> wrote:
>
> When I decode the FIT file via the FIT File Viewer site
> (https://www.fitfileviewer.com/) by checking "USER MODE," I do find
> all the heart rate data (screenshot-1) under the label "HR data
> merged." I can export all the heart rate + dive data in CSV mode.
>
> But! If I check the "DEVELOPER MODE" option, the heart rate data no
> longer appears at all ... I can only export the dive data, with the
> heart rate data completely missing (screenshot-2).

That 'screenshot-2' gave me an idea. I didn't find heartrate data
anywhere, but the file does have

DIVE_SETTINGS_heart_rate_source_type (ENUM): 5
DIVE_SETTINGS_heart_rate_device_type (UINT8): 10

which doesn't really tell me anything, but it does kind of imply that
it's *somewhere*.

And your second screenshot has a clue at the top, in that it says
"file headers" and then lists 7 different "File Index" things.

And when I add some more debugging, I see this:

DEBUG: file 16392953016_ACTIVITY.fit
DEBUG: hdrsize 14 datasize 166596 len 197557

where that key thing is the "datasize" vs "len". The "datasize" is the
size of the data we will parse. But "len" is the size of the FIT file
itself.

So I think what is going on is that I never understood that a FIT file
can have multiple "files" inside of it all appended together.

And presumably the HR data is in another of those files.

Again, horribly timing, I'm in the middle of the merge window, I have
absolutely no time to spare for this right now.

Linus
Reply all
Reply to author
Forward
0 new messages