Skip to content

3-Axis Digital Accelerometer Unit (ADXL345)

Description

ACCEL is a motion sensor Unit. Integrated with ADXL 345, ACC is able to obtain 3- axis of Acceleration. ADXL 345 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 an SPI (3- or 4-wire) or I2C digital interface. In this Unit, we used I2C series interface. 

What is an accelerometer?
An accelerometer is an electromechanical device that will measure acceleration forces. These forces may be static, like the constant force of gravity pulling at your feet, or they could be dynamic - caused by moving or vibrating the accelerometer. 
What are accelerometers useful for?
By measuring the amount of static acceleration due to gravity, you can find out the angle the device is tilted at with respect to the earth. By sensing the amount of dynamic acceleration, you can analyze the way the device is moving. At first, measuring tilt and acceleration doesn’t seem all that exciting. However, engineers have come up with many ways to make really useful products with them. 


Product Features

  • Tiny
  • ultralow power
  • 3-axis accelerometer

Include

  • 1x ACC unit
  • 1x GROVE Cable

Application

  • Building and structural monitoring
  • Navigation
  • Orientation sensing
Documents
Learn

PinMap

M5Core ( GROVE A ) GPIO22 GPIO21 5V GND
ACC Unit SCL SDA 5V GND

Code

1. Arduino IDE

To get complete code, please click here.
Download library ADXL345 before compile.

#include <M5Stack.h> #include <ADXL345.h>  ADXL345 accel(ADXL345_ALT); // download this library before compile. //https://github.com/jakalada/Arduino-ADXL345  // initialization void setup() {    M5.Lcd.setCursor(20, 100); M5.Lcd.print(" x ");   M5.Lcd.setCursor(120, 100); M5.Lcd.print(" y ");   M5.Lcd.setCursor(220, 100); M5.Lcd.print(" z ");   ...   byte deviceID = accel.readDeviceID(); }  void loop() {     if (accel.update()) {     M5.Lcd.fillRect(0, 130, 360, 30, BLACK);     M5.Lcd.setCursor(15,  130); M5.Lcd.print((int)(1000*accel.getX()));     M5.Lcd.setCursor(115, 130); M5.Lcd.print((int)(1000*accel.getY()));     M5.Lcd.setCursor(215, 130); M5.Lcd.print((int)(1000*accel.getZ()));     ... }

Video

The 3-Axis Digital Accelerometer Unit (ADXL345) appears in the following collections:

SKU M5-U056