Go Down

Topic: ADXL345 i2c PROBLEMS (Read 12560 times) previous topic - next topic


I found the mistake, Like an idiot I had commented out the line
readFrom(DEVICE, regAddress, TO_READ, buff);, in my previous debugging attempts and didn't check to uncomment it
Everything works fine now. Sorry for wasting your time.


Oh no, I'm new with arduino and have the same issue, that my ADXL345 only shows 0 0 0 for x y z.

I tried several tutorials like http://www.babelduck.com/index.php/en/reference/user-manuals/1427-adxl345-3-axis-accelerometer-sensor-module-product-manual and http://bildr.org/2011/03/adxl345-arduino/ but with all of these my accelerometer seems to deliver only nulls...

It's brand new and it's hard to believe, that it's broken. Wiring was always like it should.

Anyone a further idea?

Thank you so much!


Hello; i havent read the whole thread; so maybe i'm repeataing something.
im reading this tutorial:

and says something that recalled your problem to me: His code writes three bytes to the device before asking for a reading, to take it out from sleep mode (which will give zero readings). We are talking about I2C communication.

See this:
Code: [Select]
#include <Wire.h>
#define DEVICE (0x53)    //ADXL345 device address
#define TO_READ (6)        //num of bytes we are going to read each time (two bytes for each axis)

byte buff[TO_READ] ;    //6 bytes buffer for saving data read from the device
char str[512];                      //string buffer to transform data before sending it to the serial port

void setup()
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  //Turning on the ADXL345
  writeTo(DEVICE, 0x2D, 0);     
  writeTo(DEVICE, 0x2D, 16);
  writeTo(DEVICE, 0x2D, 8);

Look it up. then, the author then explains:
Most of the code is pretty self-explanatory, so I'll explain only the code after the //Turning on the ADXL345 comment.
As you can see we are writing three different values to register 0x2D. 0x2D is the Power Control register of the ADXL345 (see datasheet). We first reset the power control register, then put the sensor in standby mode, and last we are putting it in to measure mode. We're doing the writes one after another because that's what the datasheet recommends. We could simply do the last write also. If you don't turn on the fourth bit on (writeTo(DEVICE, 0x2D, 8)) the sensor will be in sleep mode, and will give zero readings!!

So the device must be waked up before use.

Hope this helps.


Aug 23, 2015, 10:43 pm Last Edit: Aug 23, 2015, 10:50 pm by impeham
I just tried playing with this ADXL3 I2C module. have used the program and circuit described here:


for some reason, i'm getting a good read from x and y, but z read is constant and equals to 511.

i'm using arduino nano, SDA is connected to A4, SCL connected to A5.

Any idea why is that and how to fix it?

Go Up