

The ADXL345 is a small, thin, low-power, 3-axis accelerometer capable of high-resolution (13-bit) measurements at up to ±16g. It is designed for applications requiring precise motion sensing, tilt detection, and gesture recognition. The device supports both I2C and SPI communication protocols, making it versatile and easy to integrate into a wide range of projects.








Below are the key technical details of the ADXL345:
| Parameter | Value |
|---|---|
| Supply Voltage (VDD) | 2.0V to 3.6V |
| I/O Voltage (VDDIO) | 1.7V to VDD |
| Measurement Range | ±2g, ±4g, ±8g, ±16g |
| Resolution | 13-bit |
| Communication Protocols | I2C, SPI |
| Operating Temperature | -40°C to +85°C |
| Power Consumption | 40 µA in measurement mode |
| Data Output Rate | 0.1 Hz to 3200 Hz |
| Dimensions | 3 mm × 5 mm × 1 mm |
The ADXL345 has 14 pins, but not all are required for basic operation. Below is the pin configuration:
| Pin | Name | Description |
|---|---|---|
| 1 | VDD | Power supply input (2.0V to 3.6V). |
| 2 | GND | Ground. |
| 3 | CS | Chip Select. Used to select SPI (active low). Tie high for I2C mode. |
| 4 | INT1 | Interrupt 1 output. Configurable for various events. |
| 5 | INT2 | Interrupt 2 output. Configurable for various events. |
| 6 | SCL/SCLK | Serial Clock Line for I2C/SPI. |
| 7 | SDA/SDI/SDO | Data line for I2C or SPI (data in/out). |
| 8 | GND | Ground. |
| 9-14 | NC | Not connected. Leave unconnected or tie to ground. |
The ADXL345 can be connected to an Arduino UNO using the I2C protocol. Below is the wiring guide:
| ADXL345 Pin | Arduino UNO Pin |
|---|---|
| VDD | 3.3V |
| GND | GND |
| SCL | A5 (SCL) |
| SDA | A4 (SDA) |
| CS | 3.3V (to enable I2C mode) |
The following code demonstrates how to read acceleration data from the ADXL345 using the I2C protocol:
#include <Wire.h> // Include the Wire library for I2C communication
#define ADXL345_ADDRESS 0x53 // I2C address of the ADXL345
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Start serial communication for debugging
// Initialize the ADXL345
Wire.beginTransmission(ADXL345_ADDRESS);
Wire.write(0x2D); // Power control register
Wire.write(0x08); // Set the device to measurement mode
Wire.endTransmission();
}
void loop() {
int16_t x, y, z;
// Request 6 bytes of data (X, Y, Z axes)
Wire.beginTransmission(ADXL345_ADDRESS);
Wire.write(0x32); // Start reading from the data registers
Wire.endTransmission(false);
Wire.requestFrom(ADXL345_ADDRESS, 6);
if (Wire.available() == 6) {
x = (Wire.read() | (Wire.read() << 8)); // Combine low and high bytes for X-axis
y = (Wire.read() | (Wire.read() << 8)); // Combine low and high bytes for Y-axis
z = (Wire.read() | (Wire.read() << 8)); // Combine low and high bytes for Z-axis
}
// Print the acceleration values
Serial.print("X: "); Serial.print(x);
Serial.print(" Y: "); Serial.print(y);
Serial.print(" Z: "); Serial.println(z);
delay(500); // Wait for 500ms before the next reading
}
No Data Output:
Incorrect or Unstable Readings:
Device Not Detected:
Q: Can the ADXL345 operate at 5V?
A: No, the ADXL345 operates at a maximum of 3.6V. Use a voltage regulator or level shifter if interfacing with a 5V system.
Q: How do I change the measurement range?
A: Write to the DATA_FORMAT register (0x31) to set the range to ±2g, ±4g, ±8g, or ±16g.
Q: Can I use SPI instead of I2C?
A: Yes, the ADXL345 supports SPI communication. Connect the CS pin to GND to enable SPI mode and configure the SPI settings in your microcontroller.
Q: What is the maximum sampling rate?
A: The ADXL345 supports a maximum data output rate of 3200 Hz. Adjust the BW_RATE register (0x2C) to set the desired rate.