Simple test
Ensure your device works with this simple test.
examples/mc3479_simpletest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
from machine import Pin, I2C
import micropython_mc3479.mc3479 as MC3479
i2c = I2C(sda=Pin(8), scl=Pin(9)) # Correct I2C pins for UM FeatherS2
mc3479 = MC3479.MC3479(i2c)
while True:
accx, accy, accz = mc3479.acceleration
print(f"x:{accx:.2f}m/s^2 y:{accy:.2f}m/s^2 z:{accz:.2f}m/s^2")
print()
time.sleep(0.5)
|
Acceleration Data Range
Example showing how to change the acceleration data range
examples/mc3479_acceleration_range.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
from machine import Pin, I2C
import micropython_mc3479.mc3479 as MC3479
i2c = I2C(sda=Pin(8), scl=Pin(9)) # Correct I2C pins for UM FeatherS2
mc3479 = MC3479.MC3479(i2c)
while True:
for acc_rate in MC3479.accel_data_rate_values:
print(
"Current Acceleration Data Rate Setting: ",
mc3479.acceleration_output_data_rate,
)
for _ in range(10):
accx, accy, accz = mc3479.acceleration
print(f"x:{accx:.2f}m/s^2 y:{accy:.2f}m/s^2 z:{accz:.2f}m/s^2")
print()
time.sleep(0.5)
mc3479.acceleration_output_data_rate = acc_rate
|
Acceleration Data Rate
Example showing how to change the acceleration data rate
examples/mc3479_datarate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
from machine import Pin, I2C
import micropython_mc3479.mc3479 as MC3479
i2c = I2C(sda=Pin(8), scl=Pin(9)) # Correct I2C pins for UM FeatherS2
mc3479 = MC3479.MC3479(i2c)
while True:
for acc_rate in MC3479.accel_data_rate_values:
print(
"Current Acceleration Data Rate Setting: ",
mc3479.acceleration_output_data_rate,
)
for _ in range(10):
accx, accy, accz = mc3479.acceleration
print(f"x:{accx:.2f}m/s^2 y:{accy:.2f}m/s^2 z:{accz:.2f}m/s^2")
print()
time.sleep(0.5)
mc3479.acceleration_output_data_rate = acc_rate
|
Low Pass Filter
Example showing how to change the Low Pass Filter Setting
examples/mc3479_lpf.py
import time
from machine import Pin, I2C
import micropython_mc3479.mc3479 as MC3479
i2c = I2C(sda=Pin(8), scl=Pin(9)) # Correct I2C pins for UM FeatherS2
mc3479 = MC3479.MC3479(i2c)
while True:
for lpf in MC3479.lpf_values:
print("Current Low Pass Filter Setting: ", mc3479.lpf_setting)
for _ in range(10):
accx, accy, accz = mc3479.acceleration
print(f"x:{accx:.2f}m/s^2 y:{accy:.2f}m/s^2 z:{accz:.2f}m/s^2")
print()
time.sleep(0.5)
mc3479.lpf_setting = lpf