Description
What it is
The ADXL345 accelerometer is a digital sensor that allows measuring acceleration and tilt, useful for projects requiring motion and orientation detection.
Features
- ADXL345 Sensor
- IIC SPI Digital Communication
What it is for
The accelerometer can be used to create projects that require motion and orientation detection, such as a simple digital clock that turns on when the module is tilted. Compatible with Arduino and ESP.
Tutorial: How to Use the ADXL345 IIC SPI Accelerometer Module
The ADXL345 is a digital sensor for measuring acceleration and tilt. Useful for projects that require motion and orientation detection.
What you need
- Arduino or compatible
- IIC Cable
- VCC/GND Cable
- PC with Arduino IDE
Steps
- 1. Connect VCC to 3.3V of Arduino and GND to GND.
- 2. Connect SDA to pin 4 of Arduino.
- 3. Connect SCL to pin 5 of Arduino.
- 4. Load the basic Sketch code.
- 5. Check the datasheet for the maximum acceleration values.
- 6. Try moving the module and observe the changes on Serial Monitor.
- 7. Implement the module in a subsequent project.
- 8. Test the project and fix any errors.
Example code
```cpp
#include <Wire.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified();
void setup() {
Wire.begin();
if (!accel.begin()) {
Serial.println("Failed to initialize ADXL345!");
while (1);
}
}
void loop() {
float x, y, z;
accel.getAcceleration(&x, &y, &z);
Serial.print("x:"); Serial.print(x);
Serial.print(" y:"); Serial.print(y);
Serial.print(" z:"); Serial.println(z);
}
```
Mini project
Create a simple digital clock that turns on when the module is tilted.
Common mistakes
- Incorrect connection to VCC/GND.
- Error in IIC pin selection.
- Incorrect or unuploaded Sketch code.
- Serial Monitor not configured correctly.
Recommended accessories
- Arduino UNO
- 16×2 LCD Display
- 10kΩ Resistor
- 3.7V Battery
Frequently asked questions
How can I connect the module if I don’t have an Arduino?
You can use a compatible microcontroller like ESP32 or Raspberry Pi.
What maximum acceleration values should I consider?
Check the datasheet. Maximum 16g.
Does the module work with Arduino Nano?
Yes, but make sure the VCC is 3.3V.
Can I use this module for a navigation project?
Yes, but consider adding a magnetometer for orientation.







Reviews
There are no reviews yet.