I have the device hooked up to the arduino correctly and the code complies and runs fine, except i get constant readings when i monitor the serial output . 36.02 -45.44 over and over again regardless of orientation. any help would be greatly appreciated, could it simply be a hardware fault?
What version of ADXL345 library are you using? The one that I have is from I2C devlib. I am unfamiliar with the lib you are using. The first thing that I would do is make sure that I am communicating with the sensor. Print the raw results right from the acc.read.
You should see around 0 on X and Y and 230ish on Z. If not then you will need to make sure the I2C interface is working.
Well it is handy that you have the same module! When you say raw do you mean just the voltages? before being put through the equations? in that case no, the results should be in g's??? for each direction, i just followed the adxl345 tutorial on the page i linked. My arduino is tied up in anothe project at least until tonight, and my spare is with a friend so will post some raw data asap. Until then; what do you use this module for? my grand scheme was to write some flight software for a quadcopter, before you say anything, i know, my ability is probably lacking in so many areas for me to be able to achieve this, but is it possible? is this module good enough? is the arduino uno powerful and fast enough? Again, thank you so much for your help.
What I mean by raw data is the output of the accel before any scaling. The data will be in AD cunts (0-1023). Just print the values of x, y, z. I use mine to learn about sensing orientation. I am working on a self balancing robot and self leveling table using the GY-80 and PID to control motors. I use the gyro as well as the accel and complementary filters to get orientation. I have seen posts on this forum about using the Uno for quads so there is info available. And the ADXL345 seems to be a common sensor for quads so I am sure it is possible. No one was born with the knowledge to build a quadcopter. Carve the project into several parts and learn each part then someday you will have what you need to put it all together.
I was using a different library than you. I found the library that you referred to and installed it. Ran your latest code and it compiled without errors and the ADXL345 is sending data. I did insert a 1000 mS delay in loop() to slow down the printing and labels for the data. Maybe re-install the library.
I checked the libraries folder in my arduino install directory and it was empty, does the IDE not install libraries correctly (it only appears in documents/arduino/libraries. I manually unzipped the adxl345 library folder into the install directory library folder, still with the same error. This is frustrating as i have had this library working before, what prompted me to start this topic. I'm very grateful for your help and i apologise that this thread is going off topic because i cant get some simple code to run. GRRR!
The version of the library that I used had #include arduino.h. so is for the later Arduino IDE. Follow the link that I included and download the version on that page to make sure you have the same one. Make sure that the ADXL345 folder goes into the library folder of your sketch directory (not the IDE install directory).
To make sure your library is the latest, look in the ADXL345.h file. The first #include should be "Arduino.h". Also make sure that the latest ADXL345 lib is the only one on your system. Make sure there is not one in the libraries folder of the IDE installation directory.
Here is what my file structure looks like. The I2CDevlib folders look pretty empty. Is this where the problem lies? Are these libraries just broken when installed via PlatformIO? They used to work. I did update them using the library manager. Do I need to specify an old version?
The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to 16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface. Libraries for both communication protocols are provided below.
This library enables users to communicate with the ADXL345 accelerometer through the I2C bus on the mbed. The API names are similar and work nearly the same way as those made in the SPI libraries for the ADXL345.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.
IMUs (inertial measurement unit) are useful to many projects such as self-balancing robots and quadcopters. As part of the quadcopter project I will be sharing with you how I connect and use a 10DOF GY80 Arduino sensor, a popular Chinese made IMU. This sensor uses I2C connection with the Arduino. There are four sensors on this board: a gyroscope (L3G4200D), an accelerometer (ADXL345), a Magnetometer (HMC5883L) and a Barometer & Temperature sensor (BMP085). Like I said, this IMU is so popular, there are tons of documents and articles on the internet about it.
In this post I will be mainly playing around with the accelerometer, and will cover other sensors on the GY80 later in another post. I will be using the Arduino Uno as an example, it would be similar with other boards.
There are many people have been writing Arduino codes for this IMU, and there are even libraries available for these sensors. You can find the accelerometer ADXL345 library here. This is an example code how to use the ADXL345 library. It takes sensor measurements, calculate a human friendly value (in this case roll and pitch values) and output them to serial port.
Brother , i want to know that if three sensors are present. then how will be they give output? my mean to say that are every sensor having its own terminal? through which we can get different inputs from IMU and give to different bits of controller.
please help me.
I am just learning, but think this code is asking for the ADXL345.h library which you will have to google for. It will also have a ADXL345.cpp file that is needed. Make sure that these two files are in one ADXL345 folder thats in your library folder. If you get the same error again while compiling then your sketch still cant find the ADXL345.h file. Be sure to restart your arduino programmer so the programmer knows you added something new to your library. When you get this type of error it usually means are messing something. Dont give up. When you arent making mistakes you arent learning anything new.
This hookup guide will explore the various functions of the ADXL345 utilizing the SparkFun ADXL345 Arduino Library and example code. First, let's get some background on this small yet powerful accelerometer.
If you're not sure if this product is right for your needs, check out the Accelerometer, Gyro and IMU Buying Guide. Some additional resources that might be helpful in this process, especially if you are just started out, you can find here:
Whoa! What are those last three?! Yes, the ADXL345 has special sensing abilities! The single and double tap sensing detects when a single, or two simultaneous, acceleration events occur. Activity and inactivity sensing detect the presence or lack of motion. Free-fall sensing compares the acceleration on all axes with the threshold value to know if the device is falling. All thresholds levels that trigger the activity, free-fall, and single tap/double tap events are user-set levels. These functions can also be mapped to one of two interrupt output pins. An integrated, patent pending 32-level first in, first out (FIFO) buffer can be used to store data to minimize host processor intervention.
The ADXL345 is well suited to measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0. Furthermore, low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at extremely low power dissipation.
Note: A potential problem when hooking up the ADXL345 breakout to an Arduino (or compatible board) is, if you are using a breadboard with loosely connected jumper wires, you risk getting bad data. Make sure your connections are solid, and you should be fine.
Note: When using 3-wire SPI, it is recommended that the SDO pin be pulled up to VDD I/O or pulled down to GND via a 10 kΩ resistor. Please refer to page 15 of the ADXL345 Datasheet for additional information.
Note: If other devices are connected to the same I2C bus, the nominal operating voltage level of those other devices cannot exceed VDD I/O by more than 0.3 V. External pull-up resistors are necessary for proper I2C operation. Used in this connection diagram are two 4.7 kΩ resistors. Please refer to page 18 of the ADXL345 Datasheet for additional information.
The most exciting part of the Hookup Guide is the SparkFun ADXL345 library we've put together for you. Now, you not only have the ability to customize your sensing functions but also switch easily back and forth between I2C and SPI communication.
The comments can help guide you as to what each function does along with recommended ranges to stay within where applicable. More detailed information of the sensing functions and interrupts can be found on the ADXL345 Datasheet.
Let's see it in action! Go to Tools on your Arduino IDE, set your board and port, and upload the SparkFun_ADXL345_Example.ino sketch to your Arduino or compatible board. If you need further assistance in uploading your sketch this might be helpful: Uploading a Sketch.
c80f0f1006