MicroPython BMI270 Library

bmi270

MicroPython Driver for the Bosch BMI270 Accelerometer/Gyro Sensor

  • Author(s): Jose D. Montoya

class micropython_bmi270.bmi270.BMI270(i2c, address: int = 0x68)[source]

Driver for the BMI270 Sensor connected over I2C.

Parameters:
i2c : I2C

The I2C bus the BMI270 is connected to.

address : int

The I2C device address. Defaults to 0x68

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the BMI270 class. First you will need to import the libraries to use the sensor

from machine import Pin, I2C
from micropython_bmi270 import bmi270

Once this is done you can define your machine.I2C object and define your sensor object

i2c = I2C(1, sda=Pin(2), scl=Pin(3))
bmi270 = bmi270.BMI270(i2c)

Now you have access to the attributes

acc_x, acc_y, acc_z = bmi270.acceleration
property acceleration : tuple[float, float, float]

Sensor Acceleration in \(m/s^2\)

property acceleration_operation_mode : str

Sensor acceleration_operation_mode

Mode

Value

bmi270.ACCELERATOR_DISABLED

0b0

bmi270.ACCELERATOR_ENABLED

0b1

property acceleration_range : str

Sensor acceleration_range

Mode

Value

bmi270.ACCEL_RANGE_2G

0b00

bmi270.ACCEL_RANGE_4G

0b01

bmi270.ACCEL_RANGE_8G

0b10

bmi270.ACCEL_RANGE_16G

0b11

error_code() None[source]

The register is meant for debug purposes, not for regular verification if an operation completed successfully.

Fatal Error: Error during bootup. This flag will not be cleared after reading the register.The only way to clear the flag is a POR.

property gyro : tuple[float, float, float]

Gyro values

property gyro_range : str

Sensor gyro_range

Mode

Value

bmi270.GYRO_RANGE_2000

0b000

bmi270.GYRO_RANGE_1000

0b001

bmi270.GYRO_RANGE_500

0b010

bmi270.GYRO_RANGE_250

0b011

bmi270.GYRO_RANGE_125

0b100

load_config_file() None[source]

Load configuration file. This is necessary to use the sensor. Script adapted to use with MicroPython from: https://github.com/CoRoLab-Berlin/bmi270_python (c) 2023 MIT License Kevin Sommler

soft_reset() None[source]

Performs a Soft Reset

Returns:

None