upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
Adxl345 Class Reference

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).

int16_t *raw;
float *acc;
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino breakout
upm::Adxl345* accel = new upm::Adxl345(0);
accel->update(); // Update the data
raw = accel->getRawValues(); // Read raw sensor data
acc = accel->getAcceleration(); // Read acceleration (g)
fprintf(stdout, "Current scale: 0x%2xg\n", accel->getScale());
fprintf(stdout, "Raw: %6d %6d %6d\n", raw[0], raw[1], raw[2]);
fprintf(stdout, "AccX: %5.2f g\n", acc[0]);
fprintf(stdout, "AccY: %5.2f g\n", acc[1]);
fprintf(stdout, "AccZ: %5.2f g\n", acc[2]);

Public Member Functions

 Adxl345 (int bus)
float * getAcceleration ()
int16_t * getRawValues ()
uint8_t getScale ()
mraa::Result update ()

Constructor & Destructor Documentation

Adxl345 ( int  bus)

Creates an ADXL345 object

busNumber of the used I2C bus

Here is the call graph for this function:

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

float* to a float[3]
int16_t * getRawValues ( )

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

int* to an int[3]
uint8_t getScale ( )

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

uint with the current scale value
mraa::Result update ( void  )

Updates the acceleration values from the I2C bus

0 if successful

Here is the caller graph for this function:

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