/LIS331

LIS331HH and LIS3DH triple-axis accelerometer library for Arduino

Primary LanguageC++GNU General Public License v3.0GPL-3.0

LIS331HH and LIS3DH triple-axis accelerometer library for Arduino

Implements all features of STMicroelectronics LIS331HH accelerometer and most of the features of LIS3DH according to their data sheet. Scales:

  • LIS331HH: ±6g/±12g/±24g
  • LIS3DH: ±2g/±4g/±8g/±16g

Wiring

The code uses the I²C protocol to communicate with the sensor. If you attach the sensor to a 5V Arduino board, please consider using a bi-directional level shifter.

LIS331 pin Arduino Nano pin Description
GND GND
INT2 D3 Optional, pin should be interrupt-capable
INT1 D2 Optional, pin should be interrupt-capable
SDA A4 Serial data
SCL A5 Serial clock
SA0 3V3 or GND Least significant bit of the device address
CS 3V3 Selects I²C protocol over SPI
VCC 3V3

Dependencies

Install I2C Master Library. It's faster, more robust, and customisable than the built-in Wire.h library.

Pull requests

Any code loves refactoring and feature expansion. Please, do create pull requests!