Can't read temperature on Fenix 3

Former Member
Former Member
The following code works in the simulator but not on my Fenix 3. Sensor.getInfo().temperature is always set to null, therefore the temperature is never displayed.
Any hints?

Thanks
Jesus

celsius = Sensor.getInfo().temperature;
if (celsius == null) {
return;
}

if (app.tempUnits == FAHRENHEIT) {
findDrawableById("temp").setText((1.8*celsius+32).toNumber().toString());
findDrawableById("tempUnits").setText("F");
} else {
findDrawableById("temp").setText(celsius.toNumber().toString());
findDrawableById("tempUnits").setText("C");
}
  • To get the temperature using Sensor on the f3, you likely need a paired and connected Tempe. The only devices I've seen that Sensor works with the internal Temp sensor is the Edge 520 (you can't pair a Tempe with it).

    If you do have a Tempe, you need to make sure you enable it in your code:

    Sensor.setEnabledSensors([Sensor.SENSOR_TEMPERATURE]);

    You'll get the temperature in the sim based on what you are doing to get data - the "Simulate Data" includes it, and "playback .fit" will have it if the .fit was recorded with it (a Tempe was used). From what I've seen, the Edge (and maybe some other non-watches) includes temperature data in the .fit if you aren't using a Tempe.

    If you want the internal Temperature data, you may be able to use SensorHistory on the f3 (getTemperatureHistory() ). Note: this will work in the sim, but maybe not on the f3, so yoyu want to test it.

    From what I've seen (a va-hr), the internal temp can be off 5-10 degrees (F) compared to a Tempe, as the internal sensor is influenced by skin temperature and not really the ambient temperature.
  • To get the temperature using Sensor on the f3, you likely need a paired and connected Tempe. The only devices I've seen that Sensor works with the internal Temp sensor is the Edge 520 (you can't pair a Tempe with it).

    If you do have a Tempe, you need to make sure you enable it in your code:

    Sensor.setEnabledSensors([Sensor.SENSOR_TEMPERATURE]);

    You'll get the temperature in the sim based on what you are doing to get data - the "Simulate Data" includes it, and "playback .fit" will have it if the .fit was recorded with it (a Tempe was used). From what I've seen, the Edge (and maybe some other non-watches) includes temperature data in the .fit if you aren't using a Tempe.

    If you want the internal Temperature data, you may be able to use SensorHistory on the f3 (getTemperatureHistory() ). Note: this will work in the sim, but maybe not on the f3, so yoyu want to test it.

    From what I've seen (a va-hr), the internal temp can be off 5-10 degrees (F) compared to a Tempe, as the internal sensor is influenced by skin temperature and not really the ambient temperature.



    This app https://apps.garmin.com/fr-FR/apps/455cab4b-4127-4f88-ad5a-a8e227126b3a#0 works with the external TEMPE sensor
  • This app https://apps.garmin.com/fr-FR/apps/455cab4b-4127-4f88-ad5a-a8e227126b3a#0 works with the external TEMPE sensor


    I think he's thinking he can use the internal Temp Sensor (using Sensor), and like I said, I've only seen that with devices like the Edge that aren't watches. With a Tempe, the call to setEnabledSensors() is needed so the device starts looking for a Tempe.

    This App only works with the Tempe on a va-hr (I user Sensor), while this Widget uses SensorHistory and works with the internal Temp sensor on the va-hr (no Tempe involved) I'm not sure if SensorHistory.getTemperatureHistory() works on the f3 though. With the widget, I get the 4 hr history of Temperature and Air Pressure though, and can do it in a widget, and not have to be running to collect the history.
  • Former Member
    Former Member over 8 years ago
    I just confirmed that Fenix 3 doesn't support SensorHistory, or at least not for temperature.
  • So on an f3, if you want the temperature in CIQ, you must use a Tempe.

    For SensorHistory, I do think the documentation needs to be expands a bit more. While it lists what devices support SensorHistory, which of the 4 types of history is available on each devices is a "try it and see"..

    Some are kind of clear. Like getHeartRateHistory() is only on devices with WHR (internal HRM), and getElevationHistory()/getPressureHistory() are likely are only on devices with a baro altimeter, but possibly not then (and developers might not know which devices have a baro and which don't)

    getTemperatureHistory() is kind of a guess, as it needs the internal sensor and the data has to be exposed in CIQ (I'm pretty sure the f3 has the sensor, but it looks like the data isn't exposed)

    I have found that the va-hr has all 4 types of history available, and the 735 only has getHeartRateHistory(), for example.

    I'm using "has" to check for SensorHistory itself and then a "has" for each of the 4 types of history so nothing will crash if something isn't available, so there is a work-around.