'class ADXL345' has no member named 'begin'

Hi, I'd like to ask, why is there error that stated:
'class ADXL345' has no member named 'begin'

#include <Wire.h>
#include <ADXL345.h>

ADXL345 accelerometer;

void setup(void)
{
  Serial.begin(9600);
  
  pinMode(5,OUTPUT);
   Serial.println("Initializing ADXL345...");
     if(!accelerometer.begin())
   {
Serial.printlm("Could not find a valid ADXL345 sensor, check wiring!");
delay(500);
   }
  accelerometer.setFreeFallThreshold(0.35);
  accelerometer.setFreeFallDuration(0.1);
  accelerometer.useInterrupt(ADXL345_INT1);
}
void loop(void)
{
  delay(50);
Vector norm = accelerometer.readNormalize();
Activites activ = accelerometer.readActivites();
if(activ.isFreeFall)
{
  Serial.println("free fall detected");
  digitalWrite(5, HIGH);
  delay(3000);
}
}
     

It's almost certainly because the library you have for the accelerometer has no function called "begin"

1 Like

Suggestion: download the correct library.

Or, start by studying the examples that come with the library you already have.

It seems it was removed in 2017 (replaced with Wire.begin() according to the changelog).

You may want to have a look at this example.

after changing it to
if(!accelerometer Wire.begin())
there is another error
no match for 'operator!' (operand type is 'ADXL345')

That line doesn't make a lot of sense.
I'm not even sure

if (! Wire.begin ()) 

makes sense, because I think Wire.begin is a void function.

Post your complete revised code.

Post the complete error message .... not your paraphased version of it.

Post a GitHub link to the exact library you're using.

1 Like

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