Arduino library for the LIS3DH 3-axis accelerometer (STMicroelectronics).
This library supports both I2C and SPI communication and makes it easy to read:
- Acceleration values (raw and g-units)
- Threshold interrupts (INT1 and INT2)
- ADC channel readings (ADC1 / ADC2 / ADC3)
- Temperature output from internal sensor
The goal of this library is to keep setup simple, while still giving access to advanced LIS3DH features.
LIS3DH is a popular accelerometer used in many applications:
- Motion detection
- Step counting
- Tilt / orientation sensing
- Fall detection
- Vibration monitoring
- Wearables and fitness devices
- Industrial motion monitoring
It supports:
- Very low power mode
- High resolution mode
- Interrupt based detection (no polling needed)
-
I2C + SPI communication
-
Acceleration output
-
Raw signed 16-bit values
-
Converted into g-units (float)
-
Sensor configuration
-
Scale selection (±2g / ±4g / ±8g / ±16g)
-
Output Data Rate selection (1 Hz to 1.6 kHz)
-
Interrupt support
-
INT1 threshold interrupts
-
INT2 threshold interrupts
-
Polarity control (active high / low)
-
ADC + Temperature
-
3 ADC channels available
-
Temperature output via ADC3
- Arduino UNO / Mega / Nano
- ESP32 / ESP8266
- Any Arduino-compatible board with I2C or SPI
The sensor supports both I2C and SPI.
- Uses only 2 wires (SDA + SCL)
- Slower than SPI, but simple
- Default address:
0x18 - Alternate address:
0x19(depends on SA0 pin)
- Uses 4 wires + CS
- Faster reads, best for higher performance applications
- Requires manual CS pin control
- SPI mode is fixed to
SPI_MODE3for LIS3DH
| LIS3DH Pin | Arduino Pin |
|---|---|
| VCC | 3.3V / 5V |
| GND | GND |
| SDA | SDA |
| SCL | SCL |
If using a 5V board (UNO), confirm that your module has level shifting or supports 5V logic.
| LIS3DH Pin | Arduino Pin |
|---|---|
| VCC | 3.3V / 5V |
| GND | GND |
| SCL | SCK |
| SDO | MOSI |
| SDI | MISO |
| CS | Any GPIO |
| LIS3DH Pin | Arduino Pin |
|---|---|
| INT1 | D2 (example) |
| INT2 | D3 (example) |
INT pins are useful for:
- Motion detection
- Wake-up events
- Threshold triggers
- Free-fall events (can be implemented using interrupts)
- Arduino IDE → Tools → Manage Libraries
- Search: 7Semi LIS3DH
- Click install
- Download repository ZIP
- Arduino IDE → Sketch → Include Library → Add .ZIP Library
- Restart IDE
Most users follow this pattern:
- Initialize (I2C or SPI)
- Configure scale and data rate
- Read acceleration
- Optional: use interrupts for event detection
- Optional: read ADC and temperature