Unable to Stream and Log Temperature

edited March 2018 in Android

Hello Mbientlab,

I have been trying to stream and log Temperature data from a MetaMotion C board using the BOSCH env sensor on the device. However, no matter where I adjust the code placement for board.getModule(BarometerBosch.class).start();, I can't seem to get the temperature sensor to stream data continuously.

Currently it only streams a single temperature data point each time I start and then stop streaming.

I am attaching a minimum working example of the code below, and would really appreciate your assistance on this.

Also, I would also appreciate it if the API Reference for Android could be up again as it is currently down.

Thank you so much for your help and I look forward to your reply!

public class DataSensorFusionActivityExample extends AppCompatActivity implements ServiceConnection{
        public static final String METAWEAR_DEVICE_KEY = "MetaWearDeviceKey";
        private MetaWearBoard board;
        private BluetoothDevice btDevice;
        private static float temperatureData;
        private Temperature temperature;

        private static Subscriber temperatureStreamSubscriber = new Subscriber() {
            private static final long serialVersionUID = 5789372887305000501L;

            public void apply(Data data, Object... env) {
                Log.i("DataSensorFusion", "Temperature = " + data.value(Float.class));
                temperatureData = data.value(Float.class);

        public void startStreamingOnClick(View v) {
            try {

                Temperature.Sensor tempSensor = temperature.findSensors(Temperature.SensorType.BOSCH_ENV)[0];

                tempSensor.addRouteAsync(new RouteBuilder() {
                    public void configure(RouteComponent source) {
                }).continueWith(new Continuation<Route, Void>() {
                    public Void then(Task<Route> task) throws Exception {
//                        board.getModule(BarometerBosch.class).start();
                        return null;

            } catch(Exception e) {
                Log.e("Start Streaming", "Unexpected Exception while requesting to start streaming sensorfusion data", e);

        public void stopStreamingOnClick(View v) {

        public void onServiceConnected(ComponentName name, IBinder service) {
            board = ((BtleService.LocalBinder) service).getMetaWearBoard(btDevice);
            sensorFusion = board.getModule(SensorFusionBosch.class);
            temperature = board.getModule(Temperature.class);
//            board.getModule(BarometerBosch.class).start();
//            temperature.findSensors(Temperature.SensorType.BOSCH_ENV)[0].read();
This discussion has been closed.