

The Triple Axis Accelerometer Breakout - ADXL345 by SparkFun is a compact and versatile sensor designed to measure acceleration in three axes: X, Y, and Z. It is capable of detecting both static acceleration (e.g., gravity) and dynamic acceleration (e.g., motion or vibration). With its small form factor and low power consumption, the ADXL345 is ideal for applications such as motion detection, orientation sensing, gaming devices, robotics, and wearable technology.
This breakout board simplifies interfacing with the ADXL345 sensor, making it easy to integrate into your projects. It supports both I2C and SPI communication protocols, offering flexibility for various microcontroller platforms.








The breakout board has 8 pins, as described in the table below:
| Pin Name | Description |
|---|---|
| VCC | Power supply input (3.3V to 5V). |
| GND | Ground connection. |
| SDA | I2C data line (connect to microcontroller's SDA pin). |
| SCL | I2C clock line (connect to microcontroller's SCL pin). |
| CS | Chip Select for SPI communication (active low). Tie to GND for I2C mode. |
| SDO | SPI data output (or I2C address select: GND = 0x53, VCC = 0x1D). |
| SDI | SPI data input. |
| INT1 | Interrupt 1 output (configurable for motion detection, free-fall, etc.). |
To use the ADXL345 with an Arduino UNO, follow these steps:
Wiring:
Install Required Libraries:
Example Code: Below is an example Arduino sketch to read acceleration data from the ADXL345:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
// Create an ADXL345 object
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
void setup() {
Serial.begin(9600);
// Initialize the sensor
if (!accel.begin()) {
Serial.println("Failed to find ADXL345 chip");
while (1); // Halt if sensor initialization fails
}
Serial.println("ADXL345 initialized successfully!");
// Set measurement range to ±4g
accel.setRange(ADXL345_RANGE_4_G);
Serial.println("Range set to ±4g");
}
void loop() {
sensors_event_t event;
accel.getEvent(&event);
// Print acceleration data
Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" m/s^2 ");
Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" m/s^2 ");
Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.println(" m/s^2");
delay(500); // Delay for readability
}
0x53 when the SDO pin is tied to GND, or 0x1D when tied to VCC.No Data Output:
Incorrect or Noisy Readings:
Sensor Initialization Fails:
Q: Can the ADXL345 detect free-fall?
A: Yes, the ADXL345 has a built-in free-fall detection feature. You can configure it using the appropriate registers or library functions.
Q: What is the maximum sampling rate of the ADXL345?
A: The ADXL345 supports a maximum output data rate of 3200Hz.
Q: Can I use the ADXL345 with a 5V microcontroller?
A: Yes, the breakout board includes level-shifting circuitry, allowing it to interface with both 3.3V and 5V systems.
Q: How do I switch between I2C and SPI modes?
A: To use I2C, tie the CS pin to GND. For SPI, connect the CS pin to a digital pin on your microcontroller and configure it in your code.
By following this documentation, you can effectively integrate the ADXL345 into your projects for reliable motion and orientation sensing.