Hi neerajverma,
if I'm not mistaken, all the sensors are asleep by default. You first have to initialize them and turn them on before you can fetch data. Maybe this is where the problem lies. This is the configuration that I use:
a) initialization
bmi.id = 0;
bmi.interface = BMI160_SPI_INTF;
bmi.read = spi_read_transfer;
bmi.write = spi_write_transfer;
bmi.delay_ms = delay;
bmi160_init(&bmi);
b) turning sensors on
//Acc
bmi.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
bmi.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
bmi.accel_cfg.range = BMI160_ACCEL_RANGE_4G;
bmi.accel_cfg.odr = BMI160_ACCEL_ODR_200HZ;
//Gyro
bmi.gyro_cfg.odr = BMI160_GYRO_ODR_200HZ;
bmi.gyro_cfg.range = BMI160_GYRO_RANGE_1000_DPS;
bmi.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
bmi.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
bmi160_set_sens_conf(&bmi);
c) fetching data
bmi160_get_sensor_data((BMI160_TIME_SEL | BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel_data, &gyro_data, &bmi);
To clarify, 'spi_read_transfer', 'spi_write_transfer' and 'delay' are master-chip specific functions for spi transfers and delay. 'bmi' is a structure of type bmi160_dev, 'accel_data' and 'gyro_data' are of type bmi160_sensor_data.
In my project I also use the magnetometer, but I removed those parts of code to minimize confusion.
Disclamer: I'm not a Bosch employee, so this is just a guess.
Kind regards,
Marko Njirjak
Hi neerajverma,
If you are having issues getting started with BMX160, I would recommend to start your own thread and provide a link to this one in your description, and why the solution here does not work for you.
Since this thread is marked as "solved" it is confusing to continue the discussion of more issues here.
Ok, sure. let me start new thread.
Good day,
I am using the bmi160 and bmm150...I have used this post as a reference to develop my bsxLite fusion .
I was hoping someone could shed some light on feeding the fusion library. When using the struct "libraryinput_t" to feed the library, do i set the relevant variable i create to my sensor struct "bmi160_sensordata"? I have attached a screenshot of my code.
Hi Lashca_Pieterse,
BSX fusion library is a standalone piece of software that accepts accelerometer, gyroscope and magnetometer measurements on one end and gives filtered data on the other end. With that in mind, you first need to fetch the data, preferably through Bosch drivers and than feed it to the library. The library accepts LSB format, which means that the data you fetch through Bosch drivers is pretty much tailored to your needs.
Your code looks fine, the only thing that is missing is the data fetch before feeding it to the library. Here's an example for fetching accelerometer and gyroscope data:
bmi160_get_sensor_data((BMI160_TIME_SEL | BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel_data, &gyro_data, &bmi);
P.S. You're missing magnetometer timestamp. For now, you can set is a gyroscope or accelerometer timestamp.
Kind regards,
Marko Njirjak