Temperature show error
When this happens the temperature only shows the number 2 withouth updating or showing the real data, I've tested all the formats that are commented and none of them works, someone knows how to fix this?
protected void boardReady(MetaWearBoard mwBoard, TextView current_temp) throws com.mbientlab.metawear.UnsupportedModuleException
{
this.mwBoard = mwBoard;
tempModule= this.mwBoard.getModuleOrThrow(Temperature.class);
timerModule = this.mwBoard.getModuleOrThrow(Timer.class);
Temperature.Sensor tempsensor = tempModule.sensors()[0];
tempsensor.addRouteAsync(source -> source.stream((data, env) -> {
//current_temp.setText(String.format(Locale.US,"%.1fº",data.value(Float.class)));
current_temp.setText((data.value(Float.class).toString()));
//current_temp.setText(String.format(Locale.US, "%d", data.value(Float.class)));
//TemperaturaReader.this.current_temp.setText("Temperature (C) = " + data.value(Float.class).toString());
}
)).continueWithTask(task -> {
streamRoute = task.getResult();
return timerModule.scheduleAsync(TEMP_SAMPLE_PERIOD, false, tempsensor::read);
}).continueWithTask(task -> {
if(task.isFaulted()) {
Log.e("boardReady", task.getError().getMessage());
}
scheduledTask = task.getResult();
scheduledTask.start();
return null;
});
}
This discussion has been closed.
Comments
data
variable?data.value(Float.class)
returns. Are you receiving reasonable values?