MicroPython ADXL343 Library¶
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
ADXL343class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_adxl343 import adxl343Once this is done you can define your
machine.I2Cobject 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_20b00adxl343.RANGE_40b01adxl343.RANGE_80b10adxl343.RANGE_160b11
- property activity_mode : str¶
Sensor activity_mode
Mode
Value
adxl343.ACTIVITY_DISABLED0b0adxl343.ACTIVITY_ENABLED0b1
- 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_durationto a value greater 10 ms, thetap_latentto a value greater than 20 ms, thetap_windowto a value greater than 80 ms, and thetap_thresholdto 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_DISABLED0b0adxl343.DT_ENABLED0b1
- property measurement_mode : str¶
Sensor measurement_mode. Selecting 0 or
Falseplaces the part into standby mode, and a setting of 1 orTrueplaces the part into measurement mode. The ADXL343 powers up in standby mode with minimum power consumption.Mode
Value
adxl343.STANDBY0b0adxl343.READY0b1
- property resolution_mode : str¶
Sensor resolution_mode. When
resolution_modeis 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_rangeand scale factor.Mode
Value
adxl343.LOW_RES0b0adxl343.HIGH_RES0b1
- property single_tap_mode : str¶
Sensor single_tap_mode
Mode
Value
adxl343.ST_DISABLED0b0adxl343.ST_ENABLED0b1
- property tap_duration : float¶
Tap threshold in us. Maximum time that an event must be above the
tap_thresholdto qualify as a tap event. The scale factor is 625 μs/LSB. A value of 0 disables the single tap/ double tap functions