upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the ADXL345 3-Axis Digital Accelerometer. More...

Detailed Description

ADXL345 is a 3-axis digital accelerometer. (http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf) The sensor has configurable resolutions to measure ±2g, ±4g, ±8g, or ±16g. Note: The Grove* version of the sensor is incompatible with and not detected on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V (3V works fine).

adxl345.jpeg
short[] val;
float[] accel;
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino
// breakout
while (true) {
sensor.update();
val = sensor.getRawValues();
accel = sensor.getAcceleration();
System.out.println("Current scale: " + sensor.getScale());
System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2]);
System.out.println("Acceleration: X: " + accel[0] + "g Y: " + accel[1] + "g Z: "
+ accel[2] + "g");
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 Adxl345 (int bus)
 
float[] getAcceleration ()
 
short[] getRawValues ()
 
short getScale ()
 
int update ()
 

Constructor & Destructor Documentation

Adxl345 ( int  bus)

Creates an ADXL345 object

Parameters
busNumber of the used I2C bus

Member Function Documentation

float [] getAcceleration ( )

there is no need for a ADXL345 object destructor ~Adxl345(); Returns a pointer to a float[3] that contains acceleration (g) forces

Returns
float* to a float[3]
short [] getRawValues ( )

Returns a pointer to an int[3] that contains the raw register values for X, Y, and Z

Returns
int* to an int[3]
short getScale ( )

Returns the scale the accelerometer is currently set up to: 2, 4, 8, or 16

Returns
uint with the current scale value
int update ( )

Updates the acceleration values from the I2C bus

Returns
0 if successful

The documentation for this class was generated from the following file: