ADXL345 Triple Axis Accelerometer Breakout

From Geeetech Wiki
Revision as of 02:16, 23 May 2012 by Admin (talk | contribs) (Introduction)

Jump to: navigation, search

Introduction

ADXL345 1.jpg

This is a breakout board for Analog Devices ADXL345 3-Axis Accelerometer.The ADXL345 is a small, thin, ultralow power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface. The ADXL345 is well suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (3.9 mg/LSB) enables measurement of inclination changes less than 1.0°.

Features

  • Ultralow power: as low as 23 μA in measurement mode
  • Fixed 10-bit resolution Full resolution, up to 13-bit resolution at ±16 g
  • Single tap/double tap detection
  • Activity/inactivity monitoring
  • Free-fall detection
  • Supply voltage range: 2.0 V to 3.6 V
  • I/O voltage range: 1.7 V to VS
  • SPI (3- and 4-wire) and I2C digital interfaces

Usage

Here is the guide illustrates how to connect an Arduino to the ADXL335 breakout board. The following is a table describing which pins on the Arduino should be connected to the pins on the accelerometer:

500px

File:ADXL345 table.jpg


Example code

#include <Wire.h>  
#define Register_ID 0
#define Register_2D 0x2D
#define Register_X0 0x32
#define Register_X1 0x33
#define Register_Y0 0x34
#define Register_Y1 0x35
#define Register_Z0 0x36
#define Register_Z1 0x37
//
int ADXAddress = 0xA7>>1;  
int reading = 0;
int val = 0;
int X0,X1,X_out;
int Y0,Y1,Y_out;
int Z1,Z0,Z_out;
double Xg,Yg,Zg;
void setup()
{
 Serial.begin(9600);
 Wire.begin();  
 delay(100);
 Wire.beginTransmission(ADXAddress);
 Wire.send(Register_2D);
 Wire.send(8);
 Wire.endTransmission();
}
void loop()
{
 Wire.beginTransmission(ADXAddress);
 Wire.send(Register_X0);
 Wire.send(Register_X1);
 Wire.endTransmission();
 Wire.requestFrom(ADXAddress,2);
 if(Wire.available()<=2);
 {
   X0 = Wire.receive();
   X1 = Wire.receive();
   X1 = X1<<8;
   X_out = X0+X1;
 }
 //
 Wire.beginTransmission(ADXAddress);
 Wire.send(Register_Y0);
 Wire.send(Register_Y1);
 Wire.endTransmission();
 Wire.requestFrom(ADXAddress,2);
 if(Wire.available()<=2);
 {
   Y0 = Wire.receive();
   Y1 = Wire.receive();
   Y1 = Y1<<8;
   Y_out = Y0+Y1;
 }
 //
 Wire.beginTransmission(ADXAddress);
 Wire.send(Register_Z0);
 Wire.send(Register_Z1);
 Wire.endTransmission();
 Wire.requestFrom(ADXAddress,2);
 if(Wire.available()<=2);
 {
   Z0 = Wire.receive();
   Z1 = Wire.receive();
   Z1 = Z1<<8;
   Z_out = Z0+Z1;
 }
 //
 Xg = X_out/256.00;
 Yg = Y_out/256.00;
 Zg = Z_out/256.00;
 //
 Serial.print(" X=");
 Serial.print(Xg);
 //
 Serial.print(" Y=");
 Serial.print(Yg);
 //
 Serial.print(" Z=");
 Serial.println(Zg);
 delay(300); 
 }

How to buy

Click here to buy ADXL345 3-Axis Accelerometer Breakout