The Adafruit ADXL345 is a compact, low-power, 3-axis MEMS accelerometer that measures acceleration with a full-scale range of ±2g, ±4g, ±8g, or ±16g. It is capable of measuring both dynamic acceleration (e.g., motion or shock) and static acceleration (e.g., gravity). This versatility makes it suitable for a wide array of applications including mobile devices, gaming systems, industrial instrumentation, and personal navigation devices.
Parameter | Condition | Min | Typ | Max | Unit |
---|---|---|---|---|---|
Supply Voltage | VDD | 2.0 | 3.3 | 3.6 | V |
Output Data Rate | 0.1 | 3200 | Hz | ||
Current Consumption | Measurement Mode | 40 | µA | ||
Temperature Range | Operating | -40 | +85 | °C |
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground |
2 | VCC | Power supply (2.0V to 3.6V) |
3 | SDA | I2C Data / SPI Serial Data Input (SDI) |
4 | SDO | SPI Serial Data Output (SDO) / I2C Addr |
5 | SCL | I2C Clock / SPI Serial Clock (SCK) |
6 | CS | SPI Chip Select (Active Low) / I2C Enable |
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
void setup(void) {
Serial.begin(9600);
Serial.println("Accelerometer Test"); Serial.println("");
// Initialize the accelerometer.
if(!accel.begin()) {
Serial.println("No ADXL345 detected");
while(1);
}
// Set the range to whatever is appropriate for your project.
accel.setRange(ADXL345_RANGE_16_G);
}
void loop(void) {
sensors_event_t event;
accel.getEvent(&event);
// Display the results (acceleration is measured in m/s^2).
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(" ");
Serial.println("m/s^2 ");
// Delay before the next reading.
delay(500);
}
Q: Can the ADXL345 be used to detect orientation? A: Yes, by measuring static acceleration due to gravity, the ADXL345 can determine the angle at which it is tilted with respect to the earth's surface.
Q: What is the purpose of the CS pin? A: The CS pin is used to enable SPI communication. When using I2C, this pin can be tied to VCC to disable SPI mode.
Q: How can I reduce power consumption? A: The ADXL345 has a low power mode that can be enabled through software. Additionally, reducing the output data rate can also decrease power consumption.
For further assistance, consult the datasheet or contact Adafruit's support forums.