you should see Garmin sensor dcumentation. The Code that should work is:
function initialize() {
Sensor.setEnabledSensors( [Sensor.SENSOR_HEARTRATE] );
Sensor.enableSensorEvents( method( :onSensor ) );
}
function onSensor(sensorInfo as Sensor.Info) as Void {
System.println( "Heart Rate: " + sensorInfo.heartRate );
}
if it isn't working and you don't forgot all the rest of the code (you can generate with monkey c extension in visual studio code) remember that garmin edge isn't tracking heart rate you need garmin hrm.
It should work,
Tobiasz