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

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

Screenshot 2024-02-27 at 8.21.24 AM

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+