Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use ADXL345: Examples, Pinouts, and Specs

Image of ADXL345
Cirkit Designer LogoDesign with ADXL345 in Cirkit Designer

Introduction

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.

Explore Projects Built with ADXL345

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino Nano and ADXL345 Accelerometer Interface
Image of Interfacing ADXL345 with Nano: A project utilizing ADXL345 in a practical application
This circuit features an Arduino Nano interfaced with an ADXL345 accelerometer for measuring acceleration. The Arduino provides power and I2C communication to the accelerometer, enabling it to capture and process motion-related data.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Leonardo and ADXL345 Accelerometer-Based Motion Detection System
Image of mini project: A project utilizing ADXL345 in a practical application
This circuit interfaces an ADXL345 accelerometer with an Arduino Leonardo via I2C communication. The Arduino provides power and ground to the accelerometer and reads acceleration data through the SDA and SCL lines.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO and ADXL345 Accelerometer Data Logger
Image of Accelerometer ADXL345 Circuit Diagram: A project utilizing ADXL345 in a practical application
This circuit features an Arduino UNO microcontroller interfaced with an Adafruit ADXL345 accelerometer for motion detection, powered by two parallel-connected 18650 Li-ion batteries. The accelerometer communicates with the Arduino over I2C, and the system is designed for further code development to utilize the motion sensing capabilities.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-Based Multi-Sensor Monitoring System with Battery Power
Image of Wind turbine 2.0: A project utilizing ADXL345 in a practical application
This circuit is a sensor monitoring system powered by a 7.4V battery, regulated to 5V using a 7805 voltage regulator. It uses an ESP32 microcontroller to interface with an ADXL345 accelerometer, INA219 current sensor, BMP280 pressure sensor, and an IR sensor, all connected via I2C and GPIO for data acquisition and processing.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with ADXL345

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Interfacing ADXL345 with Nano: A project utilizing ADXL345 in a practical application
Arduino Nano and ADXL345 Accelerometer Interface
This circuit features an Arduino Nano interfaced with an ADXL345 accelerometer for measuring acceleration. The Arduino provides power and I2C communication to the accelerometer, enabling it to capture and process motion-related data.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of mini project: A project utilizing ADXL345 in a practical application
Arduino Leonardo and ADXL345 Accelerometer-Based Motion Detection System
This circuit interfaces an ADXL345 accelerometer with an Arduino Leonardo via I2C communication. The Arduino provides power and ground to the accelerometer and reads acceleration data through the SDA and SCL lines.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Accelerometer ADXL345 Circuit Diagram: A project utilizing ADXL345 in a practical application
Arduino UNO and ADXL345 Accelerometer Data Logger
This circuit features an Arduino UNO microcontroller interfaced with an Adafruit ADXL345 accelerometer for motion detection, powered by two parallel-connected 18650 Li-ion batteries. The accelerometer communicates with the Arduino over I2C, and the system is designed for further code development to utilize the motion sensing capabilities.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Wind turbine 2.0: A project utilizing ADXL345 in a practical application
ESP32-Based Multi-Sensor Monitoring System with Battery Power
This circuit is a sensor monitoring system powered by a 7.4V battery, regulated to 5V using a 7805 voltage regulator. It uses an ESP32 microcontroller to interface with an ADXL345 accelerometer, INA219 current sensor, BMP280 pressure sensor, and an IR sensor, all connected via I2C and GPIO for data acquisition and processing.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications

  • Motion sensing in mobile devices
  • Tilt detection in gaming controllers
  • Gesture recognition in wearable devices
  • Vibration monitoring in industrial equipment
  • Step counting in fitness trackers

Technical Specifications

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

Pin Configuration and Descriptions

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.

Usage Instructions

Connecting the ADXL345 to an Arduino UNO

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)

Sample Arduino Code

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
}

Important Considerations

  1. Power Supply: Ensure the ADXL345 is powered with a voltage between 2.0V and 3.6V. Using 5V may damage the device.
  2. Pull-Up Resistors: For I2C communication, ensure pull-up resistors (typically 4.7kΩ) are connected to the SDA and SCL lines.
  3. Interrupts: The INT1 and INT2 pins can be configured for specific events like free-fall detection or activity monitoring.
  4. Data Rate: Adjust the data output rate based on your application to balance power consumption and performance.

Troubleshooting and FAQs

Common Issues

  1. No Data Output:

    • Ensure the ADXL345 is properly powered and connected.
    • Verify the I2C address (default is 0x53) and adjust in the code if necessary.
    • Check for loose or incorrect wiring.
  2. Incorrect or Unstable Readings:

    • Ensure the device is securely mounted to avoid vibrations.
    • Verify that the power supply voltage is stable and within the specified range.
    • Check for noise on the I2C lines and use shorter wires if necessary.
  3. Device Not Detected:

    • Confirm that the CS pin is tied to 3.3V for I2C mode.
    • Use an I2C scanner sketch to detect the device address.

FAQs

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.