bma423

BMA423 Bosch Accelerometer CircuitPython Driver included in the Lilygo Watch V3

  • Author(s): Jose D. Montoya

class bma423.BMA423(i2c_bus: busio.I2C, address: int = 0x19)[source]

Driver for the BMA400 Sensor connected over I2C.

Parameters:
i2c_bus : I2C

The I2C bus the BMA423 is connected to.

address : int

The I2C device address. Defaults to 0x19

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

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

import board
import bma423

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

i2c = board.I2C()  # uses board.SCL and board.SDA
bma = bma423.BMA423(i2c)

Now you have access to the attributes

accx, accy, accz = bma.acceleration
property acc_range : str

Sensor acc_range

Mode

Value

bma423.ACC_RANGE_2

0x00

bma423.ACC_RANGE_4

0x01

bma423.ACC_RANGE_8

0x02

bma423.ACC_RANGE_16

0x03

property acceleration : tuple[float, float, float]

Acceleration :return: acceleration

property filter_performance : str

Sensor filter_performance

Mode

Value

bma423.CIC_AVG

0x00

bma423.CONT

0x01

property output_data_rate : str

Sensor output_data_rate

Mode

Value

bma423.BANDWIDTH_25_32

0b0001

bma423.BANDWIDTH_25_16

0b0010

bma423.BANDWIDTH_25_8

0b0011

bma423.BANDWIDTH_25_4

0b0100

bma423.BANDWIDTH_25_2

0b0101

bma423.BANDWIDTH_25

0b0110

bma423.BANDWIDTH_50

0b0111

bma423.BANDWIDTH_100

0b1000

bma423.BANDWIDTH_200

0b1001

bma423.BANDWIDTH_400

0b1010

bma423.BANDWIDTH_800

0b1011

bma423.BANDWIDTH_1600

0b1100

property oversample_rate : str

Sensor oversample_rate. Bandwidth parameter, determines filter configuration (acc_perf_mode=1) and averaging for undersampling mode (acc_perf_mode=0)

Mode

Value

bma423.OSR1

0x00

bma423.OSR2

0x01

bma423.OSR4

0x02

bma423.OSR8

0x03

bma423.OSR16

0x04

bma423.OSR32

0x05

bma423.OSR64

0x06

bma423.OSR128

0x07

property temperature : float

The temperature sensor is calibrated with a precision of +/-5°C. :return: Temperature