Back to Sensors & Actuators Series

ADXL345 3-Axis Digital Accelerometer

April 10, 2026 Wasil Zafar 9 min read

ADXL345 deep dive — MEMS capacitive principle, I2C/SPI wiring, tap and freefall interrupts, offset calibration, complete code, and real-world motion applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. Limitations

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

ParameterValue
Supply Voltage2.0 V – 3.6 V
Measurement Range±2g, ±4g, ±8g, ±16g (selectable)
Resolution13-bit (full resolution mode: 3.9 mg/LSB)
Output Data Rate0.1 Hz – 3200 Hz
InterfaceI2C (addr 0x53/0x1D) or SPI (3/4-wire)
Current (measurement)40 µA at 100 Hz ODR
Built-in FeaturesSingle/double tap, freefall, activity/inactivity detection
FIFO32-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).

I2C Wiring (Arduino): VCC → 3.3 V, GND → GND, SCL → A5, SDA → A4, SDO → GND (addr 0x53), CS → 3.3 V.

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

Industrial

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%.

Predictive MaintenanceIndustry 4.0Vibration

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.