Understeanding ADXL345_WE lib

i run this code in esp32 (code at end of the post) and try to get data from adxl345 , all is ok , just i cant understeand well some parts

Qustion 1:

myAcc.setActivityParameters(ADXL345_AC_MODE, ADXL345_XY0, 0.2);

1. DC / AC Mode:
    ADXL345_DC_MODE - Threshold is the defined one (parameter 3)
    ADXL345_AC_MODE - Threshold = starting acceleration + defined threshold
2. Axes, that are considered:
    ADXL345_XY0  -  x,y
    ADXL345_XYZ  -  all axes
3. Threshold in g 

so if value of x and y are betweeen g.x=0.04 | g.x=0.08 and g.y=0.00 | g.y=-0.04
and i dont want to get interrupt if difference is 0.04 , and get interrupt only if difference is more than that what should i set here:

myAcc.setActivityParameters(ADXL345_AC_MODE, ADXL345_XY0, xxx);


Qustion 2:
what really is AC and DC - can u give any example


Qustion 3:

myAcc.setDataRate(ADXL345_DATA_RATE_1_56);

data rates incan be:

3200Hz, 1600Hz, 800Hz, 400Hz, 200Hz, 100Hz, 50Hz, 25Hz, 12.5Hz, 6.25Hz, 3.13Hz, 1.56Hz, 0.78Hz, 0.39Hz, 0.20Hz, 0.10Hz

does this mean if i set to 1Hz the sensor will get g.X , g.Y values every second and comapre


Qustion 4:

myAcc.setRange(ADXL345_RANGE_4G);

ADXL345_RANGE_16G    16g     
ADXL345_RANGE_8G      8g     
ADXL345_RANGE_4G      4g   
ADXL345_RANGE_2G      2g

what is the real difference, of 2g and 16g , if i set 16G does this mean sensor is less sensitive for small movement or can u give me an example

CODE:

#include <Wire.h>
#include <ADXL345_WE.h>
const int interrupt_pin = 23;
volatile bool in_activity = false; // in_activity: activity  interrupt occurred
ADXL345_WE myAcc = ADXL345_WE(0x53);

void setup() {
  Wire.begin();
  Serial.begin(9600);
  pinMode(interrupt_pin, INPUT);
  if (!myAcc.init()) {
    Serial.println("ADXL345 not connected!");
  }

  myAcc.setDataRate(ADXL345_DATA_RATE_1_56);
  myAcc.setRange(ADXL345_RANGE_2G);
  attachInterrupt(digitalPinToInterrupt(interrupt_pin), in_activityISR, RISING);


  myAcc.setActivityParameters(ADXL345_AC_MODE, ADXL345_XY0, 0.2);
  
  myAcc.setInterrupt(ADXL345_ACTIVITY, INT_PIN_1);
  myAcc.readAndClearInterrupts();
}

void loop(){
  if (in_activity == true) { 
    String axes = myAcc.getActTapStatusAsString();
    byte intSource = myAcc.readAndClearInterrupts();

    if (myAcc.checkInterrupt(intSource, ADXL345_ACTIVITY)) {
      Serial.print("Activity at: ");
      Serial.println(axes); 
    } 

    delay(1000);
    myAcc.readAndClearInterrupts();
    in_activity = false;
  }
}

void in_activityISR() {
  in_activity = true;
}
 

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.