CPRO NoMotion Detection

I try to received a message from CPRO when the sensor is fixed.I would like to check if the person wear the sensor is motionless for 5 seconds.
For this reason i would like to set a very low accelerometer sensibility, but i never receive NoMotion detection message.

I use this code :
accelModule.enableMotionDetection(Bmi160Accelerometer.MotionType.NO_MOTION);
//accelModule.configureNoMotionDetection().setThreshold(0.3f).setDuration(500);
accelModule.configureNoMotionDetection().setDuration(5000);
accelModule.routeData().fromMotion().stream("noMotion").commit().onComplete(new CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
super.success(result);
result.subscribe("noMotion", new RouteManager.MessageHandler() {
@Override
public void process(Message msg) {
Bmi160MotionMessage motionMsg = (Bmi160MotionMessage) msg;
Log.d("test","No Motion detected "+motionMsg.toString());
}
});
}
@Override
public void failure(Throwable error) {
super.failure(error);
Toast.makeText(MainActivity.this, "Motion failure"+error.getMessage(), Toast.LENGTH_LONG).show();
}
});

accelModule.start();
I wrong same think to detect NoMotion ?

It's possible detect NoMotion and stream fromYAxis or fromAxies (for this the code is in http://community.mbientlab.com/discussion/comment/2464#Comment_2464) at the same time ?

Comments

  • There is nothing in BMI160 spec sheet that says you can't stream and detect motion simultaneously.  What happens if you only run the no motion code?  The only thing that is incorrect is that you do not commit the configuration but the default settings still work.
  • The posted code is running alone, without other accelerometer configurations or streams.
    The process method is never invoke.
    I try to commit the configuration and resetDevice before next run, but without good news.
    I forgot somethink to do ?

  • edited May 2016
    Not sure what's wrong  Try placing a breakpoint in the process function to see if the body code is buggy as opposed to not being called period.

    This code works for me:
    final Bmi160Accelerometer accModule= mwBoard.getModule(Bmi160Accelerometer.class);
    accModule.routeData().fromMotion().stream("motion").commit()
            .onComplete(new CompletionHandler<RouteManager>() {
                @Override
                public void success(RouteManager result) {
                    result.subscribe("motion", new RouteManager.MessageHandler() {
                        @Override
                        public void process(Message msg) {
                            Log.i("test", "No motion");
                        }
                    });
                    accModule.configureNoMotionDetection().setDuration(5000).commit();
                    accModule.enableMotionDetection(Bmi160Accelerometer.MotionType.NO_MOTION);
                    accModule.start();
                }
            });
  • Great Eric,
       your source work fine.

    I try together the NoMotion, and fromYAxis with success too.

    Thank you very much for you important support.

    Bye Roberto
This discussion has been closed.