Working Principle
The Analog Devices ADXL345 is a 3-axis MEMS capacitive accelerometer. Inside the IC, a micro-machined polysilicon proof mass is suspended by spring-like flexures. When acceleration is applied, the proof mass shifts relative to fixed electrodes, changing the differential capacitance. On-chip circuitry converts this capacitance change into a 13-bit digital value per axis.
Analogy: Imagine a tiny marble dangling on a rubber band inside a box. When you tilt the box, the marble shifts — sensors on the box walls measure how far it moved. The ADXL345 does this with a silicon proof mass at nanometre scale.
Electrical Characteristics
| Parameter | Value |
|---|---|
| Supply Voltage | 2.0 V – 3.6 V |
| Measurement Range | ±2g, ±4g, ±8g, ±16g (selectable) |
| Resolution | 13-bit (full resolution mode: 3.9 mg/LSB) |
| Output Data Rate | 0.1 Hz – 3200 Hz |
| Interface | I2C (addr 0x53/0x1D) or SPI (3/4-wire) |
| Current (measurement) | 40 µA at 100 Hz ODR |
| Built-in Features | Single/double tap, freefall, activity/inactivity detection |
| FIFO | 32-level sample buffer |
Interfacing with an MCU
The ADXL345 supports both I2C and SPI. For I2C, connect SDO to GND for address 0x53 or to VCC for 0x1D. The CS pin must be tied to VCC when using I2C. For SPI, connect CS, SDO (MISO), SDA (MOSI), and SCL (SCLK).
Calibration
The ADXL345 has on-chip offset registers (OFSX, OFSY, OFSZ) for zero-g compensation:
- Place sensor flat: Read X, Y, Z at rest — X and Y should be 0 g, Z should be 1 g (256 LSB at ±2g).
- Calculate offsets:
offset_x = -(x_avg / 4), write to 0x1E–0x20 registers. - Verify: Re-read and confirm X≈0, Y≈0, Z≈256.
Code Example
/*
* ADXL345 Accelerometer — Arduino I2C
* Requires: Adafruit_ADXL345_U library
* Wiring: I2C — SCL→A5, SDA→A4, VCC→3.3V
*/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
void setup() {
Serial.begin(9600);
if (!accel.begin()) {
Serial.println("ADXL345 not found! Check wiring.");
while (1);
}
accel.setRange(ADXL345_RANGE_2_G); /* ±2g for best resolution */
accel.setDataRate(ADXL345_DATARATE_100_HZ);
Serial.println("ADXL345 Ready");
}
void loop() {
sensors_event_t event;
accel.getEvent(&event);
Serial.print("X: "); Serial.print(event.acceleration.x);
Serial.print(" | Y: "); Serial.print(event.acceleration.y);
Serial.print(" | Z: "); Serial.print(event.acceleration.z);
Serial.println(" m/s²");
delay(100);
}
Real-World Applications
Vibration Monitoring in Machinery
Factories mount ADXL345 accelerometers on rotating machinery (pumps, motors, compressors) to detect abnormal vibration signatures. Machine-learning classifiers process the 3-axis data to predict bearing failures days before catastrophic breakdown, reducing unplanned downtime by up to 40%.
Limitations
- Noise floor: At full resolution the noise is ~1.1 LSB RMS per axis — averaging or oversampling needed for tilt sensing.
- No gyroscope: Cannot measure rotation; pair with MPU-6050 or BMI160 for full IMU capability.
- 3.6 V max: Not 5 V tolerant — use level shifters with 5 V Arduinos.
- Temperature sensitivity: Zero-g offset drifts ±0.5 mg/°C — recalibrate in extreme environments.