|
| 1 | +# Bosch BMI270 inertial measurement unit driver |
| 2 | + |
| 3 | +[](https://components.espressif.com/components/espressif/bmi270) |
| 4 | + |
| 5 | + |
| 6 | +## Features |
| 7 | + |
| 8 | +- Reading of the chip ID. |
| 9 | +- Configuring output data rate and range of the onboard accelerometer and gyroscope. |
| 10 | +- Reading normalized float values of acceleration and rotation angle. |
| 11 | + |
| 12 | +### Limitations |
| 13 | + |
| 14 | +- Missing implementation of the SPI interface. |
| 15 | +- Advanced features such as gesture control, FIFO buffering, interrupt on data ready and auxilary interface are not supported. |
| 16 | + |
| 17 | +## Integration guide |
| 18 | + |
| 19 | +This driver, along with many other components from this repository, can be used as a package from [Espressif's IDF Component Registry](https://components.espressif.com). To include this driver in your project, run the following idf.py from the project's root directory: |
| 20 | + |
| 21 | +``` sh |
| 22 | +idf.py add-dependency "espressif/bmi270==*" |
| 23 | +``` |
| 24 | + |
| 25 | +## Usage guide |
| 26 | + |
| 27 | +### Low level driver |
| 28 | +When using the low level driver directly then firstly initialize it by providing a valid low level driver configuration: |
| 29 | +``` c |
| 30 | +const bmi270_driver_config_t driver_config = { |
| 31 | + .addr = addr, |
| 32 | + .interface = BMI270_USE_I2C, |
| 33 | + .i2c_bus = i2c_bus_handle |
| 34 | +}; |
| 35 | +bmi270_create(&driver_config, &bmi270_handle_pointer); |
| 36 | +``` |
| 37 | +Start acquisition with a valid measurement configuration: |
| 38 | +``` c |
| 39 | +const bmi270_config_t measurement_config = { |
| 40 | + .acce_odr = BMI270_ACC_ODR_X, |
| 41 | + .acce_range = BMI270_ACC_RANGE_X, |
| 42 | + .gyro_odr = BMI270_GYR_ODR_X, |
| 43 | + .gyro_range = BMI270_GYR_RANGE_X |
| 44 | +}; |
| 45 | +bmi270_start(bmi270_handle_pointer, &measurement_config); |
| 46 | +``` |
| 47 | +After a completed measurement data can be read using: |
| 48 | +``` c |
| 49 | +bmi270_get_acce_data(bmi270_handle_pointer, &x, &y, &z); |
| 50 | +``` |
| 51 | +Disable measurements and clean up the BMI270 driver using: |
| 52 | +``` c |
| 53 | +bmi270_stop(bmi270_handle_pointer); |
| 54 | +bmi270_delete(bmi270_handle_pointer); |
| 55 | +bmi270_handle_pointer = NULL; |
| 56 | +``` |
| 57 | + |
| 58 | +### Espressif sensor hub |
| 59 | + |
| 60 | +This driver can be used with [sensor-hub](https://docs.espressif.com/projects/esp-iot-solution/en/latest/sensors/sensor_hub.html) abstraction. |
| 61 | +Create a BMI270 sensor instance using a valid configuration: |
| 62 | +``` c |
| 63 | +iot_sensor_create("sensor_hub_bmi270", &bmi270_sensor_hub_configuration, sensor_handle_pointer); |
| 64 | +``` |
| 65 | +
|
| 66 | +## Driver structure |
| 67 | +
|
| 68 | +``` |
| 69 | +BMI270 |
| 70 | +├── CMakeLists.txt # Driver component CMake file |
| 71 | +├── README.md |
| 72 | +├── idf_component.yml # Driver component configuration file |
| 73 | +├── include # Public include folder |
| 74 | +│ └── bmi270.h |
| 75 | +├── include_priv # Private include folder |
| 76 | +│ └── bmi270_priv.h |
| 77 | +├── license.txt |
| 78 | +├── src |
| 79 | +│ ├── bmi270.c # Low level driver source file |
| 80 | +│ └── bmi270_sensor_hub.c # Sensor-hub wrapper |
| 81 | +└── test_app # Test app for the low level driver |
| 82 | + ├── CMakeLists.txt |
| 83 | + ├── main |
| 84 | + │ ├── CMakeLists.txt |
| 85 | + │ ├── idf_component.yml |
| 86 | + │ └── test_app_bmi270.c |
| 87 | + └── sdkconfig.defaults |
| 88 | +``` |
| 89 | +
|
| 90 | +## See also |
| 91 | +[BMI270 datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi270-ds000.pdf) |
| 92 | +[ESP-IDF component registry documentation](https://docs.espressif.com/projects/idf-component-manager/en/latest/) |
| 93 | +[Sensor hub documentation](https://docs.espressif.com/projects/esp-iot-solution/en/latest/sensors/sensor_hub.html) |
0 commit comments