ADXL345 not connected, using ESP32 as microcontroller

I am trying to use adxl345 to send vibration signals with the ESP32 as the microcontroller. However, the serial monitor only outputs "ADXL345 is not connected" despite having my connections correct which are just vcc to 3.3v, gnd to gnd, sda to d21, and scl to d22. I have also tried using the CS and SDO connections, but still the same output. Could it be a sensor issue? Since the ESP32 is functioning, i checked it too. I also have a code for checking I2C devices connection but still outputs no I2C connected.

Here is my main code (not everything):

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>

// Initialize ADXL345 sensor
Adafruit_ADXL345_Unified adxl = Adafruit_ADXL345_Unified(12345);

void setup() {
    Serial.begin(115200); 
 
    if (!adxl.begin()) {
        Serial.println("ADXL345 not detected. Check wiring!");
        while (1);
    }

Here is the code for like a test to see if an I2C device is connected

#include <Wire.h>

void setup() {
  Serial.begin(115200);
  Wire.begin(); // Default SDA=21, SCL=22
  
  Serial.println("Scanning for I2C devices...");
}

void loop() {
  byte error, address;
  int nDevices = 0;
  
  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      Serial.println(address, HEX);
      nDevices++;
    }
  }
  
  if (nDevices == 0) Serial.println("No I2C devices found. Check wiring!");
  delay(2000);
}




Do you have the header soldered onto the ADXL board or is it just poking through the holes?
It won't work unless it's soldered.

1 Like

Good day! Oh, I did not solder my header pins yet because I was planning to after the code works and when I checked online, they did not really solder it but it still worked so I really thought the problem is my module. Thanks for your insights.

They fooled you.
You can try pushing the board towards the pins so they make contact but it still may not work.
Must be soldered.

  • or an appropriate mating connector (like those used by shields) soldered if you want to change later,

Still must be soldered.

1 Like

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