Download sensor value error

Hi,

I'm using metatracker to log sensor data
- temperature with 30 minutes timer
- humidity with 30 minutes timer
- light with threshold at 10 lux
- accelometer (odr 25) with threshold

Sometimes I have errors in download data:
- I don't receive temperature and humidity data
- all temperature value at - 3000 or humidity at 0 and light at 0.

I have tried its with different devices and different smartphones.

Can you help me?

Comments

  • Post your code and we can try it out on our end.

  • My setup Temperature and humidity sensor code :

            humidity = mwBoard.getModule ( HumidityBme280.class );
            humidity.setOversampling ( HumidityBme280.OversamplingMode.SETTING_16X );
    
    
            final Task <Timer.ScheduledTask> objectTask2 = humidity.value ().addRouteAsync ( new RouteBuilder () {
                @Override
                public void configure(RouteComponent source) {
                    source.log ( new Subscriber () {
                        @Override
                        public void apply(Data data, Object... env) {
                            Log.i("FD_H",data.value ( Float.class ).toString()+" "+data.formattedTimestamp ());
                            ndati=ndati+1;
                            if(data.value ( Float.class )>=1 && data.value ( Float.class )<=100){
                                DateFormat inputFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS" );
                                Date date = null;
                                try {
                                    date = inputFormat.parse ( data.formattedTimestamp () );
                                } catch (ParseException e) {
                                    e.printStackTrace ();
                                }
    
                                //date.setTimeZone( TimeZone.getTimeZone("UTC"));
                                        long epochH ;
                                        epochH= date.getTime ();
    
                                            if (flaginizioRH == 0) {
                                                umidity = umidity + ",";
                                            } else {
                                                flaginizioRH = 0;
                                            }
                                            umidity = umidity + "{\"timestamp\":" + (Long.toString( epochH / 1000L )) + ",\"data\":" + data.value( Float.class ) + "}";
    
                                            umidityend = "HUMIDITY: " + data.value( Float.class ) + "% [ " + data.formattedTimestamp() + "]";
    
                            }else{
                                erroridati=erroridati+1;
                            }}
                    } );
                }
            } ).continueWithTask ( Task -> {
                return timerModule.scheduleAsync ( 1800000, true, humidity.value ()::read );
            } ).continueWithTask ( Task -> {
                scheduledTask2 = Task.getResult ();
               // if (scheduledTask != null && scheduledTask3 != null)
                flagtask2=true;
                Log.i("FD", "fine_rh");
                if(flagtask1&&flagtask2&&flagtask3&&flagtask4&&flagtask5&&flagtask6)
                    finishWithScheduledTasks ();
                return null;
            } );
    
            temperature = mwBoard.getModule ( Temperature.class );
            tempSensor = temperature.findSensors ( Temperature.SensorType.BOSCH_ENV )[0];
    
            final Task <Timer.ScheduledTask> objectTask = tempSensor.addRouteAsync ( new RouteBuilder () {
                @Override
                public void configure(RouteComponent source) {
                    source.log ( new Subscriber () {
                        @Override
                        public void apply(Data data, Object... env) {
                            Log.i("FD_T",data.value ( Float.class ).toString()+" "+data.formattedTimestamp ());
                            ndati=ndati+1;
                            if(data.value( Float.class )>=-20 && data.value ( Float.class )<=80){
                                DateFormat inputFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS" );
                                Date date = null;
                                try {
                                    date = inputFormat.parse ( data.formattedTimestamp () );
                                } catch (ParseException e) {
                                    e.printStackTrace ();
                                }
    
                                long epoch = date.getTime ();
    
    
    
                                    if (flaginizioT == 0) {
                                        temp = temp + ",";
                                    } else {
                                        flaginizioT = 0;
                                    }
                                    temp = temp + "{\"timestamp\":" + (Long.toString( epoch / 1000L )) + ",\"data\":" + data.value( Float.class ) + "}";
    
                                    tempend = "TEMPERATURE: " + data.value( Float.class ) + "C [ " + data.formattedTimestamp() + "]";
    
                            }else{
                                erroridati=erroridati+1;
                            }}
                    } );
                }
            } ).continueWithTask ( Task -> {
                return timerModule.scheduleAsync ( 1810000, true, tempSensor::read );
            } ).continueWithTask ( Task -> {
                scheduledTask = Task.getResult ();
                //if (scheduledTask2 != null && scheduledTask3 != null )
                flagtask1=true;
                Log.i("FD", "fine_T");
                if(flagtask1&&flagtask2&&flagtask3&&flagtask4&&flagtask5&&flagtask6)
                    finishWithScheduledTasks ();
                return null;
            } );
    
  • I've setup a test to read temp and humidity every 30 min. A few questions for you:

    • Can this issue be reliably reproduced?
    • How long were you sampling the data in your tests?
    • Do you have the same issues if you collect temperature data with the preset thermistor instead of the Bosch env sensor?
    • What are the hardware and firmware revisions of your boards?
  • Hi,

    • No, we aren't able to reproduced the issue.
    • We have tested it with different timing, 40 minutes and also days. We have changed also the timing from 30 seconds to 60 minutes.
    • I will test it
    • hardware revision 1.3.6

    I have other info for you, maybe they can help:

    1) We have sniffed the ble packages and we have tested that:

    • in the download without data packages error we have all right value
    • in the downlaod with error in one or more data package we cannot read all sensor values

    2) We have tested it with iphone and in that case we never lost the values but some time we read some wrong Temperature value at 0. Maybe is it the same error but with different interpratation?

    Thanks
    Alberto

  • Sorry: Hardware revision r0.2 I think and firmware 1.3.6

  • edited March 2018

    Can you also post the code for the light and accelerometer?
    Also, what Android devices / OS are you testing with?

  • We have used:
    Iphone 6 and 7
    Huawei p9 e p8, samsung s8 plus, note 3, samsung j7 and other

    My accelorometer and light setup code:

    accelerometer.configure ().odr ( 25.0f ).commit ();

        alLtr329.configure ().gain ( AmbientLightLtr329.Gain.LTR329_8X ).integrationTime ( AmbientLightLtr329.IntegrationTime.LTR329_TIME_400MS ).measurementRate ( AmbientLightLtr329.MeasurementRate.LTR329_RATE_1000MS ).commit ();
    
        alLtr329.illuminance ().addRouteAsync ( new RouteBuilder () {
            @Override
            public void configure(RouteComponent source) {
    
                source.multicast ().to ().filter ( ThresholdOutput.ABSOLUTE, 10.f ).log ( new Subscriber () {
                    //   source.limit(10).log( new Subscriber() {
                    @Override
                    public void apply(Data data, Object... env) {
                        Log.i("FD_L",data.value ( Float.class ).toString());
                        ndati=ndati+1;
                        if(data.value ( Float.class )>=0) {
                            DateFormat inputFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS" );
                            Date date = null;
                            try {
                                date = inputFormat.parse ( data.formattedTimestamp () );
                            } catch (ParseException e) {
                                e.printStackTrace ();
                            }
    
                            long epoch = date.getTime ();
                            if (flaginizioL == 0) {
                                light = light + ",";
                            } else {
                                flaginizioL = 0;
                            }
    
                            light = light + "{\"timestamp\":" + (Long.toString ( epoch / 1000L )) + ",\"data\":" + data.value ( Float.class ) + "}";
                            lightend = "LIGHT: "+data.value ( Float.class ) + "lx [ " + data.formattedTimestamp () + "]";
    
    
                        }else{
                            erroridati=erroridati+1;
                        }
    
                    }
    
                });
            }
        } ).continueWith(new Continuation<Route, Void>() {
            @Override
            public Void then(Task<Route> task) throws Exception {
                flagtask4=true;
                Log.i("FD", "fine_light");
                if(flagtask1&&flagtask2&&flagtask3&&flagtask4&&flagtask5&&flagtask6)
                    finishWithScheduledTasks ();
                return null;
            }
        });
    
        accelerometer.acceleration ().addRouteAsync ( new RouteBuilder () {
            @Override
            public void configure(RouteComponent source) {
                source.multicast ().
    
                        to ().split ().index ( 0 ).filter ( ThresholdOutput.ABSOLUTE, 0.0f, collo.getSensorMac ().equalsIgnoreCase ( "CE:33:EB:F1:EF:19" ) ? 0.05f : collo.getSensorMac ().equalsIgnoreCase ( "F6:3E:2D:BA:09:0B" ) ? 0.2f : 0.1f ).log ( new Subscriber () {
                    //    to().split().index(0).limit(10).log( new Subscriber() {
                    @Override
                    public void apply(Data data, Object... env) {
                        ndati=ndati+1;
                        DateFormat inputFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS" );
                        Date date = null;
                        try {
                            date = inputFormat.parse ( data.formattedTimestamp () );
                        } catch (ParseException e) {
                            e.printStackTrace ();
                        }
    
                        long epoch = date.getTime ();
                        if (timeX != (Math.round ( epoch / 1000L ))) {
                            if (flaginizioX == 0) {
                                accX = accX + ",";
                            } else {
                                flaginizioX = 0;
                            }
    
                            accX = accX + "{\"timestamp\":" + (Long.toString( epoch / 1000L )) + ",\"data\":" + data.value( Float.class ) + "}";
    
                            timeX = (Math.round( epoch / 1000L ));
                        }
    
                    }
                } ).
    
                        to ().split ().index ( 1 ).filter ( ThresholdOutput.ABSOLUTE, 1.f, collo.getSensorMac ().equalsIgnoreCase ( "CE:33:EB:F1:EF:19" ) ? 0.05f : collo.getSensorMac ().equalsIgnoreCase ( "F6:3E:2D:BA:09:0B" ) ? 0.2f : 0.1f ).log ( new Subscriber () {
                    //      to().split().index(1).limit(10).log( new Subscriber() {
                    @Override
                    public void apply(Data data, Object... env) {
                        ndati=ndati+1;
                        DateFormat inputFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS" );
                        Date date = null;
                        try {
                            date = inputFormat.parse ( data.formattedTimestamp () );
                        } catch (ParseException e) {
                            e.printStackTrace ();
                        }
    
                        long epoch = date.getTime ();
                        if (timeY != (Math.round ( epoch / 1000L ))) {
                            if (flaginizioY == 0) {
                                accY = accY + ",";
                            } else {
                                flaginizioY = 0;
                            }
    
                            accY = accY + "{\"timestamp\":" + (Long.toString ( epoch / 1000L )) + ",\"data\":" + data.value ( Float.class ) + "}";
    
                            timeY = (Math.round ( epoch / 1000L ));
                        }
                    }
                } ).
    
                        to ().split ().index ( 2 ).filter ( ThresholdOutput.ABSOLUTE, 0.0f, collo.getSensorMac ().equalsIgnoreCase ( "CE:33:EB:F1:EF:19" ) ? 0.05f : collo.getSensorMac ().equalsIgnoreCase ( "F6:3E:2D:BA:09:0B" ) ? 0.2f : 0.1f ).log ( new Subscriber () {
                    //to().split().index(2).limit(10).log( new Subscriber() {
                    @Override
                    public void apply(Data data, Object... env) {
                        ndati=ndati+1;
                        DateFormat inputFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS" );
                        Date date = null;
                        try {
                            date = inputFormat.parse ( data.formattedTimestamp () );
                        } catch (ParseException e) {
                            e.printStackTrace ();
                        }
    
                        long epoch = date.getTime ();
    
                        if (timeZ != (Math.round ( epoch / 1000L ))) {
                            if (flaginizioZ == 0) {
                                accZ = accZ + ",";
                            } else {
                                flaginizioZ = 0;
                            }
                            accZ = accZ + "{\"timestamp\":" + (Long.toString ( epoch / 1000L )) + ",\"data\":" + data.value ( Float.class ) + "}";
    
                            timeZ = (Math.round ( epoch / 1000L ));
                        }
                    }
                } );
    
    
            }
        } ).continueWith(new Continuation<Route, Void>() {
            @Override
            public Void then(Task<Route> task) throws Exception {
                Log.i("FD", "fine_acc");
                flagtask5=true;
                if(flagtask1&&flagtask2&&flagtask3&&flagtask4&&flagtask5&&flagtask6)
                    finishWithScheduledTasks ();
                return null;
            }
        });
    
  • Another info: Sometimes I have the some problem also with your metabase app.

  • I use metatracker in this way; maybe it can help:

    • First setup configuration (see before)
    • After some time i do teardown and stop logging and sensors --> setup configuration again --> download data --> restart sensor and logging.
  • After doing some tests, I suspect the root cause of these issues is that the battery is low on charge. How long have you been using the current batteries in your devices? If you put in a fresh CR2450 battery, do these issues arise?

  • we have tested it also with new battery.

  • edited March 2018
    • Can you attach the data you have collected so far? I would like to see if the data is simply all bad, or if it starts out good then eventually becomes invalid.
    • Since you are running the acc @ 25Hz, do you see the same issues if you don't use it?
    • Another test you should run is to insert a fresh battery and record the same data along with the battery state (charge & voltage).
      https://mbientlab.com/androiddocs/latest/settings.html#battery-state
  • HI,

    • in fault case, the temperature and humidity value are all bads or we don't have value. (I send you the file of metabase app in fault case).
    • Yes I have the same problem also without acc sensor
    • Yes we have tested to record also the battery charge.
  • I post an example of data reads with your app metabase:

    TEMPERATURE with timing at 30 seconds (Only the final values are rights, the other have wrong times and values):
    epoch (ms),time (01:00),elapsed (s),temperature (C)
    1538641158488,2018-10-04T10:19:18.488,0.000,4.000
    1538647890750,2018-10-04T12:11:30.750,6732.262,4.000
    1538647899435,2018-10-04T12:11:39.435,6740.947,4.000
    1538648284831,2018-10-04T12:18:04.831,7126.343,4.000
    1538648284851,2018-10-04T12:18:04.851,7126.363,4.000
    1538653712270,2018-10-04T13:48:32.270,12553.782,4.000
    1538655550541,2018-10-04T14:19:10.541,14392.053,4.000
    1538655975637,2018-10-04T14:26:15.637,14817.149,4.000
    1538705888714,2018-10-05T04:18:08.714,64730.223,4.000
    1538734266123,2018-10-05T12:11:06.123,93107.633,4.000
    1544990932563,2018-12-16T21:08:52.563,6349774.000,4.000
    1545019813689,2018-12-17T05:10:13.689,6378655.000,4.000
    1545019813708,2018-12-17T05:10:13.708,6378655.000,4.000
    1545023307055,2018-12-17T06:08:27.055,6382148.500,384.000
    1544932552566,2018-12-16T04:55:52.566,6291394.000,17.875
    1544932582564,2018-12-16T04:56:22.564,6291424.500,17.875
    1544932612564,2018-12-16T04:56:52.564,6291454.000,17.875
    1544932642566,2018-12-16T04:57:22.566,6291484.000,17.875
    1544932672566,2018-12-16T04:57:52.566,6291514.000,17.875
    1544932702566,2018-12-16T04:58:22.566,6291544.000,17.875

    in this case I have the HUMIDITY and LIGHT mixed

    • Accelorometer it's ok.
  • How long were you sampling data in that CSV file? It looks like there are lingering data points from previous logged data.

    I'll have more time to do another batch of tests tomorrow.

This discussion has been closed.