Accelerometer type not found: MBL_MW_MODULE_TYPE_NA

Hello!
I'm trying to interface with the MMRL+ sensor with the c++ api and a microcontroller.
I can connect, read & write (for example control the haptic motor).

But I can't read accelerometer data, the base of this problem seems to be that the Accelerometer type is not found, I get 'MBL_MW_MODULE_TYPE_NA' when running:

void check_acc_type(MblMwMetaWearBoard* board) {
  auto acc_type= mbl_mw_metawearboard_lookup_module(board, MBL_MW_MODULE_ACCELEROMETER);
  switch(acc_type) {
  case MBL_MW_MODULE_TYPE_NA:
      // should never reach this case statement
      printf("No accelerometer on this board\n");
      break;
  case MBL_MW_MODULE_ACC_TYPE_MMA8452Q:
      printf("Acc Type = MMA8452Q\n");
      break;
  case MBL_MW_MODULE_ACC_TYPE_BMI160:
      printf("Acc Type = BMI160\n");
      break;
  case MBL_MW_MODULE_ACC_TYPE_BMI270:
      printf("Acc Type = BMI160\n");
      break;
  case MBL_MW_MODULE_ACC_TYPE_BMA255:
      printf("Acc Type = BMA255\n");
      break;
  default:
      printf("Unknown type\n");
      break;
  }
}

Any idea what can be at the base of this problem?
Debug output in the attached file.

Thanks in advance!

Comments

  • What does the diagnostic say from the MetaBase App?

  • edited June 11

    Hi @Laura,
    Thank you for the quick reply.

    I've added the diagnostics as attachment, looks all fine to me, the accelerometer module is there and has an implementation of 1, which corresponds to the BMI160 = Good. So the less good part is obviously my code.

    From the debug output I see that the function "mbl_mw_metawearboard_lookup_module" doesn't read values from the metaboard with a new BLE-read, so board->module_info should already be populated by the initialization?

    int32_t mbl_mw_metawearboard_lookup_module(const MblMwMetaWearBoard *board, MblMwModule module) {
        auto it = board->module_info.find(module);
        return it == board->module_info.end() || !it->second.present ? MBL_MW_MODULE_TYPE_NA : it->second.implementation;
    }
    
  • So if it's in the diagnostic but not working in your code, then the issue is with your code syntax.
    The module info does get populated when the SDK initializes (right after a connection is secured).

  • edited June 11

    Okay Thanks Laura! I'll do some digging !

Sign In or Register to comment.