Component guide · Beginner · 3 min read
ADXL345 Accelerometer

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The ADXL345 is a low-power 3-axis digital accelerometer from Analog Devices with ranges of ±2 to ±16 g. It talks I2C (address 0x53) or SPI and has built-in tap, double-tap, activity and free-fall detection. Use it for tilt sensing, step and shake detection, vibration logging and fall alarms.
Key specs at a glance
- Axes
- 3-axis acceleration
- Range
- ±2, ±4, ±8 or ±16 g
- Resolution
- Up to 13 bits, about 3.9 mg per count in full-resolution mode
- Interface
- I2C (0x53 with SDO low, 0x1D with SDO high) or SPI
- Supply
- Chip 2.0 to 3.6 V; GY-291 style modules accept 3.3 to 5 V
- Data rate
- 0.1 to 3200 Hz
- Features
- Tap, double tap, activity, inactivity and free-fall interrupts
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1ADXL345 Digital Acceleration Sensor Module – I2C/SPI, 3.3V/5V Compatible₹186
Option 2ADXL345 Triple-Axis Accelerometer Sensor Module – I2C/SPI Interface₹187
Option 3DFRobot Fermion ADXL345 Digital Triaxial Acceleration Sensor Breakout (±16g) – I2C/SPI Interface₹689
Option 4Keyestudio ADXL345 3-Axis Acceleration Module Accelerometer Gravity Tilt Module₹347
What the ADXL345 is
An accelerometer measures acceleration along three axes. At rest it measures gravity, so the readings tell you how the board is tilted. When it moves or vibrates it measures that movement.
The ADXL345 does more than stream numbers: it can watch for taps or a free fall itself and raise an interrupt pin, so the main board can sleep until something happens.
ADXL345 pinout
The pins on the ADXL345 and what each one does.
| Pin | Function |
|---|---|
| VCC | Supply, 3.3 V (or 5 V on modules with a regulator) |
| GND | Ground |
| CS | Chip select: high for I2C, low for SPI |
| INT1 / INT2 | Interrupt outputs |
| SDO | I2C address select (GND 0x53, VCC 0x1D), or SPI data out |
| SDA / SDI | I2C data, or SPI data in |
| SCL / SCLK | I2C clock, or SPI clock |
- VCC
- Supply, 3.3 V (or 5 V on modules with a regulator)
- GND
- Ground
- CS
- Chip select: high for I2C, low for SPI
- INT1 / INT2
- Interrupt outputs
- SDO
- I2C address select (GND 0x53, VCC 0x1D), or SPI data out
- SDA / SDI
- I2C data, or SPI data in
- SCL / SCLK
- I2C clock, or SPI clock
Wiring the ADXL345
Tie CS high to select I2C; many modules do this on board. On a bare 3.3 V board, power it from 3.3 V and use a level shifter on SDA and SCL with a 5 V Arduino.
| ADXL345 pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V (or 3.3V) | 3V3 |
| GND | GND | GND |
| SDA | A4 | GPIO 21 |
| SCL | A5 | GPIO 22 |
| CS | 3.3V (I2C mode) | 3V3 (I2C mode) |
| SDO | GND (address 0x53) | GND (address 0x53) |
- VCC
- Arduino Uno:
- 5V (or 3.3V)
- ESP32:
- 3V3
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- SDA
- Arduino Uno:
- A4
- ESP32:
- GPIO 21
- SCL
- Arduino Uno:
- A5
- ESP32:
- GPIO 22
- CS
- Arduino Uno:
- 3.3V (I2C mode)
- ESP32:
- 3V3 (I2C mode)
- SDO
- Arduino Uno:
- GND (address 0x53)
- ESP32:
- GND (address 0x53)
Example code
In full-resolution mode each count is about 3.9 mg at any range. Flat on a table, Z reads about 1 g. The Adafruit ADXL345 library is an alternative with tap setup helpers.
#include <Wire.h>
const uint8_t ADXL = 0x53;
void writeReg(uint8_t reg, uint8_t val) {
Wire.beginTransmission(ADXL); Wire.write(reg); Wire.write(val); Wire.endTransmission();
}
void setup() {
Serial.begin(115200);
Wire.begin();
writeReg(0x31, 0x0B); // DATA_FORMAT: full resolution, ±16 g
writeReg(0x2D, 0x08); // POWER_CTL: start measuring
}
void loop() {
Wire.beginTransmission(ADXL); Wire.write(0x32); Wire.endTransmission(false);
Wire.requestFrom(ADXL, (uint8_t)6);
int16_t x = Wire.read() | Wire.read() << 8; // low byte first
int16_t y = Wire.read() | Wire.read() << 8;
int16_t z = Wire.read() | Wire.read() << 8;
Serial.print(x * 0.0039); Serial.print(" ");
Serial.print(y * 0.0039); Serial.print(" ");
Serial.println(z * 0.0039);
delay(100);
}Setup and tuning
pitch = atan2(x, sqrt(y² + z²)) and roll = atan2(y, sqrt(x² + z²)), in radians.
the OFSX, OFSY and OFSZ registers remove small zero errors; measure them with the board flat.
±2 g for gentle tilt, ±16 g for impacts.
lower the data rate and use the activity interrupt to wake your board.
What you need
Shop this list6 of 8 found in our store · ₹1,800
- ADXL345 acceleration sensor module: the sensor this guide coversFind this part
ADXL345 Triple-Axis Accelerometer Sensor Module – I2C/SPI Interface: another version this guide coversADXL345 Triple-Axis Accelerometer Sensor Module – I2C/SPI Interface₹187
DFRobot Fermion ADXL345 Digital Triaxial Acceleration Sensor Breakout (±16g) – I2C/SPI Interface: another version this guide coversDFRobot Fermion ADXL345 Digital Triaxial Acceleration Sensor Breakout (±16g) – I2C/SPI Interface₹689
Keyestudio ADXL345 3-Axis Acceleration Module Accelerometer Gravity Tilt Module: another version this guide coversKeyestudio ADXL345 3-Axis Acceleration Module Accelerometer Gravity Tilt Module₹347- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- MPU6050: adds a gyroscope for fast rotation, better for balancing robots.
- Accelerometers compared: ADXL345, LIS3DH, ADXL335 and MMA8452.
- Vibration and tilt sensors: simple switches when you only need on or off.
Try it: I2c pullup calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Reading the data bytes high byte first; the ADXL345 sends the low byte first.
- Leaving CS floating, so the chip switches between I2C and SPI.
- Forgetting to set the measure bit in POWER_CTL, so every reading is zero.
- Connecting a bare 3.3 V board to 5 V logic.
Frequently asked questions
What is the ADXL345's I2C address?
0x53 with SDO to GND (most modules) or 0x1D with SDO to VCC.
Can the ADXL345 measure angle?
Yes, tilt angle from gravity when it is still. For angles while moving, combine it with a gyroscope.
Can it detect a fall?
Yes, it has a free-fall interrupt that fires when all axes read near zero g.
Does it work at 5 V?
Modules with a regulator do; the chip itself is a 3.3 V part.
ADXL345 or ADXL335?
The ADXL345 is digital (I2C/SPI) with interrupts; the ADXL335 gives three analog voltages.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 16 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

