Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use ADXL345: Examples, Pinouts, and Specs

Image of ADXL345Design with ADXL345 in Cirkit Designer

Introduction

The ADXL345 is a compact, low-power, 3-axis accelerometer that offers high-resolution (13-bit) measurement across a range of up to ±16 g. Manufactured by Adafruit, this versatile sensor is capable of providing real-time acceleration data, which makes it ideal for applications in motion detection, free-fall detection, and dynamic orientation detection. Common use cases include mobile devices, gaming systems, and activity monitoring.

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 Arduino UNO and ADXL345 Accelerometer Data Logger: 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.

Open Project in Cirkit Designer

Technical Specifications

Key Features

Electrical Characteristics

Parameter Condition Min Typ Max Unit
Supply Voltage VDD 2.0 3.3 3.6 V
I/O Voltage VDDIO 1.7 3.3 3.6 V
Output Current per pin 10 mA
Operating Temp. Range -40 +85 °C

Pin Configuration

Pin Number Name Description
1 GND Ground
2 VCC Power supply (2.0V to 3.6V)
3 CS Chip select for SPI (active low)
4 INT1 Interrupt 1 output
5 INT2 Interrupt 2 output
6 SDO Serial data out for SPI / alt address for I2C
7 SDA Serial data for I2C / MOSI for SPI
8 SCL Serial clock for I2C / SCLK for SPI

Usage Instructions

Integration with a Circuit

To use the ADXL345 in a circuit:

  1. Connect VCC to a 2.0V to 3.6V power supply.
  2. Connect GND to the ground of your system.
  3. For I2C communication, connect SDA and SCL to your microcontroller's I2C bus. If using SPI, connect SDA (MOSI), SCL (SCLK), and SDO (MISO) to the corresponding SPI pins on your microcontroller.
  4. The CS pin can be connected to a digital I/O pin on your microcontroller for SPI mode. Leave it unconnected or tie it to VCC for I2C mode.
  5. INT1 and INT2 can be connected to interrupt-capable pins on your microcontroller if you wish to use the interrupt features.

Best Practices

Example Code for Arduino UNO

#include <Wire.h>
#include <Adafruit_ADXL345_U.h>

Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

void setup() {
  Serial.begin(9600);
  if (!accel.begin()) {
    Serial.println("No ADXL345 detected");
    while (1);
  }
  accel.setRange(ADXL345_RANGE_16_G);
}

void loop() {
  sensors_event_t event; 
  accel.getEvent(&event);

  Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" ");
  Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" ");
  Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" m/s^2 ");
  Serial.println();

  delay(500);
}

This example initializes the ADXL345 and continuously reads the acceleration data along the X, Y, and Z axes, outputting the results to the serial monitor.

Troubleshooting and FAQs

Common Issues

FAQs

Q: Can the ADXL345 be used with a 5V microcontroller? A: Yes, but ensure that the I/O voltage does not exceed 3.6V. Use level shifters if necessary.

Q: How can I change the data rate of the sensor? A: Use the setDataRate() function provided by the Adafruit ADXL345 library to configure the output data rate.

Q: What is the purpose of the CS pin? A: The CS pin is used to select the ADXL345 when multiple devices are connected to the same SPI bus. It is not used in I2C mode.

For further assistance, consult the Adafruit ADXL345 datasheet and the library documentation.