Available in Arduino Library manager!
Please read the documentation: ADXL372 Datasheet
- Open the Library Manager (Ctrl + Shift + I).
- Search for ADXL372.
- Install the latest version.
This library uses SPI as communication with the accelerometer. I²C is supported, but has limited functionality. See the documentation for further information.
This accelerometer is packed with features, so check out the simple example here for the minimum requirements for continuously reading the 3-axis acceleration.
ADXL372class(csPin)
Create an ADXL372 object with the CS (Chip select) pin.begin()
Call this to initiate the accelerometer.begin(uint32_t spiClockSpeed)
Initiate with a custom spi clock speed.printDevice()
Print the device's Analog Devices ID, device ID, MEMS ID, revision ID and Device Status.selfTest()
Executes the self test procedure. Returns true if the test finished and passed, otherwise returns false.
setStatusCheck(bool isCheckingStatus)
Sets if you want to check if the data is ready or not, before reading the acceleration data.readAcceleration(float& x, float& y, float& z)
Read the 3-axis acceleration in g.readPeakAcceleration(float& xPeak, float& yPeak, float& zPeak)
Read the 3-axis peak acceleration in g.
setOffsetTrims(OffsetTrims xOffset, OffsetTrims yOffset, OffsetTrims zOffset)
Sets the offsets for each of the 3-axis. Can be set between -60 and 52.5 with 7.5 intervals.
setActivityThresholds(uint16_t xThreshold, uint16_t yThreshold, uint16_t zThreshold)
Sets the activity thresholds for the 3 axis. Threshold value is a 11-bit value with 100mg per LSBenableActivityDetection(bool isEnabledX, bool isEnabledY, bool isEnabledZ)
Enable activity detection for each axis.setReferencedActivityProcessing(bool isReferenced)
Referenced activity processing for each axis when true. Absolute processing when false.setActivityTimer(uint8_t timerPeriod)
Sets the activity timer period. Timer period is ~6.6ms per code at 3200Hz ODR and below, and ~3.3ms at 6400Hz ODR.
setInactivityThresholds(uint16_t xThreshold, uint16_t yThreshold, uint16_t zThreshold)
Sets the inactivity thresholds for the 3 axis. Same as activity threshold.enableInactivityDetection(bool isEnabledX, bool isEnabledY, bool isEnabledZ)
Enable inactivity detection for each axis.setReferencedInactivityProcessing(bool isReferenced)
Referenced inactivity processing for each axis when true. Absolute processing when false.setInactivityTimer(uint16_t timerPeriod)
Sets the activity timer period. Timer period is ~26ms per code at 3200Hz ODR and below, and ~13ms at 6400Hz ODR.
setMotionWarningThresholds(uint16_t xThreshold, uint16_t yThreshold, uint16_t zThreshold)
Sets the Motion Warning thresholds for the 3 axis. Same as activity threshold.enableMotionWarningDetection(bool isEnabledX, bool isEnabledY, bool isEnabledZ)
Enable Motion Warning detection for each axis.setReferencedMotionWarningProcessing(bool isReferenced)
Referenced Motion Warning processing for each axis when true. Absolute processing when false.
The FIFO has not been implemented yet.
selectInt1Function(InterruptFunction function)
Select an interrupt function for interrupt pin 1selectInt1Functions(uint8_t function)
Select multiple interrupt functions for interrupt pin 1. For example:(DATA_RDY | AWAKE)
.selectInt2Function(InterruptFunction function)
Select an interrupt function for interrupt pin 2selectInt2Functions(uint8_t function)
Select multiple interrupt functions for interrupt pin 2.
-
setOdr(Odr odr)
Sets the ODR. Default is 400Hz.ODR options:
ODR_400Hz
ODR_800Hz
ODR_1600Hz
ODR_3200Hz
ODR_6400Hz
-
setWakeUpRate(WakeUpRate wur)
Sets the wake-up rate. Default is 52ms.Wake-up rate options:
WUR_52ms
WUR_104ms
WUR_208ms
WUR_512ms
WUR_2048ms
WUR_4096ms
WUR_8192ms
WUR_24576ms
-
enableExternalClock(bool isEnabled)
Enables external clock. When using this, apply a clock in the INT1 pin. -
enableExternalTrigger(bool isEnabled)
Enables external triggers. When this enabled, use the INT2 pin as the sync trigger input.
-
setBandwidth(Bandwidth bandwidth)
Sets the bandwidth of the accelerometer. Default is 200Hz. Please use up to half of the ODR to unsure the Nyquist criteria.Bandwidth options:
BW_200Hz
BW_400Hz
BW_800Hz
BW_1600Hz
BW_3200Hz
-
enableLowNoiseOperation(bool isEnabled)
Enables Low-noise operation when set to true. -
setLinkLoopActivityProcessing(LinkLoop activityProcessing)
Sets the activity processing mode. Activity and inactivity must be enabled for either linked or looped mode.Link-Loop options:
DEFAULT
LINKED
LOOPED
-
enableAutosleep(bool isEnabled)
Enables Autosleep mode when set to true. If activity processing is set toDEFAULT
, this bit will be ignored.
-
setOperatingMode(OperatingMode opMode)
Sets the accelerometer operating mode.Operating mode options:
STANDBY
WAKE_UP
INSTANT_ON
FULL_BANDWIDTH
-
disableHighPassFilter(bool isDisabled)
Disables the digital high-pass filter. -
disableLowPassFilter(bool isDisabled)
Disables the digital low-pass activity detect filter. -
setFilterSettling(FilterSettlingPeriod filterSettling)
Sets the filter settling period. It is ideal to set this to 16ms when the high-pass filter and the low-pass activity detect filter are disabled.Filter settling period options:
FSP_370ms
FSP_16ms
-
setInstantOnThreshold(InstantOnThreshold threshold)
Sets the instant on threshold.Intant on threshold options:
IOT_LOW_THRESH
IOT_HIGH_THRESH