Fenix 5X widget works in simulator but not on device

Hi, Really hoping someone can help me this, just created a simple little widget to show the temperature and an adjusted value, It works fine in the simulator but on the Fenix 5X it doesn't get the value back from the internal sensor, I've no idea why. I created a similar widget that reads the most recent temperature from the history and that works fine, pulling my hair out. Using Eclipse and SDK 3.0.1 - would anyone have any ideas for me please?

The code:

usingToybox.WatchUi;
usingToybox.Sensor;
usingToybox.System;



classTemperatureView extendsWatchUi.View {

varSensorTemp = 999;

functioninitialize() {

View.initialize();

Sensor.setEnabledSensors( [Sensor.SENSOR_TEMPERATURE] );

Sensor.enableSensorEvents( method(:onSnsr) );

}

// Load your resources here

functiononLayout(dc) {

setLayout(Rez.Layouts.MainLayout(dc));

// Call the parent onUpdate function to redraw the layout

view.onUpdate(dc);

}



// Update the view

functiononUpdate(dc) {
varTempFormat = "$1$";
varSensorFormat = "Sensor Reads $1$";


varTempString = "Not Available";
varSensorString = "Not Available";
varTempview = View.findDrawableById("TempLabel");
varSensorview = View.findDrawableById("SensorLabel");

// we got sensor data
if(SensorTemp != 999) {

// we got temperature
varTempInt = SensorTemp;
varSensorInt = SensorTemp;

SensorString = Lang.format(SensorFormat, [SensorInt.format("%.1f")]);

TempInt = TempInt - 10;
TempString = Lang.format(TempFormat, [TempInt.format("%.1f")]);

}



Tempview.setText(TempString);
Sensorview.setText(SensorString);

// Call the parent onUpdate function to redraw the layout

View.onUpdate(dc);

}


functiononSnsr(sensor_info)

{

varTM = sensor_info.temperature;

if( TM != null)

{

SensorTemp = TM;
}
else
{
SensorTemp = 999;
}



WatchUi.requestUpdate();

}

// Called when this View is removed from the screen. Save the

// state of this View here. This includes freeing resources from

// memory.

functiononHide() {



}



}






Many Thanks,

Ralph.
  • How long are you waiting for the tempe to connect on the watch? It can take a minute or more. So once you start your widget, give it time.

    Is the Tempe is paired to the watch? It needs to be.

    Does the Tempe connect when using a native activity like "run"? Just to make sure the battery is OK.
  • Oh, I see from your other thread you are trying to get the temperature from the internal temp sensor. It's only on edge devices where that's in Sensor.info.

    On watches, you get that by way of SensorHistory.getTemperatureHistory() and then the newest sample. When you mentioned Sensor.Info, it made me think it was a Tempe.
  • Ah ok thanks Jim, that explains everything... Where would I have found that critical piece of info if not from you?

    Many thanks,

    Ralph.
  • I'm not sure this is really documented anywhere, and there are variations. Like with Edge devices, the internal Temp is available in Sensor.Info, and they don't have SensorHistory. (you can't pair a Tempe with an Edge) Some watches also don't have SensorHistory for the temperature, like the Approach S60, fr 23x/630/73f. A baro altimeter comes into play here, as well as the version of CIQ they support (like with the fenix 3 - it's got a baro but it's CIQ1).

    Then there is the fr 920, where you can't pair a Tempe and it doesn't have SensorHistory.
  • Maybe Jim just needs to be shipped with every copy of the manual!
  • Actually, that post is about it, unless you want to include what devices/fonts don't have a degree symbol, but that's in the UX guide! :)