I2C help ADXL345 3-axis accelerometer from sparkfun

Hello, I bought the breakboard for the ADXL345 from sparkfun and can't seem to get it to talk to the picaxe.
I have gotten it to work perfectly on the arduino, so I know that the chip itself is working.

The problem I am having is that the values I am receiving from the chip are all 255.
The Picaxe I am using is the 14m2.
I am not very experienced with picaxe, so the problem is most likely my code.


Here is my code (14m2 chip):





HI2CSETUP I2CMASTER, 0x53, i2cfast, i2cbyte

HI2COUT 0x31,(0x01) 'Put the ADXL345 into +/- 4G range
HI2COUT 0x2D,(0x08) 'Put the ADXL345 into Measurement Mode

main:

HI2CIN 0x32,(b1,b2,b3,b4,b5,b6) 'read x1,x2,y1,y2,z1,z2 values

pause 5
debug
goto main







the code was converted from arduino to picaxe as best I could from this tutorial: https://www.sparkfun.com/tutorials/240


here is a picture of my setup: http://imgur.com/jk3AwBD

The circuit is wired according to diagram on page 10 of the ADXL345 datasheet found here: https://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345.pdf

The picaxe and adxl345 are being powered by an arduino's 3v3 power.
The SDA pin is connected to pin 9 of the picaxe
The SCL pin is connected to pin 10 of the picaxe
both are pulled high by 10k resistors

the CS pin is connected to +ve
the SDO pin is connected to -ve (according to the diagram this gives the address 0x53)

here is a screenshot of the debug: http://imgur.com/VokKWEy



So I'm at a loss as to what to do. I really do not understand registers and I2C in general, but I would think that my code is right.

If someone could correct my code, and maybe let me know what my mistake was that would be really appreciated!

thanks,
James
 
The 8 bit slave address to use is $A6, do not use the 7 bit address $53
so your saying the correct coded line is: "HI2CSETUP I2CMASTER, 0xA6, i2cfast, i2cbyte" ???

I am not 100% sure what your answer means, especially the $ part. Again i am very new to this....
 

abdeshpande

New Member
Hi! I'm currently trying to using the adxl345 with the picaxe 08m2! I can read values, but I don't know how to use that value to get Gs of acceleration. Could you explain or post the rest of the code to give me an example? Thanks!
 
Top