ADXL345 3-Axis Accelerometer GY-291

(1 customer review)

3,95

The ADXL345 is a high-resolution 3-axis accelerometer.

1 in stock

SKU: HE0115-910 Categories: , Tags: , Send:

Description

ADXL345 is a small, low power, 3-axis accelerometer with high resolution (13-bit) measurement up to ± 16 g. Digital output of data is formatted as 16-bit. Readable via SPI or I2C.
For measuring: static (tilt) and dynamic (movements/shocks) acceleration.
Detection of: tap, double tap, free fall and inactive.

ADXL345 specifications:
– Works on: 2.0-3.6VDC.
– SPI and I2C interface.

Arduino code example:

#include <SPI.h>
int CS=10;

//This is a list of some of the registers available on the ADXL345.
char POWER_CTL = 0x2D;	//Power Control Register
char DATA_FORMAT = 0x31;
char DATAX0 = 0x32;	//X-Axis Data 0
char DATAX1 = 0x33;	//X-Axis Data 1
char DATAY0 = 0x34;	//Y-Axis Data 0
char DATAY1 = 0x35;	//Y-Axis Data 1
char DATAZ0 = 0x36;	//Z-Axis Data 0
char DATAZ1 = 0x37;	//Z-Axis Data 1

char values[10];
int x,y,z;

void setup(){ 
  SPI.begin();
  SPI.setDataMode(SPI_MODE3);
  Serial.begin(9600);
  
  pinMode(CS, OUTPUT);
  digitalWrite(CS, HIGH);
  
  //Put the ADXL345 into +/- 4G range by writing the value 0x01 to the DATA_FORMAT register.
  writeRegister(DATA_FORMAT, 0x01);
  //Put the ADXL345 into Measurement Mode by writing 0x08 to the POWER_CTL register.
  writeRegister(POWER_CTL, 0x08);  //Measurement mode  
}

void loop(){
  readRegister(DATAX0, 6, values);

  x = ((int)values[1]<<8)|(int)values[0];
  y = ((int)values[3]<<8)|(int)values[2];
  z = ((int)values[5]<<8)|(int)values[4];
  
  Serial.print(x, DEC);
  Serial.print(',');
  Serial.print(y, DEC);
  Serial.print(',');
  Serial.println(z, DEC);      
  delay(10); 
}
//This function will write a value to a register on the ADXL345.
void writeRegister(char registerAddress, char value){
  digitalWrite(CS, LOW);
  SPI.transfer(registerAddress);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}
//This function will read a certain number of registers starting from a specified address and store their values in a buffer.
void readRegister(char registerAddress, int numBytes, char * values){
  char address = 0x80 | registerAddress;
  if(numBytes > 1)address = address | 0x40;
  
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  for(int i=0; i<numBytes; i++){
    values[i] = SPI.transfer(0x00);
  }
  digitalWrite(CS, HIGH);
}

1 rating for ADXL345 3-Axis Accelerometer GY-291

  1. Electronics4Fun (verified owner)

    Also works very well with I2c, for code and library google: AdaFruit. Sensitivity can be set in software between 2 and 16 G. Measures movements x, y, z accurately. The possibilities include controlling games, servos, measuring acceleration and deceleration, tapping, double tapping, position of e.g. your robot, is it upside down, sideways, is it driving up or down a slope, tilting, locating collisions. But also to measure, for example, at what position your garage door is open, or how far a casement window is tilted, you can even build an electronic spirit level with it. It is a sensor for 1001 possibilities. Everything that moves, accelerates, decelerates, moves at a certain angle can be measured very accurately.

Only logged in customers who have purchased this product may leave a review.

Shipping within the Netherlands

This product will be delivered via PostNL letter post in a bubble envelope.
- €3.45 shipping costs for orders under €25.
- €2.95 shipping costs for orders between €25 - €45.
- Orders above € 45,- will be park for free sent by PostNL letter post.

  • Ordered before 16:30 PM on workdays, shipped the same day!
    Click here for costs outside the Netherlands.
  • Product question?

      Your Name (required)

      Your Email (required)

      your question

      You may also like ...