Problem with an ADXL345 Accelerometer with an Arduino Due

So I'm just running some tests on the functionality of an ADXL345 3-axis accelerometer with an Arduino Due and I'm running the test code posted on the same page (here) as the product details of what I have, I've wired the device just as in the diagram there as well and am using the test code there as well, the code compiles, uploads and seems to be running correctly, but my serial monitor sends scrolling outputs as follows:

The acceleration info of x, y, z are:0 0 0
Roll:0.00
Pitch:0.00

The acceleration info of x, y, z are:0 0 0
Roll:0.00
Pitch:0.00

And nothing changes even when I change the orientation of the breakout board. Any ideas. Is this because the wiring diagram is for an Uno not a Due?

StellarJay:
So I'm just running some tests on the functionality of an ADXL345 3-axis accelerometer with an Arduino Due and I'm running the test code posted on the same page (here) as the product details of what I have, I've wired the device just as in the diagram there as well and am using the test code there as well, the code compiles, uploads and seems to be running correctly, but my serial monitor sends scrolling outputs as follows:

The acceleration info of x, y, z are:0 0 0
Roll:0.00
Pitch:0.00

The acceleration info of x, y, z are:0 0 0
Roll:0.00
Pitch:0.00

And nothing changes even when I change the orientation of the breakout board. Any ideas. Is this because the wiring diagram is for an Uno not a Due?

Hello StellarJay,

The Wire (I2C) pins in UNO and DUE are different. The example that you mentioned only works with UNO that uses pins A4(SDA) and A5(SCL). For Due you have to use pins 20(SDA) and 21(SCL).
To make it easier, search in this forum (in the Arduino Due topics) for ADXL345 examples. Good luck!

EDIT: It is weird that your link states a Power voltage range between 3.3 and 6V for the ADXL345. According to the manufacturer, the voltage range is between 2.0 to 3.6V, thus, be careful with that. Remember also that Arduino Due is not tolerant to 5V in the I/O.

-p

-p

Palliser:
Hello StellarJay,

The Wire (I2C) pins in UNO and DUE are different. The example that you mentioned only works with UNO that uses pins A4(SDA) and A5(SCL). For Due you have to use pins 20(SDA) and 21(SCL).
To make it easier, search in this forum (in the Arduino Due topics) for ADXL345 examples. Good luck!

EDIT: It is weird that your link states a Power voltage range between 3.3 and 6V for the ADXL345. According to the manufacturer, the voltage range is between 2.0 to 3.6V, thus, be careful with that. Remember also that Arduino Due is not tolerant to 5V in the I/O.

-p

-p

That worked perfectly now I am getting values, however, using that code is giving me rest values of x:~65530, y: ~65530, z: ~270, with playing around with the orientation it appears the 65535 is wrapping to 0. So 65535 to ~65260 are representing negative numbers and 0 to ~270 are positive. Is that correct behavior?

EDIT: it also shows the working voltage draw is only 2.5v: 40uA, I think the working Voltage being listed that way means it'll tolerate and function by being attached to 3V or 5V connections

StellarJay:
That worked perfectly now I am getting values, however, using that code is giving me rest values of x:~65530, y: ~65530, z: ~270, with playing around with the orientation it appears the 65535 is wrapping to 0. So 65535 to ~65260 are representing negative numbers and 0 to ~270 are positive. Is that correct behavior?

EDIT: it also shows the working voltage draw is only 2.5v: 40uA, I think the working Voltage being listed that way means it'll tolerate and function by being attached to 3V or 5V connections

No, not normally. The problem is that DDUE INT type is 4 bytes.
write so specifically for DUE:

#if F_CPU == 84000000L
typedef short int16;
#else
typedef int int16;
#endif

.
.
.

int16 x, y, z;

x = ((int16) values [1] << 8) | (int16) values [0];
// The Y value is stored in values [2] and values [3].
y = ((int16) values [3] << 8) | (int16) values [2];
// The Z value is stored in values [4] and values [5].
z = ((int16) values [5] << 8) | (int16) values [4];