MicroPython MMA8451 Library¶
mma8451¶
MicroPython module for the MMA8451 3 axis accelerometer
Author(s): Jose D. Montoya
-
class micropython_mma8451.mma8451.MMA8451(i2c, address: int =
0x1D)[source]¶ Driver for the MMA8451 Sensor connected over I2C.
- Parameters¶
- Raises¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
MMA8451class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_mma8451 import mma8451Once this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) mma8451 = mma8451.MMA8451(i2c)Now you have access to the attributes
- property acceleration : tuple[float, float, float]¶
Acceleration measured by the sensor in \(m/s^2\).
- property data_rate : str¶
Sensor data_rate
Mode
Value
mma8451.DATARATE_800HZ0b000mma8451.DATARATE_400HZ0b001mma8451.DATARATE_200HZ0b010mma8451.DATARATE_100HZ0b011mma8451.DATARATE_50HZ0b100mma8451.DATARATE_12_5HZ0b101mma8451.DATARATE_6_25HZ0b110mma8451.DATARATE_1_56HZ0b111
- property high_pass_filter : str¶
Sensor high_pass_filter
Mode
Value
mma8451.HPF_DISABLED0b0mma8451.HPF_ENABLED0b1
- property high_pass_filter_cutoff : str¶
Sensor high_pass_filter_cutoff sets the high-pass filter cutoff frequency for removal of the offset and slower changing acceleration data. In order to filter the acceleration data
high_pass_filtermust be enabled.Mode
Value
mma8451.CUTOFF_16HZ0b00mma8451.CUTOFF_8HZ0b01mma8451.CUTOFF_4HZ0b10mma8451.CUTOFF_2HZ0b11