Comparison · Intermediate · 3 min read
Accelerometers
ADXL345, LIS3DH, ADXL335 and MMA8452 Compared
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
An accelerometer measures acceleration along three axes, which lets you detect tilt, taps, free fall and vibration. The ADXL345 and LIS3DH are the most popular digital choices: both are 3.3 V I2C or SPI chips with selectable ranges up to 16 g. The ADXL335 is an analog alternative. If you also need rotation, use a six-axis chip such as the MPU6050.
Key specs at a glance
- ADXL345
- ±2/4/8/16 g, 13-bit full resolution, I2C 0x53 (0x1D alt) or SPI, tap and free-fall detection
- LIS3DH
- ±2/4/8/16 g, 12-bit, I2C 0x18/0x19 or SPI, very low power, 3 ADC inputs
- ADXL335
- Analog ±3 g, output scales with supply, about 300 mV/g at 3 V
- MMA8452Q
- ±2/4/8 g, 12-bit, I2C 0x1D/0x1C, orientation detection
- Supply
- Chips run at 1.8 to 3.6 V; many breakouts add a regulator and level shifter
- Interfaces
- I2C for simplicity, SPI for fast data (vibration)
What an accelerometer measures
A MEMS accelerometer contains a tiny proof mass on springs. When the chip accelerates, or when gravity pulls on the mass, the displacement is converted to a number for each axis. At rest, one axis reads about 1 g because gravity is acceleration, which is why an accelerometer can tell tilt.
It cannot tell heading (compass direction) and it cannot separate gravity from motion by itself. For rotation rate you need a gyroscope, and for heading a magnetometer.
Which chip to choose
Digital chips are easier to use because the ADC is built in. Analog parts need a clean reference.
| Chip | Output | Range | Strong points | Watch out for |
|---|---|---|---|---|
| ADXL345 | I2C / SPI | ±2 to ±16 g | Tap, double-tap, free-fall; fast SPI; many libraries and 3D printer support | 3.3 V chip; check module level shifting |
| LIS3DH | I2C / SPI | ±2 to ±16 g | Ultra-low power, FIFO, extra ADC inputs; used on Adafruit and SparkFun boards | Two I2C addresses; 12-bit |
| MMA8452Q | I2C | ±2 to ±8 g | Orientation and tap detection built in | Older design, fewer new modules |
| ADXL335 | Analog X, Y, Z | ±3 g | Simple, no bus needed | Needs a stable 3.3 V ADC reference and noise filtering |
| MPU6050 | I2C | ±2 to ±16 g plus gyro | Accelerometer and gyroscope in one | Needs filtering for tilt |
- ADXL345
- Output:
- I2C / SPI
- Range:
- ±2 to ±16 g
- Strong points:
- Tap, double-tap, free-fall; fast SPI; many libraries and 3D printer support
- Watch out for:
- 3.3 V chip; check module level shifting
- LIS3DH
- Output:
- I2C / SPI
- Range:
- ±2 to ±16 g
- Strong points:
- Ultra-low power, FIFO, extra ADC inputs; used on Adafruit and SparkFun boards
- Watch out for:
- Two I2C addresses; 12-bit
- MMA8452Q
- Output:
- I2C
- Range:
- ±2 to ±8 g
- Strong points:
- Orientation and tap detection built in
- Watch out for:
- Older design, fewer new modules
- ADXL335
- Output:
- Analog X, Y, Z
- Range:
- ±3 g
- Strong points:
- Simple, no bus needed
- Watch out for:
- Needs a stable 3.3 V ADC reference and noise filtering
- MPU6050
- Output:
- I2C
- Range:
- ±2 to ±16 g plus gyro
- Strong points:
- Accelerometer and gyroscope in one
- Watch out for:
- Needs filtering for tilt
Reading tilt from an ADXL345
This sketch reads the raw X, Y, Z registers over I2C and turns them into pitch and roll. Keep the board still while testing, because movement adds to gravity.
#include <Wire.h>
const uint8_t ADDR = 0x53; // SDO low = 0x53, SDO high = 0x1D
void writeReg(uint8_t reg, uint8_t val) {
Wire.beginTransmission(ADDR);
Wire.write(reg);
Wire.write(val);
Wire.endTransmission();
}
void setup() {
Serial.begin(115200);
Wire.begin();
writeReg(0x2D, 0x08); // POWER_CTL: measurement mode
writeReg(0x31, 0x08); // DATA_FORMAT: full resolution, +/-2 g
}
void loop() {
Wire.beginTransmission(ADDR);
Wire.write(0x32); // DATAX0
Wire.endTransmission(false);
Wire.requestFrom(ADDR, (uint8_t)6);
uint8_t b[6];
for (int i = 0; i < 6; i++) b[i] = Wire.read();
float x = (int16_t)(b[0] | (b[1] << 8)) * 0.0039; // g
float y = (int16_t)(b[2] | (b[3] << 8)) * 0.0039;
float z = (int16_t)(b[4] | (b[5] << 8)) * 0.0039;
float pitch = atan2(x, sqrt(y * y + z * z)) * 57.2958;
float roll = atan2(y, sqrt(x * x + z * z)) * 57.2958;
Serial.print(pitch); Serial.print(" "); Serial.println(roll);
delay(100);
}Vibration and 3D printer tuning
For vibration you need a fast sample rate, so use SPI and a chip with a FIFO. An ADXL345 wired to the Raspberry Pi SPI header (or a vendor kit with the sensor already on a board) is the standard tool for measuring printer resonances. Firmware such as Klipper uses the data for input shaping, which cancels ringing on printed corners and allows faster printing. Mount the sensor firmly on the toolhead and the bed.
Practical tips
- Power digital chips at 3.3 V unless the module states 5 V tolerance, and use the right I2C pull-ups (see I2C).
- Pick the smallest range that fits. ±2 g is finest for tilt and step counting; use ±16 g for impacts.
- Average a few readings or add a low-pass filter. Raw data is noisy.
- Calibrate: lay each axis flat and note the offset from 1 g.
Try it: Adc resolution calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Powering a 3.3 V accelerometer breakout from 5 V without a regulator.
- Using too large a range and losing resolution.
- Expecting tilt readings to stay accurate while the board is moving.
- Leaving an I2C address pin floating.
- Mounting the sensor on a flexible part when measuring a printer.
Frequently asked questions
ADXL345 or LIS3DH?
Both work well. LIS3DH is lower power and common on wearable boards; ADXL345 is popular for 3D printer tuning and has tap detection.
Can an accelerometer measure speed or distance?
Not reliably. Integrating acceleration twice drifts within seconds.
What is 1 g?
The acceleration of gravity, 9.81 m/s². A resting sensor reads 1 g on the axis pointing at the ground.
Can it detect free fall?
Yes. When all axes read near zero g, the sensor is in free fall. The ADXL345 has a built-in free-fall interrupt.
Is an accelerometer the same as an IMU?
An IMU combines an accelerometer with a gyroscope and sometimes a magnetometer.
How do I get a tap or knock detector?
Use the ADXL345 or MMA8452 tap interrupt or watch for peaks in the readings.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 20 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- Analog Devices ADXL345 and ADXL335 datasheets
- STMicroelectronics LIS3DH datasheet
- NXP MMA8452Q datasheet
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.




