Detect movements, speed variation and gravity with the ADXL345 accelerometer
ADXL345 is a 3-axis digital accelerometer (Wikipedia) offering an I2C and SPI interface. Since AdaFruit added a 3.3V regulator and a logic level converter to it, this accelerometer has become compatible with 3.3v peripherals but also with Arduino or any other 5-volt microcontroller :-).
The sensor is capable of making measurements on the 3 axes X Y Z and can be used with a digital interface such as I2C or SPI. You can set the sensitivity level to +-2g, +-4g, +-8g or +-16g. The lower range (+-2g) offers better resolution for slow movements, the higher range (+-16g) is more suitable for tracking at high speed. The ADXL345 is the last born from the company "Analog Devices" known for its exceptional peripherals based on MEMs technology. The VCC power supply accepts up to 5V, a voltage which is regulated at 3.3V (voltage also available on another pin).
Completely assembled and tested, delivered with a 2.54mm pinHeader to use this breakout with a breadboard, prototyping plate, etc. Also has 2 mounting holes of 2.5mm.
Mounting on an Arduino
Using this component with your Arduino is relatively simple. The following connections must be made:
- The VIN pin of the ADXL345 breakout on a power source between 3 and 5 volts from your continuous.
- The GND pin to ground/GND of your Arduino.
- Connect the SCL pin to the I2C clock signal of your Arduino (pin A5 on an Arduino UNO).
- Connect the SDA pin to the I2C data signal of your Arduino (A4 pin on an Arduino UNO).
Library for Arduino
Then download the ADXL345 library for Arduino. Decompress it and rename the repertory inside "Adafruit_ADXL345". Verify that the repertory contains a .cpp and .h file. Finally, place the repertory with your Arduino libraries (in the "libraries" repertory) and restart your Arduino IDE. That's it ... ADXL345 samples must be available.
We also have a tutorial explaining how to instal Arduino libraries on our Wiki.
Assembled and tested, this breakout board comes with a 2.54mm pinHeader (not welded). This connector will allow easy insertion into a breadboard or a prototyping plate. The breakout board has 2 fixing holes of 2.5mm for easy assembly.
The ADXL345 component is the latest from a family of analog components recognized for the quality of their MEMS devices (electromechanical microsystems Wikipedia).
- Length: 25mm
- Width: 19mm
- Height: 3.14mm
- Weight: 1.27g
- ADXL345 datasheet.
- The VIN terminal accepts up to 5V and regulates the voltage to 3.3V (voltage also available on an output pin).
- The axes and their positive direction are indicated on the breakout board.
Since our planet also has a gravitational acceleration (of 1G), it is possible to detect the orientation of the breakout relative to the earth with this sensor. Such an accelerometer can, for example, be used to detect the orientation of a phone screen (see this article on Wikipedia)
This will seem more obvious after reading the accelerometer calibration method (see tutorial).