Simple test
Ensure your device works with this simple test.
examples/bma423_simpletest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bma423
i2c = board.I2C() # uses board.SCL and board.SDA
bma = bma423.BMA423(i2c)
for i in range(10):
print(bma.acceleration)
print(bma.temperature)
time.sleep(2)
|
Output data rate settings
Example showing the Output data rate setting
examples/bma423_output_data_rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bma423
i2c = board.I2C()
bma = bma423.BMA423(i2c)
bma.output_data_rate = bma423.BANDWIDTH_25_2
while True:
for output_data_rate in bma423.output_data_rate_values:
print("Current Output data rate setting: ", bma.output_data_rate)
for _ in range(10):
accx, accy, accz = bma.acceleration
print("x:{:.2f}m/s2, y:{:.2f}m/s2, z:{:.2f}m/s2".format(accx, accy, accz))
time.sleep(0.5)
bma.output_data_rate = output_data_rate
|
Oversample rate settings
Example showing the Oversample rate setting
examples/bma423_oversample_rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bma423
i2c = board.I2C()
bma = bma423.BMA423(i2c)
bma.oversample_rate = bma423.OSR32
while True:
for oversample_rate in bma423.oversample_rate_values:
print("Current Oversample rate setting: ", bma.oversample_rate)
for _ in range(10):
accx, accy, accz = bma.acceleration
print("x:{:.2f}m/s2, y:{:.2f}m/s2, z:{:.2f}m/s2".format(accx, accy, accz))
time.sleep(0.5)
bma.oversample_rate = oversample_rate
|
Acc range settings
Example showing the Acc range setting
examples/bma423_acc_range.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import bma423
i2c = board.I2C()
bma = bma423.BMA423(i2c)
bma.acc_range = bma423.ACC_RANGE_8
while True:
for acc_range in bma423.acc_range_values:
print("Current Acc range setting: ", bma.acc_range)
for _ in range(10):
accx, accy, accz = bma.acceleration
print("x:{:.2f}m/s2, y:{:.2f}m/s2, z:{:.2f}m/s2".format(accx, accy, accz))
time.sleep(0.5)
bma.acc_range = acc_range
|