adafruit_lis331
¶
A library for the ST LIS331 family of high-g 3-axis accelerometers
- Author(s): Bryan Siepert
Implementation Notes¶
Hardware:
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
-
class
adafruit_lis331.
LIS331
(i2c_bus, address=24)¶ Base class for the LIS331 family of 3-axis accelerometers. Cannot be instantiated directly
param ~busio.I2C i2c_bus: The I2C bus the LIS331 is connected to. param address: The I2C device address. Defaults to 0x18
-
lpf_cutoff
¶ The frequency above which signals will be filtered out
-
hpf_reference
¶ The reference value to offset measurements when using the High-pass filter. To use,
use_reference
must be set to true when enabling the high-pass filter. The value is a signed 8-bit number from -128 to 127. The value of each increment of 1 depends on the currently set measurement range and is approximate: #pylint: disable=line-too-longRange Incremental value (LSB value) LIS331HHRange.RANGE_6G
orH3LIS331Range.RANGE_100G
~16mg LIS331HHRange.RANGE_12G
orH3LIS331Range.RANGE_200G
~31mg LIS331HHRange.RANGE_24G
orH3LIS331Range.RANGE_400G
~63mg #pylint: enable=line-too-long
-
zero_hpf
()¶ When the high-pass filter is enabled with
use_reference=False
, callingzero_hpf()
will set all measurements to zero immediately, avoiding the normal settling time seen when using the high-pass filter without ahpf_reference()
-
enable_hpf
(enabled=True, cutoff=0, use_reference=False)¶ Enable or disable the high-pass filter.
Parameters: - enabled – Enable or disable the filter. Default is
True
to enable - cutoff (RateDivisor) – A
RateDivisor
to set the high-pass cutoff frequency. Default isRateDivisor.ODR_DIV_50
. SeeRateDivisor
for more information - use_reference – Determines if the filtered measurements are offset by a reference value. Default is false.
See section 4 of the LIS331DLH application note for more information LIS331DLH application note for more information
- enabled – Enable or disable the filter. Default is
-
data_rate
¶ Select the rate at which the accelerometer takes measurements. Must be a
Rate
-
mode
¶ The
Mode
power mode that the sensor is set to, as determined by the currentdata_rate
. To set the mode, usedata_rate
and the appropriateRate
-
range
¶ Adjusts the range of values that the sensor can measure, Note that larger ranges will be less accurate. Must be a
H3LIS331Range
orLIS331HHRange
-
acceleration
¶ The x, y, z acceleration values returned in a 3-tuple and are in \(m / s ^ 2\).
-
-
class
adafruit_lis331.
LIS331HH
(i2c_bus, address=24)¶ Driver for the LIS331HH 3-axis high-g accelerometer.
Parameters: - i2c_bus (I2C) – The I2C bus the LIS331 is connected to.
- address – The I2C device address. Defaults to
0x18
Quickstart: Importing and using the device
Here is an example of using the
LIS331
class. First you will need to import the libraries to use the sensorimport board import adafruit_lis331
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA lis = adafruit_lis331.LIS331HH(i2c)
Now you have access to the
acceleration
attributeacceleration = lis.acceleration
-
class
adafruit_lis331.
H3LIS331
(i2c_bus, address=24)¶ Driver for the H3LIS331 3-axis high-g accelerometer.
Parameters: - i2c_bus (I2C) – The I2C bus the LIS331 is connected to.
- address – The I2C slave address of the sensor. Defaults to
0x18
Quickstart: Importing and using the device
Here is an example of using the
LIS331
class. First you will need to import the libraries to use the sensorimport board import adafruit_lis331
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA lis = adafruit_lis331.H3LIS331(i2c)
Now you have access to the
acceleration
attributeacceleration = lis.acceleration