lis3dh¶
LIS3DH MicroPython Driver
Author(s): Jose D. Montoya
-
class micropython_lis3dh.lis3dh.LIS3DH(i2c, address=
24)[source]¶ Main class for the Sensor
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
lis3dh.LIS3DHclass. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_lis3dh import lis3dhOnce this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(sda=Pin(8), scl=Pin(9)) # Correct I2C pins for UM FeatherS2 lis = lis3dh.LIS3DH(i2c)Now you have access to the
accelerationattributeacc_x, acc_y, acc_z = lis3dh.acceleration- property acceleration¶
The x, y, z acceleration values returned in a 3-tuple and are in \(m/s^2\)
- property axes_enabled¶
The data rate of the accelerometer. you could selected different axes to be on. Take a look at the table to select the Aces that you are interested in.
Mode
Value
lis3dh.AXES_X0b001lis3dh.AXES_Y0b010lis3dh.AXES_X_Y0b011lis3dh.AXES_Z0b100lis3dh.AXES_Z_X0b101lis3dh.AXES_Z_Y0b110lis3dh.AXES_Z_Y_X0b111
- property data_range¶
The range of the accelerometer. The LIS3DH has dynamically user selectable full scales of ±2g/±4g/±8g/±16g and it is capable of measuring accelerations with output data rates from 1 Hz to 5 kHz.
Mode
Value
lis3dh.DATARANGE_20b00lis3dh.DATARANGE_40b01lis3dh.DATARANGE_80b10lis3dh.DATARANGE_160b11
- property data_rate¶
The data rate of the accelerometer ODR <3:0> is used to set power mode and ODR selection. In the following table are reported all frequency resulting in combination of ODR<3:0>
Mode
Value
lis3dh.DATARATE_10b0001lis3dh.DATARATE_100b0010lis3dh.DATARATE_250b0011lis3dh.DATARATE_500b0100lis3dh.DATARATE_1000b0101lis3dh.DATARATE_2000b0110lis3dh.DATARATE_4000b0111lis3dh.DATARATE_13440b1001lis3dh.DATARATE_POWERDOWN0b0000lis3dh.DATARATE_LOWPOWER_16000b1000lis3dh.DATARATE_LOWPOWER_50000b1001
i2c_helpers¶
I2C MicroPython Helpers
Author(s): Jose D. Montoya