User Guide

1/16/2018 H3LIS331DL Accelerometer Breakout Hookup Guide - learn.sparkfun.com
https://learn.sparkfun.com/tutorials/h3lis331dl-accelerometer-breakout-hookup-guide?_ga=2.255828235.2084638943.1516049849-204410570.150963…
4/7
convertToG(maxScale, reading) - Converts from raw data to an actual g-reading. The first parameter is the maximum reading for
the current mode, as set by the setFullScale() function. Options are 6/12/24g for the LIS331HH and 100/200/400g for the
H3LIS331DL.
setHighPassCoeff(high_pass_cutoff_freq_cfg hpcoeff) - Set the coefficient for the high pass filter. The actual cutoff frequency is
dependent upon the data rate set by setODR() . The cutoff frequency is (fs)/(6*Hpc), where fs is the sampling frequency and Hpc
is the high pass coefficient as set by these constants:
LIS331::HPC_8 - Sets coefficient to 8.
LIS331::HPC_16 - Sets coefficient to 16.
LIS331::HPC_32 - Sets coefficient to 32.
LIS331::HPC_64 - Sets coefficient to 64.
enableHPF(bool enable) - true to enable, false to disable.
HPFOOnIntPin(bool enable, intSource) - Does the high pass filter apply to the signal the interrupt is based on? true to
enable, false to disable, and the second parameter is 1 or 2 depending on which interrupt you wish to apply this setting to.
intActiveHigh(bool enable) - Pass true to set the interrupt pin to active high, false to set it as active low. Default value is
active high.
intPinMode(pp_od _pinMode) - Are the interrupt pins open-drain or push pull? Pass LIS331::PUSH_PULL or LIS331::OPEN_DRAIN .
intSrcConfig(int_sig_src src, pin) - What sort of thing triggers an interrupt, and which pin shows the interrupt. The options
are:
LIS331::INT_SRC - Interrupt source is the same as the pin number.
LIS331::INT1_2_SRC - Either interrupt will be reflected on the pin.
LIS331::DRDY - The “new data ready” signal will be reflected on the pin.
LIS331::BOOT - The boot mode status of the part is reflected on the pin.
setFullScale(fs_range range) - Sets the range of the part, as listed below:
LOW_RANGE - +/-6g for the LIS331HH or +/-100g for the H3LIS331DH.
MED_RANGE - +/-12g for the LIS331HH or +/-200g for the H3LIS331DH.
HIGH_RANGE - +/-24g for the LIS331HH or +/-400g for the H3LIS331DH.
bool newXData() - returns true if new X data is available since last read of X data register.
bool newYData() - same as newXData() for Y axis.
bool newZData() - same as newZData() for Z axis.
enableInterrupt(int_axis axis, trig_on_level trigLevel, interrupt, bool enable) - axis can
be LIS331::X_AXIS , LIS331::Y_AXIS , or LIS331::Z_AXIS . trigLevel can
be LIS331::TRIG_ON_HIGH or LIS331::TRIG_ON_LOW , interrupt can be 1 or 2, and enable is true to enable the interrupt
and false to disable it.
setIntDuration(duration, intSource) - duration can be any value from 0-127, and represents the time in number of samples
that the sensor must read above or below the threshold set by the user. intSource is 1 or 2.
setIntThreshold(threshold, intSource) - threshold is the absolute magnitude above or below which an interrupt will occur,
divided by 16. It can range from 0-127. intSource is 1 or 2.
Examples
Hardware Hookup
The H3LIS331DL supports I C, SPI, and three-wire SPI data transfer. The library supports I C and SPI mode. Obviously, since SPI
requires four wires and I C only requires two, there are different circuit configurations for each mode. Now would be a good time
to solder the female headers to the Arduino Pro 3.3V/8MHz and breakaway headers to the H3LIS331DL sensor before connecting
the boards together.
I C Mode
The board is labeled for I C mode. Here you can see it connected to a 3.3V Arduino Pro. Note that connecting the board to a 5V
Arduino can damage it.
2 2
2
2
2