Comments: ADXL345 Hookup Guide


Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Member #1631299 / about 4 years ago / 2

    Thx for your detailed guide, but I can't get it to work, i followed exactly ur guide for SPI connection with Arduino UnoR3, the output i'm getting from adxl345 is -1,-1,-1 all the time, can you kindly help me with this? thanks

  • Member #1629103 / about 4 years ago / 1

    anyone know how to connect this to an esp32 huzzah feather?

  • Member #1503565 / about 5 years ago / 1

    I purchase ADXL345 instead of ADXL335 for Hand gesture control robot. Please send the ADXL345 code for moving robot forward, backward,left , right and stop.Also send me the circuit diagram for that.

  • Member #710235 / about 5 years ago / 1

    I noticed the values I'm reading off the "Example.ino" are not accurate. So I looked at the "Calibration.ino" patch while following the calibration section from the hookup guide. However they don't explain what the actual calibration consists of: Once I have the defined Offset and Gain values within "Calibration.ino" with the new calculations; now what?

    *Is "Calibration.ino" going to write these new values to the library? or,

    *Am I supposed to manually replace these values myself in the ".cpp" file? (if so where?) or,

    *Is "Example.ino" going to somehow read "Calibration.ino" and take the new values? or,

    *Am I supposed to place these new values within "Example.ino"? or,

    ... (Well, you see where I'm going?).

    Can someone please explain what I'm missing here?

  • dennisp / about 6 years ago / 1

    On-line I have noticed that there are a large number of people having issues with getting the ADXL-345 to generate interrupts using the example code contained in the Sparkfun library. If you uncomment all the portions of the code associated with interrupts and remove the ADXL_ISR function call from the loop routine you will not receive any interrupts. This can be very frustrating for users. The fix is very simple though. In setup, after calling attachinterrupt add a call to the ADXL_ISR function. The issue is that during setup one or more events have been triggered. Once triggered an interrupt will not be generated until the interrupt source has been read. Reading the interrupts source clears the trigger and allows an interrupt to be generated for the next event that is trigger. Calling the ADXL_ISR reads the interrupt source, clearing the trigger and allowing another interrupt to occur.

    • Member #710235 / about 5 years ago / 1

      I feel this may be related to an issue I have... I'm getting several "single tap" detections at once. I tried to implement your solution mentioned above, however I don't think I'm getting it right. Could you please elaborate a bit more about your solution? Thanks

  • Member #1270921 / about 6 years ago / 1

    I'm using an arduino MKR FOX 1200 and having trouble using the accelerometer. I was using using i2c on arduino uno. What pins should house on MAKE FOX 1200 to use the i2c?

  • Member #359801 / about 7 years ago / 1

    I found that the gains in the library code were off by a factor of 0.1, i.e. 10% of their correct values. I changed them to the following to get approx 1g in the Z axis. So these numbers should give genuine g values for the accelerations.

    gains[0] = 0.0376390; gains[1] = 0.0376009; gains[2] = 0.0349265;

    These gains are located in SparkFun_ADXL345_Arduino_Library/src/SparkFun_ADXL345.cpp for anyone who needs to change them.

    This might help @Member #556651


  • How can i change the SPI pins to pins other then 11, 12 and 13?

    • M-Short / about 7 years ago / 1

      The ATMega328 has hardware SPI on those pins so they can't be changed. In theory you can probably write a software SPI library, but since you can run numerous devices on one SPI bus these are rare. If you are using a different microcontroller you will have to check the datasheet to find out where the SPI bus is.

  • Member #980543 / about 7 years ago / 1

    Hi everything works fine! however i cant manage to measure free fall:( and what are these: adxl.setFreeFallThreshold(7);
    adxl.setFreeFallDuration(30); what does the digit represent? i dropped my accelerometer( ADXL345) from my table but the serial monitor did not display free fall Please help! i really need an answer i cant find anything on the web.

  • Member #556651 / about 7 years ago / 1

    I hooked up the ADXL345 with I2C and am getting data using the example code that is provided with this tutorial. I also ran the calibration script that is provided. But I don't see anything in the tutorial that says how to convert that calibrated data to actual g.

  • -------------------- Tech Support Tips/Troubleshooting/Common Issues --------------------

    Connecting Two ADXL345s

    The ADXL345 has two I2C address (0x53 and 0x1D) as stated in the datasheet [pg 10 - ]. Try looking at this tutorial for more information => ].

If you've found an issue with this tutorial content, please send us your feedback!