MicroPython ADXL343 Driver¶
adxl343
¶
MicroPython Driver for the Analog Devices ADXL343 Accelerometer
Author(s): Jose D. Montoya
-
class micropython_adxl343.adxl343.ADXL343(i2c, address: int =
0x53
)[source]¶ Driver for the ADXL343 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
ADXL343
class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_adxl343 import adxl343
Once this is done you can define your
machine.I2C
object and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) adxl = adxl343.ADXL343(i2c)
Now you have access to the attributes
accx, accy, accz = adx.acceleration
- property acceleration_range : str¶
Sensor acceleration_range
Mode
Value
adxl343.RANGE_2
0b00
adxl343.RANGE_4
0b01
adxl343.RANGE_8
0b10
adxl343.RANGE_16
0b11
- property activity_mode : str¶
Sensor activity_mode
Mode
Value
adxl343.ACTIVITY_DISABLED
0b0
adxl343.ACTIVITY_ENABLED
0b1
- property double_tap_mode : str¶
Sensor double_tap_mode Every mechanical system has somewhat different single tap/double tap responses based on the mechanical characteristics of the system. Therefore, some experimentation is required. In general, a good starting point is to set the
tap_duration
to a value greater 10 ms, thetap_latent
to a value greater than 20 ms, thetap_window
to a value greater than 80 ms, and thetap_threshold
to a value greater than 3 g. Setting a very low values may result in an unpredictable response due to the accelerometer picking up echoes of the tap inputs.Mode
Value
adxl343.DT_DISABLED
0b0
adxl343.DT_ENABLED
0b1
- property measurement_mode : str¶
Sensor measurement_mode. Selecting 0 or
False
places the part into standby mode, and a setting of 1 orTrue
places the part into measurement mode. The ADXL343 powers up in standby mode with minimum power consumption.Mode
Value
adxl343.STANDBY
0b0
adxl343.READY
0b1
- property resolution_mode : str¶
Sensor resolution_mode. When
resolution_mode
is set toTrue
, the device is in full resolution mode, where the output resolution increases with the g range set by the range bits to maintain a 4 mg/LSB scale factor. When is set toFalse
, the device is in 10-bit mode, and the range bits determine the maximum gacceleration_range
and scale factor.Mode
Value
adxl343.LOW_RES
0b0
adxl343.HIGH_RES
0b1
- property single_tap_mode : str¶
Sensor single_tap_mode
Mode
Value
adxl343.ST_DISABLED
0b0
adxl343.ST_ENABLED
0b1
- property tap_duration : float¶
Tap threshold in us. Maximum time that an event must be above the
tap_threshold
to qualify as a tap event. The scale factor is 625 μs/LSB. A value of 0 disables the single tap/ double tap functions