Reading the HR frequently in an app on FR235

Former Member
Former Member
Howdy,

I have a developed a few apps and feel pretty comfy with the SDK/API stuff at this point.

One app I have is for workouts and part of this is a continuous HR readout. However, while the app is running, the HR doesn't seem to change much (it DOES change sometimes, but not often). I know the HR system is responsive (if you go into the HR display from the main watchface, you see second-by-second changes), but I feel like when my app is running, I get HR updates about as often as a watchface does (i.e. every few minutes or so).

Is there a recommended way for reading the HR with more frequent updates? (prolly once per second, along with other updates). My watch is a FR235 with the most recently published (non-beta) firmware.

Right now, I use the Toybox.ActivityMonitor API and call getHeartrateHistory(1, true).next.heartRate

Thanks,

Gerry
  • The heart rate history is only updated periodically. If you want more frequent updates, you need to register for sensor events or use the Activity.getInfo() functionality.

    Travis
  • On the va-hr, the data in getHeartRateHistory() is only updated about every 2 minutes, and on top of that, it's only available on devices with WHR (so you have it on the 235, but not on the 230, for example)

    For an app, you want to enable the sensor (it will also work with HRM bands), so you do something like:

    Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE,Sensor.SENSOR_TEMPERATURE);

    And with a Tempe, you need this, as the temperature isn't in Activity.Info

    Sensor.enableSensorEvents(method(:sensorEvents));


    Watchfaces use getHeartRateHistory() (after checking if it's available!) because they don't have access to Sensor, so "every couple of minutes" is all they can do.
  • Former Member
    Former Member
    That worked great! Very responsive HR numbers now. Thanks!

    Gerry
  • And with a Tempe, you need this, as the temperature isn't in Activity.Info


    Just for educational purposes, is there any advantage to using the Sensor notification vs just grabbing the HR out of the Activity.Info at the same time I grab time, distance, etc? I'm updating every second anyway.
  • It doesn't make any difference as far as what I've seen. One thing about using Sensor.Info is you can display the HR before you start recording an activity, and I do that in a few things. (like when I'm waiting for GPS, show the HRM/Tempe is communicating)