Hello,
I'm using the BMX055 in a company's project. I read the data using the bma2x2_driver, bmg160_driver and bmm150_sensor_api for ACC, GYRO and MAG respectively.
The data coming from ACC and DATA seem to be fine, whereas the data from the MAG doesn't seem relyable.
As a preliminary test I'm using the smartphone compass to detect the North, in order to compare it with the result I get from the BMX055. Since the results are very different and the readings from the BMX055 are varying over time I tried to perform a self test:
- the normal test completes successfully
- the advanced test always fails (I used 3 different boards)
Here is a snipped of my code:
static struct bmm150_dev dev;
s8 initMAG(void) {
s8 ret = BMM150_OK;
/* Sensor interface over I2C */
dev.dev_id = BMM150_DEFAULT_I2C_ADDRESS;
dev.intf = BMM150_I2C_INTF;
dev.read = user_i2c_read;
dev.write = user_i2c_write;
dev.delay_ms = user_delay_ms;
ret = bmm150_init(&dev);
if(ret != 0) {
ESP_LOGE(TAG_IMU, "Error initializing the magnetometer. Error code: %d", ret);
}
ret += perform_mag_self_tests();
/* Setting the power mode as normal */
dev.settings.pwr_mode = BMM150_NORMAL_MODE;
ret += bmm150_set_op_mode(&dev);
/* Setting the preset mode as Low power mode
i.e. data rate = 10Hz XY-rep = 1 Z-rep = 2*/
dev.settings.preset_mode = BMM150_PRESETMODE_REGULAR;
ret += bmm150_set_presetmode(&dev);
return ret;
}
where:
int8_t perform_mag_self_tests(void)
{
int8_t rslt;
/* Perform Normal Self test */
rslt = bmm150_perform_self_test(BMM150_NORMAL_SELF_TEST, &dev);
ESP_LOGI(TAG_IMU, "NORMAL SELF TEST RESULT : %d", rslt);
/* Validate normal self test result */
if (rslt == BMM150_OK) {
ESP_LOGI(TAG_IMU, "Normal Self test passed");
} else {
ESP_LOGE(TAG_IMU, "Normal Self test failed");
}
/* Perform Advanced Self test */
rslt |= bmm150_perform_self_test(BMM150_ADVANCED_SELF_TEST, &dev);
ESP_LOGI(TAG_IMU, "ADVANCED SELF TEST RESULT : %d", rslt);
/* Validate Advanced self test result */
if (rslt == BMM150_OK) {
ESP_LOGI(TAG_IMU, "Advanced Self test passed");
} else {
ESP_LOGE(TAG_IMU, "Advanced Self test failed");
}
return rslt;
}
Could you please help me identifying the problem?
Thank you!