Tap detection with BMI160Accelerometer Metawear v3.0


I am using Metawear RPRO which has BMI160 accelerometer+gyro, want to do tap detection.
have been using Metawear api v2.3.0, but tap detection is not available with earlier so updated to v3, but in v3 lots of classes and methods have been either renamed or removed.
for e.g can't find AsyncOperation, RouteManager, connectionStatehandler, can someone help me with sample code for streaming data from sensor.



  • edited March 2017
    Documentation, sample code, etc. are provided in the api v3 thread:

    The project README has a section highlighting some important changes:

    If migrating to v3 is not something you have the time for at the moment, I suggest upgrading to the latest v2 release instead.
  • Thanks so much Eric.
    Trying in v2, sorry for being so naive, but not able to detect tap.In debugging also nothing caught up.

    stateHandler = new ConnectionStateHandler() {
    public void connected() {
    try {
    ledModule = mwBoard.getModule(Led.class);
    accelModule = mwBoard.getModule(Bmi160Accelerometer.class);
    loggingModule = mwBoard.getModule(Logging.class);
    gyroModule = mwBoard.getModule(Bmi160Gyro.class);

    } catch (UnsupportedModuleException e) {
    //Compound Switch Button//
    final Switch accel_switch = (Switch) findViewById(R.id.accel_switch);
    accel_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

    //Accelerometer & Gyro Routing//

    AsyncOperation routeManagerResultAccel = accelModule.routeData().fromAxes()

    AsyncOperation routeManagerResultGyro = gyroModule.routeData().fromAxes().stream(GYRO_STREAM_KEY).commit();
    routeManagerResultAccel.onComplete(new CompletionHandler() {
    public void success(RouteManager result) {
    result.subscribe(STREAM_KEY, new RouteManager.MessageHandler() {
    public void process(Message msg) {

    Log.i(TAG, String.format("Accelerometer %s %s", msg.getData(CartesianFloat.class), msg.getTimestampAsString()));
    sensorMsg(String.format(msg.getData(CartesianFloat.class).toString()), "accel");

    routeManagerResultGyro.onComplete(new CompletionHandler() {
    public void success(RouteManager result) {
    result.subscribe(GYRO_STREAM_KEY, new RouteManager.MessageHandler() {
    public void process(Message msg) {
    Log.i(TAG, String.format("Gyroscope %s %s", msg.getData(CartesianFloat.class), msg.getTimestampAsString()));

    sensorMsg(String.format(msg.getData(CartesianFloat.class).toString()), "gyro");


    // Route data from the chip's tap detector
    AsyncOperation routeManagerResultTap = accelModule.routeData().fromTap()
    routeManagerResultTap.onComplete(new CompletionHandler() {
    public void success(RouteManager result) {
    result.subscribe("tap", new RouteManager.MessageHandler() {
    public void process(Message msg) {
    TapResponse response= msg.getData(TapResponse.class);
    switch(response.type()) {
    case SINGLE:
    Log.i("MainActivity", "Single tap");
    case DOUBLE:
    Log.i("MainActivity", "Double tap");


  • Hi,
    Is there anything wrong with my code?
    I am able to get results from high/low detection and orientation detection, but not the tap detection.
    don't know what to do.
  • Double tap can be pretty finicky to configure correctly so you'll have to experiment with different configurations to find what works for your use case.
  • edited March 2017
    I configured with every possible combination but did not get any response at all.
    Could not detect tap even once.

  • edited March 2017
    These settings worked for me on an RPro board. I was also tapping the board directly so some further tweaking may be needed if you are using a case.
    AccelerometerBosch accBosch = metawear.getModule(AccelerometerBosch.class);
This discussion has been closed.