Vivoactive HR temperature from sensor doesn't work (?)

Former Member
Former Member
I followed this example:

```using Toybox.Sensor; function initialize() { Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE]); Sensor.enableSensorEvents(method(:onSensor)); } function onSensor(sensorInfo) { System.println("Heart Rate: " + sensorInfo.heartRate); }```
to also display temperature data (Sensor.SENSOR_TEMPERATURE). It works on the simulator, but when I load it on my vivoactive hr, it doesn't work - no temperature information returned in sensorInfo. I think the temperature works on the watch overall, because I can get it from SensorHistory, but not through sensor events as described above.

Any ideas?

Thank you

It's a widget with:
<iq:products>
<iq:product id="vivoactive_hr"/>
</iq:products>
<iq:permissions>
<iq:uses-permission id="Background"/>
<iq:uses-permission id="Positioning"/>
<iq:uses-permission id="Sensor"/>
<iq:uses-permission id="SensorHistory"/>
</iq:permissions>
  • For temperature in sensor info on a vahr, you need to have an external Tempe Sensor. It does not return the value from the internal temperature sensor. To get the internal temperature sensor data, you need to use SensorHistory.getTemperatureHistory. In the sim, if you "simulate Data", that acts as if there is a Tempe. This isn't a bug - you just need a tempe to get temperature data from sensor info.

    Another note about the Tempe, is it can take a minute or two to connect, which may exceed the timeout for widgets on some devices.
  • Former Member
    Former Member
    Thanks. Hm - since the sensor is already there, it would've been nice if the SenorInfo returned it - maybe a future enhancement.

    In the meantime, it would be nice if the SDK documentation reflected that.

    Thanks for the information.
  • Another thing to note, is on the vahr, unless you have a Tempe, the temperature isn't saved in an activity's .fit. Also, the internal sensor can be different from ambient temperature, as it's impacted by body temperature, and is mainly used for the baro altimeter. IIRC, when you call .setEnabledSensors with SENSOR_TEMPERATURE, you get an array back that will indicate if there is a Tempe paired. On watches with ohr, it will indicate a HR sensor, and on all watches, if an external HRM is paired.

    Here's one of my widgets that shows both the internal reading as well as the Tempe if it's paired. Temps