User avatar
joan
Posts: 14747
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ADXL345 only returning -2.048

Mon Jan 12, 2015 5:01 pm

rudy0912 wrote:"pigs spix 0 0xf2 0 0 0 0 0 0" returns "7 240 0 240 0 240 0 240" every time
I'm afraid it doesn't look good for your ADXL345.

Could you try the following commands

pigs spic 0 # close SPI channel
pigs spio 1 40000 3 # re-open
pigs spix 0 0xc0 0 0 # read device Id

It should return

3 229 229 0

If that doesn't work it's a final check that the connections are secure and correct and then the bin I'm afraid.

rgrbic
Posts: 128
Joined: Thu Jun 12, 2014 1:07 pm
Contact: Website

Re: ADXL345 only returning -2.048

Mon Jan 12, 2015 5:12 pm

Does the adxl345 board have pull up resistors? If so maybe you have too strong pull up on the bus since you have parallel connection of resistors on the adxl board and on raspberry pi sda and scl lines.
At 127.0.0.1
Twitter: @rgrbic
IoT-projects.com

rudy0912
Posts: 20
Joined: Wed Dec 24, 2014 9:29 pm

Re: ADXL345 only returning -2.048

Mon Jan 12, 2015 5:18 pm

joan wrote:
rudy0912 wrote:"pigs spix 0 0xf2 0 0 0 0 0 0" returns "7 240 0 240 0 240 0 240" every time
I'm afraid it doesn't look good for your ADXL345.

Could you try the following commands

pigs spic 0 # close SPI channel
pigs spio 1 40000 3 # re-open
pigs spix 0 0xc0 0 0 # read device Id

It should return

3 229 229 0

If that doesn't work it's a final check that the connections are secure and correct and then the bin I'm afraid.
I'm getting "3 2 229 2"

User avatar
joan
Posts: 14747
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: ADXL345 only returning -2.048

Mon Jan 12, 2015 5:31 pm

It's almost as if it wants to work. The Id is 229, but the other values are incorrect.

I suppose you could play around with sending values but I personally wouldn't spend much more time on it. The SPI mode needs to be 3 (the final parameter in the spio command). It might be worth trying to read other registers to see if any of it makes sense. You'd need to look at the ADXL345 specs and the SPI timing diagrams for why the register address sometimes need altering according to whether it's a read/write or multi-byte transaction. man pigs for info on pigs and SPI.

rudy0912
Posts: 20
Joined: Wed Dec 24, 2014 9:29 pm

Re: ADXL345 only returning -2.048

Tue Jan 13, 2015 1:10 am

I don't think I have the patience to try with this one anymore. I ordered a different adxl345 considering it was only $5. Hopefully it works out of the box. Thanks again for the help.

Return to “Automation, sensing and robotics”