blog

Easy to Use Accelerometer Module – ADXL345

ADXL345 Cover(1)

What is ADXL345?

The ADXL345 sensor is a 3-axis accelerometer with high resolution (3.9 mg/LSB), capable of measuring tilt angle changes of less than 1.0 degree. It is compact, slim, and low – power. The digital output data is in 16 – bit two’s complement format and can be accessed via SPI or I2C digital interfaces. The ADXL345 is a 3 – axis, digital output accelerometer sensor launched by ADI based on iMEMS technology. The characteristics of this accelerometer sensor are as follows:

  1. High resolution: Up to 13 – bit resolution.
  2. Variable measurement range: It has variable measurement ranges of +/-2g, +/-4g, +/-8g, and +/-16g.
  3. High sensitivity: Up to 3.9mg/LSB, it can measure tilt angle changes of less than 1.0°.
  4. Low power consumption: Ultra – low power consumption of 40 – 145uA, and only 0.1uA in standby mode.
  5. Small size: The entire IC has a size of only 3mm * 5mm * 1mm, with LGA packaging.

ADXL supports standard I2C or SPI digital interfaces, has a built – in 32 – level FIFO storage, and features various internal motion state detection and flexible interrupt modes, etc.

What is the composition of the ADXL345 module?

The ADXL345 accelerometer module is composed of a voltage regulator IC, a level shifter IC, an ADXL345 accelerometer IC, as well as resistors and capacitors.
Components of the ADXL345(1)
Components of the ADXL345

What is the function of ADXL345?

The function of ADXL345 is to detect acceleration, and it can calculate the corresponding tilt angle in conjunction with gravitational acceleration.

How does the ADXL345 work?

ADXL345 is a 3 – axis accelerometer sensor based on Micro – Electro – Mechanical Systems (MEMS) technology. It adopts a miniature mechanical structure and is supported by built-in polycrystalline silicon springs. It will deflect when it is subjected to acceleration, generating a slight displacement to change the capacitance between the overhang mass and the fixed plate. When the capacitance changes due to acceleration, it will be converted into an analog voltage, which is then digitally converted by the built – in ADC (Analog – to – Digital Converter) to output a 16 – bit two’s complement, representing the acceleration of the X, Y, and Z axes. ADXL345 is widely used in mobile phones, motion health detection devices, etc.

Specification Parameter Table

And we provide you with the ADXL345 datasheet.

ADXL345 PINS

GND:Power supply negative pole

VCC:Power supply positive pole (3.3–6V)

CS:Chip select

INT1:Interrupt 1 output

INT2:Interrupt 2 output

SDO: IIC address setting / SPI data output

SDA:IIC data line (compatible with 5V level) / SPI data I/O port

SCL:IIC clock line (compatible with 5V level) / SPI clock line

ADXL345(1)
ADXL345 Pinout Display

How to connect ADXL345 to Arduino ?

There are many ways to connect ADXL345 to Arduino, and the codes also have slight differences. Here we provide you with an example connection diagram and sample code for reference.
ADXL345 connects to Arduino
ADXL345 connects to Arduino
ADXL345 connected to Arduino schematic1
ADXL345 connected to Arduino schematic

sample code

				
					#include <Wire.h>  // Wire library - used for I2C communication
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>//OLED library

Adafruit_SSD1306 display(128,64, &Wire, -1);//Set the screen size of OLED

int ADXL345 = 0x53;         // The ADXL345 sensor I2C address
float X_out, Y_out, Z_out;  // Outputs
void setup() {
  Serial.begin(9600);
  Wire.begin();             // Initiate the Wire library
  // Set ADXL345 in measuring mode
  Wire.beginTransmission(ADXL345); // Start communicating with the device
  Wire.write(0x2D); // Access/ talk to POWER_CTL Register - 0x2D
  // Enable measurement
  Wire.write(8); // (8dec -> 0000 1000 binary) Bit D3 High for measuring enable
  Wire.endTransmission();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);//Initialize OLED and set IIC communication address
  delay(10);
}
void loop() {
  Wire.beginTransmission(ADXL345);
  Wire.write(0x32); // Start with register 0x32 (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(ADXL345, 6, true); // Read 6 registers total, each axis value is stored in 2 registers
  X_out = ( Wire.read()| Wire.read() << 8); // X-axis value
  X_out = X_out/256; //For a range of +-2g, we need to divide the raw values by 256, according to the datasheet
  Y_out = ( Wire.read()| Wire.read() << 8); // Y-axis value
  Y_out = Y_out/256;
  Z_out = ( Wire.read()| Wire.read() << 8); // Z-axis value
  Z_out = Z_out/256;
  Serial.print("Xa= ");
  Serial.print(X_out);
  Serial.print("   Ya= ");
  Serial.print(Y_out);
  Serial.print("   Za= ");
  Serial.println(Z_out);
  display.clearDisplay();//Clear screen
  display.setTextColor(WHITE);//Setting text color, monochrome OLED is invalid, but must have
  display.setTextSize(2);//Set text size
  display.setCursor(0, 0);
  display.print("X: ");
  display.print(X_out);
  display.setCursor(0, 20);
  display.print("Y: ");
  display.print(Y_out);
  display.setCursor(0, 40);
  display.print("Z: ");
  display.print(Z_out);
  display.display();//Execute Display
  delay(100);
}
				
			

What is the difference between ADXL345 and ADXL335?

ADXL345 is an upgraded version of ADXL. In addition to measuring gravitational acceleration, it also provides more advanced functions such as tap detection. It also improves the maximum measured value and resolution (accuracy) of gravitational acceleration, and adds an on – board FIFO data buffer to ensure that data will not be overwritten by newly generated data during transmission.

What are the application scenarios for ADXL345?

ADXL345 has a wide range of application fields, especially for moving objects. It can detect tilt and acceleration. The high resolution of 4 mg/LSB enables it to detect a 1° tilt, and it can even easily handle CNC machine tools.

Which is better, MPU6050 or ADXL345?

MPU6050 not only provides acceleration detection but also rotation angle, making it suitable for fields that require a gyroscope, such as drones. But ADXL345 has higher accuracy and a faster data reading frequency, making it suitable for automated equipment that requires precise control, such as CNC machine tools.

FAQS

What is the range of ADXL345 in g?

ADXL345 can provide a maximum acceleration detection range of 16G, which can cope with most scenarios.

Is ADXL345 3V or 5V

It has a wide voltage input, and both 3.3V – 5V can be used. The module has a voltage regulator chip for separate power supply.

Is ADXL345 an IMU?

Strictly speaking, ADXL345 is not an IMU because it can only detect real – time acceleration but cannot distinguish rotation.

How fast is ADXL345?

The maximum data transmission rate of ADXL345 can reach up to 3200Hz.

What is acceleration and how is it measured

Acceleration is the way of acceleration expressed relative to the gravity of the Earth. Accelerometers usually use a small mass block, which will produce a relative displacement under the action of acceleration.Then the displacement generated by this movement is measured through changes in capacitance or resistance and converted into an acceleration value.

Leave a Reply

Your email address will not be published. Required fields are marked *