![]() |
ADXL345 Accelerometer and Arduino
I am finally getting around to playing with the ADXL345 Accelerometer that is included with the FRC Kit of parts. Right now I am trying to make the Accelerometer work with an Arduino Uno. However, after several attempts, I am not getting anywhere. I am reading nothing but -1 values and can cannot verify if it is wiring, commands or codes.
I would like to ask if anyone has done work on the ADXL345 Accelerometer and Arduino using the SPI or I2C bus. Looking for wiring diagrams and perhaps example code. Please note, I have looked at spec sheets on the ADXL345 but it doesn't quite match up to the one we get in the kit of parts. No arduino examples I found have worked. Anything to help. Will |
Re: ADXL345 Accelerometer and Arduino
You might want to take a look at this: https://github.com/adafruit/Adafruit_ADXL345
We used this library to test our accelerometers with an Arduino and it worked perfectly. |
Re: ADXL345 Accelerometer and Arduino
1 Attachment(s)
Here is the code we used to test our ADXL345 (and our analog gyro), if you want an example. This requires the Adafruit libraries (Adafruit_Sensor and Adafruit_ADXL345).
|
Re: ADXL345 Accelerometer and Arduino
Posting your code might help as well. It might be something very simple.
And a picture of your wiring. Is this the KoP board you are referencing? |
Re: ADXL345 Accelerometer and Arduino
If you are using SPI, the kit board inverts the chip select line of the adxl345 so you would need to make it active high on the arduino to make it work. I2C should just work.
|
Re: ADXL345 Accelerometer and Arduino
1 Attachment(s)
Attached is the code I found that should work but doesn't. Yes, we are using the Andy Mark am-2067 sensor module. Thank you for verifying.
In the example, it holds the Chip Select (CS) pin high and holds it low when actually transferring data (Both directions). When I read files, all I get when converted to an int is -1, -1, -1 for all 3 variables. So I am wondering if perhaps I have it cabled incorrectly, if I'm not actually sending the correct hex codes (or the code isn't being converted correctly), it I'm not sending MSB First or what. Just finding this difficult that I cannot get it to respond to anything I send. Will |
Re: ADXL345 Accelerometer and Arduino
The chip select needs to be high during the transfer. That's what active means.
|
Re: ADXL345 Accelerometer and Arduino
Awesome! I'll invert my Chip Select Pin next try I get which will be this evening.
Will |
Re: ADXL345 Accelerometer and Arduino
I inverted my chip select so that it as pulled high only during transmission (which is opposite to what stated in the manual for this accelerometer) and now I am able to read data using the SPI bus. Thank you so much for the suggestion!
Will Edds |
| All times are GMT -5. The time now is 02:45. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi