04-03-2019 02:17 PM
Hi,
I want to set an interruption with significant motion detector using BMI160. It works with accelerometer in normal mode and gyro in suspend mode, but I want to use it with accelerometer in low power mode and it doesn't work. The datasheet of the sensor specifies the current consumption for "Significant motion detector, gyro in suspend, accel in low power mode @50Hz", so I guess it is possible. Which parameters do I need to set for low power mode and significant motion interruption?
Thanks!
Solved! Go to Solution.
04-05-2019 02:14 PM
Hi,
This has been asnwer on this post:
Regards
05-17-2019 11:00 AM - edited 05-17-2019 04:07 PM
Hi, i'm facing a similar problem with any motion interrupt. I created a task and configured the BMI160 in normal mode but I don't know where is the problem to have an interrupt. Please someone can help me.
void task_bmi160_normal_mode()
{
//esp_sleep_enable_ext0_wakeup(GPIO_NUM_4, 1);
//gpio_set_direction(GPIO_NUM_4, GPIO_MODE_INPUT);
/* Select the Interrupt channel/pin */
int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_ANY_MOTION_INT;// Choosing Any motion interrupt
/* Select the interrupt channel/pin settings */
int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
int_config.int_pin_settg.output_mode = BMI160_ENABLE;// Choosing push-pull mode for interrupt pin
int_config.int_pin_settg.output_type = BMI160_DISABLE;// Choosing active low output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;// non-latched output
/* Select the Any-motion interrupt parameters */
int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_ENABLE;// 1- Enable the any-motion, 0- disable any-motion
int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE;// Enabling x-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE;// Enabling y-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE;// Enabling z-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 0;// any-motion duration
int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 20;// (2-g range) -> (slope_thr) * 3.91 mg, (4-g range) -> (slope_thr) * 7.81 mg, (8-g range) ->(slope_thr) * 15.63 mg, (16-g range) -> (slope_thr) * 31.25 mg
/* Set the Any-motion interrupt */
bmi160_set_int_config(&int_config, &sensor_bmi160); /* sensor is an instance of the structure bmi160_dev */
while (1)
{
bmi160_get_sensor_data((BMI160_ACCEL_SEL | BMI160_GYRO_SEL | BMI160_TIME_SEL), &accel, &gyro, &imu->sensor_bmi160);
#if 0
float ax = convert_raw_acceleration(accel.x);//
float ay = convert_raw_acceleration(accel.y);
float az = convert_raw_acceleration(accel.z);
float gx = convert_raw_gyro(gyro.x);
float gy = convert_raw_gyro(gyro.y);
float gz = convert_raw_gyro(gyro.z);
#endif
float ax = getAccelerationBMI160_x();//
float ay = getAccelerationBMI160_x();
float az = getAccelerationBMI160_x();
float gx = getGyroBMI160_x();
float gy = getGyroBMI160_y();
float gz = getGyroBMI160_z();
ESP_LOGI(TAG, "[ACCEL] X: %2f, Y: %2f, Z: %2f", ax, ay, az);
ESP_LOGI(TAG, "[GYRO] X: %2f, Y: %2f, Z: %2f", gx, gy, gz);
int_status_sel = BMI160_INT_STATUS_ALL;
rslt = bmi160_get_int_status(int_status_sel, &interrupt, &sensor_bmi160);
if (interrupt.bit.anym)
printf("Step detector interrupt occured\n");
//esp_light_sleep_start();
/* Task delay */
vTaskDelay(10 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}