# DFRobot_LIS
**Repository Path**: dfrobot/DFRobot_LIS
## Basic Information
- **Project Name**: DFRobot_LIS
- **Description**: No description available
- **Primary Language**: Python
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 2
- **Forks**: 0
- **Created**: 2021-06-02
- **Last Updated**: 2024-04-18
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# DFRobot_LIS
* [中文版](./README_CN.md)
The H3LIS200DL is a low-power high performance 3-axis linear accelerometer
belonging to the “nano” family, with digital I2C/SPI
serial interface standard output.
The device features ultra-low-power operational
modes that allow advanced power saving and
smart sleep-to-wakeup functions.
The H3LIS200DL has dynamically user selectable full scales of ±100g/±200g and is
capable of measuring accelerations with output
data rates from 0.5 Hz to 1 kHz.
The H3LIS200DL is available in a small thin
plastic land grid array package (LGA) and is
guaranteed to operate over an extended
temperature range from -40 °C to +85 °C.
The LIS331HH is an ultra low-power high
performance high full-scale three axes linear
accelerometer belonging to the “nano” family, with
digital I2C/SPI serial interface standard output.
The device features ultra low-power operational
modes that allow advanced power saving and
smart sleep to wake-up functions.
The LIS331HH has dynamically user selectable
full scales of ±6g/±12g/±24g and it is capable of
measuring accelerations with output data rates
from 0.5 Hz to 1 kHz. The self-test capability
allows the user to check the funct
The IIS2DLPC is an ultra-low-power high-performance
three-axis linear accelerometer with digital I²C/SPI
output interface which leverages on the robust and
mature manufacturing processes already used for the
production of micromachined accelerometers.
The IIS2DLPC has user-selectable full scales of
±2g/±4g/±8g/±16g and is capable of measuring
accelerations with output data rates from 1.6 Hz to
1600 Hz.
The LIS2DW12 is an ultra-low-power high-performance three-axis linear
accelerometer belonging to the “femto” family which leverages on the robust and
mature manufacturing processes already used for the production of micromachined
accelerometers.
The LIS2DW12 has user-selectable full scales of ±2g/±4g/±8g/±16g and is capable of
measuring accelerations with output data rates from 1.6 Hz to 1600 Hz.
CHIP | Work Well | Work Wrong | Remarks
------------------ | :----------: | :---------- | -----
H3LIS200DL | √ | |
LIS331HH | √ | |
LIS2DW12 | √ | |
IIS2DLPC | √ | |
IS2DH12 | √ | |






## Product Link(https://www.dfrobot.com)
SKU:SEN0405
SKU:SEN0407
SKU:SEN0408
SKU:SEN0409
SKU:SEN0411
SKU:SEN0412
SKU:SEN0224
## Table of Contents
* [Summary](#summary)
* [Installation](#installation)
* [Method_H3LIS200DL_LIS331HH](#Method_H3LIS200DL_LIS331HH)
* [Method_LIS2DW12_IIS2DLPC](#Method_LIS2DW12_IIS2DLPC)
* [Method_LIS2DH12](#Method_LIS2DH12)
* [Compatibility](#compatibility)
* [History](#history)
* [Credits](#credits)
## Summary
Provide an Arduino library to get Three-axis acceleration by reading data from LIS.
## Installation
To use this library, first download the library file, paste it into the \Arduino\libraries directory, then open the examples folder and run the demo in the folder.
## Method_H3LIS200DL_LIS331HH
```C++
/**
* @fn begin
* @brief Initialize the function
* @return true(Succeed)/false(Failed)
*/
bool begin(void);
/**
* @fn getID
* @brief Get chip id
* @return 8 bit serial number
*/
uint8_t getID();
/**
* @fn enableInterruptEvent
* @brief Enable interrupt
* @param source Interrupt pin selection
* @n eINT1 = 0,//
* @n eINT2,//
* @param event Interrupt event selection
* @n eXLowerThanTh ,//
* @n eXHigherThanTh ,//
* @n eYLowerThanTh,//
* @n eYHigherThanTh,//
* @n eZLowerThanTh,//
* @n eZHigherThanTh,//
*/
void enableInterruptEvent(eInterruptSource_t source, eInterruptEvent_t event);
/**
* @fn setRange
* @brief Set measurement range
* @param range Range(g)
* @n eH3lis200dl_100g, //±100g
* @n eH3lis200dl_200g, //±200g
*
* @n eLis331hh_6g = 6,//±6g
* @n eLis331hh_12g = 12 //±12g
* @n eLis331hh_24g = 24 //±24g
* @return true(Set successfully)/false(Set failed)
*/
bool setRange(eRange_t range);
/**
* @fn setAcquireRate
* @brief Set data measurement rate
* @param rate rate(HZ)
* @n ePowerDown_0HZ //Measurement off
* @n eLowPower_halfHZ //0.5 hz
* @n eLowPower_1HZ
* @n eLowPower_2HZ
* @n eLowPower_5HZ
* @n eLowPower_10HZ
* @n eNormal_50HZ
* @n eNormal_100HZ
* @n eNormal_400HZ
* @n eNormal_1000HZ
*/
void setAcquireRate(ePowerMode_t rate);
/**
* @fn setHFilterMode
* @brief Set data filtering mode
* @param mode Four modes
* @n eCutOffMode1 = 0,
* @n eCutOffMode2,
* @n eCutOffMode3,
* @n eCutOffMode4,
* @n eShutDown, no filering
* @n eg: Select eCutOffMode1 in 50HZ, and the filtered frequency is 1HZ
* @n |---------------------------High-pass filter cut-off frequency configuration-----------------------------|
* @n |--------------------------------------------------------------------------------------------------------|
* @n | | ft [Hz] | ft [Hz] | ft [Hz] | ft [Hz] |
* @n | mode |Data rate = 50 Hz| Data rate = 100 Hz | Data rate = 400 Hz | Data rate = 1000 Hz |
* @n |--------------------------------------------------------------------------------------------------------|
* @n | eCutOffMode1 | 1 | 2 | 8 | 20 |
* @n |--------------------------------------------------------------------------------------------------------|
* @n | eCutOffMode2 | 0.5 | 1 | 4 | 10 |
* @n |--------------------------------------------------------------------------------------------------------|
* @n | eCutOffMode3 | 0.25 | 0.5 | 2 | 5 |
* @n |--------------------------------------------------------------------------------------------------------|
* @n | eCutOffMode4 | 0.125 | 0.25 | 1 | 2.5 |
* @n |--------------------------------------------------------------------------------------------------------|
*/
void setHFilterMode(eHighPassFilter_t mode);
/**
* @fn setInt1Th
* @brief Set the threshold of interrupt source 1 interrupt
* @param threshold The threshold we set before is within measurement range(unit:g)
*/
void setInt1Th(uint8_t threshold);
/**
* @fn setInt2Th
* @brief Set interrupt source 2 interrupt generation threshold
* @param threshold The threshold we set before is within measurement range(unit:g)
*/
void setInt2Th(uint8_t threshold);
/**
* @fn enableSleep
* @brief Enable sleep wake function
* @param enable true(enable)\false(disable)
* @return false Indicate enable failed/true Indicate enable successful
*/
bool enableSleep(bool enable);
/**
* @fn getInt1Event
* @brief Check whether the interrupt event'event' is generated in interrupt 1
* @param event Interrupt event
* @n eXLowerThanTh ,//
* @n eXHigherThanTh ,//
* @n eYLowerThanTh,//
* @n eYHigherThanTh,//
* @n eZLowerThanTh,//
* @n eZHigherThanTh,//
* @return true This event generated/false This event not generated
*/
bool getInt1Event(eInterruptEvent_t event);
/**
* @fn getInt2Event
* @brief Check whether the interrupt event'event' is generated in interrupt 2
* @param event Interrupt event
* @n eXLowerThanTh ,//
* @n eXHigherThanTh ,//
* @n eYLowerThanTh,//
* @n eYHigherThanTh,//
* @n eZLowerThanTh,//
* @n eZHigherThanTh,//
* @return true This event generated/false This event not generated
*/
bool getInt2Event(eInterruptEvent_t event);
/**
* @fn readAccX
* @brief Get the acceleration in the x direction
* @return acceleration from x
*/
int32_t readAccX();
/**
* @fn readAccY
* @brief Get the acceleration in the y direction
* @return acceleration from y
*/
int32_t readAccY();
/**
* @brief Get the acceleration in the z direction
* @return acceleration from z
*/
int32_t readAccZ();
/**
* @fn getAcceFromXYZ
* @brief Get the acceleration in the three directions of xyz
* @param accx Store the variable of acceleration in x direction
* @param accy Store the variable of acceleration in y direction
* @param accz Store the variable of acceleration in z direction
* @return true(Get data successfully/false(Data not ready)
*/
bool getAcceFromXYZ(int32_t &accx,int32_t &accy,int32_t &accz);
/**
* @fn getSleepState
* @brief Get whether the sensor is in sleep mode
* @return true(In sleep mode)/false(In normal mode)
*/
bool getSleepState();
/**
* @fn setSleepFlag
* @brief Set the sleep state flag
* @param into true(Flag the current mode as sleep mode)/false(Flag the current mode as normal mode)
*/
void setSleepFlag(bool into);
```
## Method_LIS2DW12_IIS2DLPC
```C++
/**
* @fn begin
* @brief Initialize the function
* @return true(Initialization succeed)/fasle(Initialization failed)
*/
bool begin(void);
/**
* @fn getID
* @brief Get chip id
* @return 8 bit serial number
*/
uint8_t getID();
/**
* @fn softReset
* @brief Software reset to restore the value of all registers to the default value
*/
void softReset();
/**
* @fn continRefresh
* @brief Enable the chip to continuously collect data
* @param enable true(continuous update)/false( output registers not updated until MSB and LSB read)
*/
void continRefresh(bool enable);
/**
* @fn setFilterPath
* @brief Set the filter processing mode
* @param path path of filtering
* @n eLPF = 0x00,/< low-pass filter path selected>/
* @n eHPF = 0x10,//
*/
void setFilterPath(ePath_t path);
/**
* @fn setFilterBandwidth
* @brief Set the bandwidth of the data
* @param bw bandwidth
* @n eRateDiv_2 ,//
* @n eRateDiv_4 ,/*
* @n eRateDiv_10 ,//
* @n eRateDiv_20 ,//
*/
void setFilterBandwidth(eBWFilter_t bw);
/**
* @fn setPowerMode
* @brief Set power mode, there are two modes for the sensor to measure acceleration
* @n 1.Continuous measurement In this mode, the sensor will continuously measure and store data in its register
* @n 2.Single data conversion on demand mode In this mode, the sensor will not make a measurement unless it receives an external request
* @param mode power modes to choose from
* @n eHighPerformance_14bit //
* @n eContLowPwr4_14bit //
* @n eContLowPwr3_14bit //
* @n eContLowPwr2_14bit //
* @n eSingleLowPwr4_14bit //
* @n eSingleLowPwr3_14bit //
* @n eSingleLowPwr2_14bit //
* @n eSingleLowPwr1_12bit //
* @n eHighPerformanceLowNoise_14bit //
* @n eContLowPwrLowNoise4_14bit //
* @n eContLowPwrLowNoise3_14bit //
* @n eContLowPwrLowNoise2_14bit //
* @n eContLowPwrLowNoise1_12bit //
* @n eSingleLowPwrLowNoise4_14bit //
* @n eSingleLowPwrLowNoise3_14bit //
* @n eSingleLowPwrLowNoise2_14bit //
* @n eSingleLowPwrLowNoise1_12bit //
*/
void setPowerMode(ePowerMode_t mode);
/**
* @fn setDataRate
* @brief Chip data collection rate setting
* @param rate Accelerometer frequency, 0-1600hz selection
* @n eRate_0hz //
* @n eRate_1hz6 /<1.6hz, use only under low-power mode>/
* @n eRate_12hz5 /<12.5hz>/
* @n eRate_25hz
* @n eRate_50hz
* @n eRate_100hz
* @n eRate_200hz
* @n eRate_400hz /