Fenix 3 HR - Getting the current temp in an app

Former Member
Former Member
I have the following code, but it seems the Fenix 3 HR is not returning any temp data

var Info = Toybox.Sensor.getInfo();
If (Info != null && Info.temperature != null)
{
var LastTemp = Info.temperature;
}

I'm sure I'm getting something for Info, since i can use it to get the current altitude, but it seems the current temp is not being set.

I have the permission set in my manifest file:

<iq:uses-permission id="Sensor"/>

What am I missing or should I be getting the temp using another class/method?

Thanks
  • I believe (others may know otherwise) that the temperature field is set only if you enable the temperature sensor and a temperature sensor (like a Garmin Tempe) is connected via ANT+.

    Sensor.enableSensorEvents(method(:onSensor)); // may not be necessary...

    // pretty sure this is the important part
    Sensor.setEnabledSensors([Sensor.SENSOR_TEMPERATURE]);


    Travis
  • Travis is correct.

    It's the setEnabledSensors() call that tells the FW to try to connect to the paired Tempe.

    The Edge 520 (not sure about the 820 or 1000), it will use the internal sensor - you can't even pair a Tempe with it, but that's the exception. Other devices need the Tempe for this.

    With a fr 920, the Tempe isn't a sensor known to the FW, so there you have to make your own Ant+ calls to use it.

    Also note that with a Tempe, it may take a minute or more after the setEnabledSensors() call to start getting data.
  • Former Member
    Former Member over 8 years ago
    Neither suggestion seem to work

    Neither of these suggestions seem to work on the Fenix 3 HR.

    For my app, i just want to display the current temp from the internal temperature sensor.

    The code works and show temp data in the simulator when i choose the "Simulate Data" menu option, but does not show anything when running on a real F3HR.

    Do I need to start an activity on the device to have the temp data enabled?
  • Again, you can't get the temperature from the internal sensor - you need to use a Garmin Tempe Temperature Sensor with a f3/f3-hr When you use "Simulate data" in the sim, it's simulating having a Tempe, so that's why you see data there.

    BTW, you'll likely find the Tempe more accurate (if worn correctly) than what you see from the internal sensor (on the va-hr you can get the last internal Temp using SensorHistory.getTemperatureHistory(), but that's not available on the f3-hr. So it's easy to compare on the va-hr)

    With the internal sensor, it can easily be impacted by your skin temperature, or by things like wearing a heavy coat. On the va-hr I've seen the internal sensor showing a temperature that's close to 10 degrees F warmer than the Tempe, for example.
  • Jim and I have both answered this question above... Just so we're absolutely clear about the answer here.

    I just want to display the current temp from the internal temperature sensor.

    You can't get the temperature from the internal sensor - you need to use a Garmin Tempe Temperature Sensor


    You can't access the internal temperature sensor on any of the wrist-based devices. Period. You have to use an external temperature sensor (Garmin Tempe)

    Travis
  • Former Member
    Former Member over 8 years ago
    Internal Temp

    Thanks for the reply, I did not find anywhere in the docs that the internal temp sensor could not be accessed.

    So I am curious, how does the temp widget get access to the internal temp sensor?

    And I've seen temp readings for activities, so they must also have access to the internal temp sensor.
  • So I am curious, how does the temp widget get access to the internal temp sensor?

    The built-in applications and widgets have access to this sensor. They are most likely not using ConnectIQ, they are probably written in C and have direct access to all of the devices internal data.

    And I've seen temp readings for activities, so they must also have access to the internal temp sensor.

    If you're talking about activities (fit files) written by the built-in applications (Run, Ride, ...) those would definitely have access to the internal temperature sensor (for the same reason as mentioned above).

    For activities recorded by ConnectIQ applications, they don't necessarily have to have access the internal temperature sensor for the data to end up in the fit file. The underlying activity recording system will just insert the data into the fit file stream without ever passing it back out to the application. Yes, there is a field named temperature (and pressure, and ...) in Sensor.Info, but that doesn't mean it will be populated for all devices. For wrist-based devices the measured temperature can be off by quite a bit due to proximity to skin and any clothing that may be worn, so Garmin has made a decision to not expose that data for those devices.

    Travis
  • Former Member
    Former Member over 8 years ago
    I'm also trying to get internal sensor temperature on VAHR with no luck so far.
    I understand that it won't be correct because of proximity of skin but my idea is that Garmin provides bike handlebars mount for most of the watches. VAHR is indicated as compatible with it.
    During bike trainings I mount my VAHR on the handlebars so that I have it visible all the time. In such cases it should be possible to get internal temperature data and record it into fit file as it's done on Edge devices. I can display this data as it's available as a standard field but it's not saved into fit file.

    I've tried to workaround this issue with SensorHistory module (CIQ 2.1) and I get the last sample but it doesn't refresh after another getTemperatureHistory and another read sample.

    Do anyone know how often Sensor History is refreshed? Maybe I should call it in some specific way to get a data sample from second ago?
    Even if there would be some small time shift from the SensorHistory it won't really matter as temperature doesn't change as quickly as e.g. GPS position.
  • I'm also trying to get internal sensor temperature on VAHR with no luck so far.
    I understand that it won't be correct because of proximity of skin but my idea is that Garmin provides bike handlebars mount for most of the watches. VAHR is indicated as compatible with it.
    During bike trainings I mount my VAHR on the handlebars so that I have it visible all the time. In such cases it should be possible to get internal temperature data and record it into fit file as it's done on Edge devices. I can display this data as it's available as a standard field but it's not saved into fit file.

    I've tried to workaround this issue with SensorHistory module (CIQ 2.1) and I get the last sample but it doesn't refresh after another getTemperatureHistory and another read sample.

    Do anyone know how often Sensor History is refreshed? Maybe I should call it in some specific way to get a data sample from second ago?
    Even if there would be some small time shift from the SensorHistory it won't really matter as temperature doesn't change as quickly as e.g. GPS position.


    The only way to get the internal temp is with getTemperatureHistory() and look at the newest sample. The FW controls the frequency, and IIRC, it's every 95 seconds (the HR in getHeartRateHistory() is also every 95 seconds).

    But, with a tempe, you only get a reading every minute, so it's not that different.

    The internal temperature on the va-hr is not recorded to the .fit, but it is with a Tempe. You could do a developer field and add it, but to be honest, I think it would be easier to just get a Tempe, and then you can use it with other apps too (native or CIQ apps that support it).