sts1_sensors.edu.ADXL345¶
Module Contents¶
- class ADXL345(range=2, datarate=50, x_offset=0, y_offset=0, z_offset=0, address=None, bus=None)¶
Digital accelerometer.
- Parameters:
range (int) – How many gs the sensor should be able measure. Allowed values: [2, 4, 8, 16]. Defaults to 2.
datarate (int) – How often the sensor should measure in Hz. Allowed values: [0.10, 0.20, 0.39, 0.78, 1.56, 3.13, 6.25, 12.5, 25, 50, 100, 200, 400, 800, 1600, 3200]. Defaults to 50.
x_offset (int) – x-axis offset, defaults to 0.
y_offset (int) – y-axis offset, defaults to 0.
z_offset (int) – z-axis offset, defaults to 0.
address (hexadecimal) – Physical address of the sensor on the board (see i2cdetect command). Allowed values: [0x1D, 0x3A, 0x3B, 0x53]. If None, the environment variable STS1_SENSOR_ADDRESS_AVXL345 will be used. If environment variable is not found, 0x53 will be used.
bus (SMBus) – A SMBus object. If None, this class will generate its own, defaults to None.
Example:
accel = ADXL345(range=2, datarate=50) x, y, z = accel.get_g() print(f"{x=:.2f} g, {y=:.2f} g, {z=:.2f} g")
- property datarate¶
- property range¶
- get_g_raw()¶
Get raw acceleration.
- get_g()¶
Get acceleration adjusted by previously defined offsets.