ADXL345: get angle form G-force

Hi,

I have G-force values. How to get angle (degrees)? I am confused :confused:

Code:

#include <Wire.h>

#include <Adafruit_Sensor.h>

#include <Adafruit_ADXL345_U.h>

Adafruit_ADXL345_Unified BSens = Adafruit_ADXL345_Unified(1);


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  BSens.begin();
}

void loop() {


  
  // put your main code here, to run repeatedly:
  sensors_event_t event;
  BSens.getEvent(&event);
  Serial.print("X: ");
  Serial.println(event.acceleration.x);
  Serial.print("Y: ");
  Serial.println(event.acceleration.y);
  Serial.print("Z: ");
  Serial.println(event.acceleration.z);
  Serial.println("|-------------|");
  delay(500);
}

Thanks very much! Einars.

Which angle?

The angle of rotation along the y axis? x axis? z axis?

The angle between point A and point B of displacement in Cartesian co-ordinates?

Maybe a diagram may help us understand what you mean by "the angle".

atan2 is always the answer to this sort of question....

Yes XYZ! :slight_smile: