BMI160 Accelerometer

The BMI160 accelerometer is the most commonly used accelerometer on the available MbientLab boards and has additional features not available on the BMA255. It also comes with a gyroscrope giving 6 degrees of freedom.

using MbientLab.MetaWear.Sensor;

IAccelerometerBmi160 accBmi160 = metawear.GetModule<IAccelerometerBmi160>();

Output Data Rate

Available output data rates for the BMI160 device is enumerated by its OutputDataRate enum. You can use these entries to set the ODR to a known quantity.

using MbientLab.MetaWear.Sensor;
using MbientLab.MetaWear.Sensor.AccelerometerBmi160;
using MbientLab.MetaWear.Sensor.AccelerometerBosch;

// set odr to 25Hz
// set range to +/-4g
accBmi160.Configure(odr: OutputDataRate._25Hz, range: DataRange._4g);

Step Detection

The BMI160 chip comes with a step detection algorithm that can either send an interupt for every step detected (async producer) or accumulate the steps in a counter that returns the value when requested (forced producer). The algorithm has 3 operational modes that modify the sensitivity and robustness of the detector. It is important that you set the mode before using the detection algorithm.

Mode Description
Normal Balanced between false positives and false negatives, recommended for most applications
Sensitive Few false negatives but eventually more false positives, recommended for light weighted people
Robust Few false positives but eventually more false negatives

Data from both the counter and detector are unsigned integers with the step counter able to count to 2^16 steps (2 bytes).

using MbientLab.MetaWear.Sensor.AccelerometerBmi160;

var detector = accBmi160.StepDetector;

// Configuration the algorithm to run as a detector
// using normal detection mode
detector.Configure(mode: StepDetectorMode.Normal);
await detector.AddRouteAsync(source => source.Stream(data => Console.WriteLine("Took a step")));

detector.Start();
accelerometer.Start();

Significant Motion

The BMI160 chip also has an additional motion detection algorithm that detects significant motion i.e. a change in location from walking or being in a moving vehicle. It detects this type of motion by sleeping for a period of time (skip time), when motion is first detected, then still detecting motion for a window of time (proof time) when waking up.

using MbientLab.MetaWear.Sensor.AccelerometerBmi160;

accBmi160.Motion.ConfigureSignificant(proof: ProofTime._1s, skip: SkipTime._1_5s);
await accBmi160.Motion.AddRouteAsync(source =>
    source.Stream(data => Console.WriteLine("significant motion detected"))
);

accBmi160.Motion.Start();
accBmi160.Start();