

The LIS331 is a low-power, 3-axis accelerometer designed to measure acceleration in three dimensions. It is widely used in motion sensing applications, such as gesture recognition, tilt detection, and vibration monitoring. The LIS331 provides digital output via I2C or SPI interfaces, making it easy to integrate into microcontroller-based systems. Its compact size and low power consumption make it ideal for portable devices, including smartphones, fitness trackers, and gaming peripherals.








The LIS331 accelerometer offers a range of features and specifications that make it versatile for various applications. Below are the key technical details:
The LIS331 is housed in a 16-pin LGA package. Below is the pin configuration:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VDD | Power supply (2.16V to 3.6V) |
| 2 | VDD_IO | I/O interface voltage supply |
| 3 | GND | Ground |
| 4 | CS | SPI chip select (active low) |
| 5 | SCL/SPC | I2C clock / SPI serial port clock |
| 6 | SDA/SDI/SDO | I2C data / SPI data input/output |
| 7 | SDO/SA0 | SPI data output / I2C least significant bit of |
| the device address | ||
| 8-16 | NC | Not connected (leave floating or grounded) |
The LIS331 can be used in a variety of applications by interfacing it with a microcontroller via I2C or SPI. Below are the steps and considerations for using the LIS331 in a circuit:
Wiring:
Arduino Code: Below is an example Arduino sketch to read acceleration data from the LIS331:
#include <Wire.h>
#define LIS331_ADDR 0x18 // I2C address of the LIS331 (SA0 = GND)
// LIS331 register addresses
#define CTRL_REG1 0x20
#define OUT_X_L 0x28
#define OUT_X_H 0x29
#define OUT_Y_L 0x2A
#define OUT_Y_H 0x2B
#define OUT_Z_L 0x2C
#define OUT_Z_H 0x2D
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Initialize serial communication
// Configure LIS331: Enable all axes, set ODR to 100 Hz
Wire.beginTransmission(LIS331_ADDR);
Wire.write(CTRL_REG1);
Wire.write(0x27); // 0x27 = 00100111 (Normal mode, all axes enabled)
Wire.endTransmission();
}
void loop() {
int16_t x, y, z;
// Read X-axis data
x = readAxis(OUT_X_L, OUT_X_H);
// Read Y-axis data
y = readAxis(OUT_Y_L, OUT_Y_H);
// Read Z-axis data
z = readAxis(OUT_Z_L, OUT_Z_H);
// Print acceleration values
Serial.print("X: ");
Serial.print(x);
Serial.print(" Y: ");
Serial.print(y);
Serial.print(" Z: ");
Serial.println(z);
delay(100); // Delay for readability
}
int16_t readAxis(uint8_t lowReg, uint8_t highReg) {
Wire.beginTransmission(LIS331_ADDR);
Wire.write(lowReg | 0x80); // Set MSB for auto-increment
Wire.endTransmission();
Wire.requestFrom(LIS331_ADDR, 2);
uint8_t lowByte = Wire.read();
uint8_t highByte = Wire.read();
return (int16_t)((highByte << 8) | lowByte); // Combine high and low bytes
}
No Communication with the LIS331:
Incorrect or No Acceleration Data:
High Noise in Readings:
Device Overheating:
Q: Can the LIS331 be used with a 5V microcontroller?
A: Yes, but you must use a level shifter or voltage divider for the I2C/SPI lines and a 3.3V regulator for the power supply.
Q: How do I change the measurement range?
A: Write to the CTRL_REG4 register to configure the full-scale range (±2g, ±4g, or ±8g).
Q: What is the default output data rate (ODR)?
A: The default ODR is 50 Hz in normal mode.
Q: Can I use SPI instead of I2C?
A: Yes, the LIS331 supports both SPI and I2C. Configure the communication mode by setting the appropriate pins (CS and SDO/SA0).