Pull sensors from the fit file and display on activity

Trying to find a way to display the sensors used on my different activities. Sensors as in HRMs, power meters, watch/computer, temperature, running power etc.
According to a thread on the garmin-forums the information seems to be in the fit file ( Sensors used - Garmin Connect Web - Mobile Apps & Web - Garmin Forums ), but when looking in the JsFitSDK class (Server side data model for scripts) (?) there seems to be a lot of different potential sources for this information, and i’m a little lost.

Has anyone done this? Is there something that I have overlooked? Is it possible to do this with custom activity fields? Or is it a potential feature request?

Hoping for an end result something like this displayed on the acitivity:
Sensors used in this activity:

  • Favero Assioma Duo ID: nnnnnn
  • Garmin HRM PRO ID: nnnnn
  • Core sensor ID: nnnnn
  • Edge 1040 ID: nnnnn
1 Like

The power meter data is already visible on the activity data page. I have created a custom activity field for the HR monitor. Click “Custom” under the activity timeline chart:

Click the search button and then search for “HR Monitor” and you should see it. Click it to get a copy:

Now do Actions → Reprocess File to re-analyse the fit file to pickup the field:

The script for the HR Monitor field looks like this (you can edit your copy to get this code). If you know the device type for the other sensors you need you can probably adapt this script easily to find them:

{
  let hrm
  for (let di of icu.fit.device_info) {
    if (di.device_type?.value !== 120 /* HEART_RATE */) continue
    console.log("di " + di)
    let manufacturer = di.manufacturer?.valueName
    if (!manufacturer) continue
    let product = di.product?.value
    if (product) {
      if (manufacturer === "GARMIN") product = icu.fitSdk.enumValueName('GARMIN_PRODUCT', product)
      else if (manufacturer === "FAVERO") product = icu.fitSdk.enumValueName('FAVERO_PRODUCT', product)
    }
    let serial = di.serial_number?.value
    hrm = manufacturer + (product ? " " + product : "") + (serial ? " " + serial : "")
  }
  hrm
}
2 Likes

Great, thanks! Will give it a shot!

Has anybody figured out how to get this HR Monitor field to pick up an HR sensor?
It does not seem to work for me with a Polar or Magene unit. I probably do not understand what should be modified in the script
This is how device_info section looks like, don’t see any mention of Polar (I was using Polar H9 in this activity paired to a Forerunner 265)

The bluetooth_low_energy entry is probably the Polar but how to tell with certainty?

Per this, it says device_type = 120 for Heart Rate. I don’t see 120 in any of the device types on your screenshot.

This is output from FitFileViewer on a Run activity w/ Polar H10

This is output from FitFileExplorer (Mac) App

I shared 2 diff screenshots cos FitFileViewer doesn’t decode the diff fields. FitFileExplorer does

So basically you’re looking for the field “antplus_device_type” (device_type) = 120 for Heart Rate. Manufacturer = 123 For Polar

#define FITAntplusDeviceTypeHeartRate ((FITAntplusDeviceType)120)

#define FITManufacturerPolarElectro ((FITManufacturer)123)
#define FITManufacturerMagene ((FITManufacturer)107)

Note: I would presume that there’s 2 entries for each device cos It looks like one is start of workout and 1 at end of workout and the one with end of workout only thing I see different is the Battery_status and some other “field_x” which I’ve no idea what.

From what I can tell, your Screenshot shows (not sure what is 4259 as it’s not avialable in the Garmin FitSDK)

#define FITGarminProductFr265Large ((FITGarminProduct)4257)
#define FITGarminProductGnss ((FITGarminProduct)3865)

You’re prob right. the Device Type 1 seems to be for BLE HR (120 is ANT+ HR)

typedef FITUInt8 FITBleDeviceType;
#define FITBleDeviceTypeHeartRate ((FITBleDeviceType)1)

Is the HRM connected to the watch as BLE or ANT+? Mine is all connected as ANT+ so it shows up as 120. Didn’t try connect as BLE.

Thanks for looking into this.
I believe the issue is with having paired the straps using BLE instead of ANT+ and maybe BLE does not pass on the device information correctly.

My real aim here is to try to detect the cases when the external HRM is not used and the smartwatch automatically switches to use the internal sensor, which we know is garbage for intervals

i typically would just lift my watch up and see if there’s any light coming from the OHR :stuck_out_tongue:

I’m trying to detect this after the fact, here’s a typical scenario

  1. Start an activity, miss the split second when the watch tells you an external HRM is connected but assuming it is
  2. Perform a great workout
  3. Reviewing the stats at home and seeing fantastic HR numbers making me think I’m in great shape
  4. Realised I was possibly fooled by Garmin having used the crappy built in sensor
2 Likes

Why not try to do some “at desk” experiments? That’s essentially what I do when I experiment and try stuffs. Just connect the HRM as ANT+, start a 10s “at desk” activity and just upload the FIT file and see what it says. maybe you’ll see “120” when it’s ANT+

I’ve recently decided to encode sensors connected to my BreakAway App into the FIT file and I’m coming into a stumbling block.

My BreakAway App is iOS only, so can only connect via BT. but It seems that the Polar is reporting 3 diff serial numbers

  1. Official Polar says the SN is X on the Back of the Pod
  2. Pod Connected to Garmin as ANT+ has a SN of Y
  3. Pod Connected to Garmin as BLE has a SN of Z

so this is confusing and what’s worst is that the FIT SDK from Garmin only permits Digits for the SN and Polar has letters in it

Edit: Hmm… interestingly I think Ive been interpreting it wrongly. Polar calls it ID, but Garmin says it’s SN but to Polar, there a difference between ID and SN

Can anyone tell me how to get my Polar Verity Sense to show up? I’ve got the activity field and reprocessed file, but the field remains empty. I Dow loaded the fit file and viewed it but it doesn’t have the word “device” anywhere in it. I don’t know how to modify scripts and such.

I don‘t get any data from my Verity Sense, to detect it.
Only Ant number is transmitted, no manufacturer or so. Is there more info for you?

I can’t see anything about it. The .fit file that I downloaded from Intervals doesn’t even look like the tables that others have shown in this thread.

Look at fitfileviewer.com in the Device Info category.
There is nothing for this HR (for me)

Ok I just did that but there is no Device Info caregory

Did you get the ‘Original fit file’ from the activity Data tab?

I got it from Edit > Download fit files

Just now I got the original from Garmin Connect Web, and it looks the similar to R2Tom’s (no manufacturer or serial number), but there is some additional info.

Can it be made to work with the Activity Field in Intervals?

And you can get Ant+ID + sensor name you have in watch sensor settings

{

for (let se of icu.fit.m_147) {
if ( se.f_52?.value !== 0) continue
console.log("se " +se)

let antid = se.f_0?.value
let name = se.f_2 ?.value

ssds = (name ? " " + name : “”) + (antid ? " "+ antid : “”)

ssds
}}

In my watch settings under Sensors & Accessories the device has a name consisting of five digits. I don’t know what to do with that coding stuff and it’s not clear to me how to set it up. Can you give a step by step?

Oh, my script. That works for Ant+ sensors, your connection is Ant+ or BLE?