← All parts

ADXL345 Digital Accelerometer

Adafruit

A digital accelerometer with I2C and SPI interfaces, featuring a 3-axis MEMS sensor for measuring acceleration in X, Y, Z axes.

In stock

Specifications

4
Operating Voltage
3.3V - 5V
Logic Level
3.3V or 5V
Gpio Count
6
Dimensions
4 mounting holes for easy attachment

Pinout

7
PinNameFunctionsNotes
VINVIN
POWER
3Vo3Vo
GND
GNDGND
GND
SCLSCL
I2CSPI
SDASDA
I2CSPI
CSCS
SPI
SDO/ALT ADDRSDO/ALT ADDR
I2C

Interactive pinout

Highlight:
BOARD

Click a pin to copy its name · tap a tag above to spotlight a bus.

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

Arduino library: Adafruit ADXL345 (+ Adafruit Unified Sensor)

arduino
// ADXL345 3-axis accelerometer (I2C) — community starter example
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>

Adafruit_ADXL345_Unified accel(12345);

void setup() {
  Serial.begin(115200);
  if (!accel.begin()) { Serial.println("ADXL345 not found"); while (1) delay(10); }
  accel.setRange(ADXL345_RANGE_16_G);
}

void loop() {
  sensors_event_t e;
  accel.getEvent(&e);
  Serial.print("x="); Serial.print(e.acceleration.x);
  Serial.print(" y="); Serial.print(e.acceleration.y);
  Serial.print(" z="); Serial.println(e.acceleration.z);
  delay(500);
}

MicroPython

MicroPython library: adxl345 (mcauser/micropython-adxl345)

python
# ADXL345 (ESP32) — community starter example
# lib: mcauser/micropython-adxl345 (adxl345.py on the board)
from machine import Pin, I2C
import adxl345, time

i2c = I2C(0, scl=Pin(22), sda=Pin(21))
accel = adxl345.ADXL345(i2c)

while True:
    print(accel.xyz)
    time.sleep(0.5)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VIN+5V3V3Breakout 3-5 V (chip is 3.3 V)
GNDGNDGND
SCLA5/SCLGPIO22I2C clock
SDAA4/SDAGPIO21I2C data

Typical uses

  • Tilt, motion, and vibration sensing
  • Free-fall and tap detection

Related parts

6