UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

ADXL335 Class

Module: adxl335

UPM module for the ADXL335 3-axis analog accelerometer. This was tested on a Grove 3-axis Analog Accelerometer. It uses 3 analog pins, one for each axis: X, Y, and Z.
adxl335.jpg

Methods

ADXL335

(
  • pinX
  • pinY
  • pinZ
  • aref
)
Number

ADXL335 constructor

Parameters:

  • pinX Number

    Analog pin to use for X-axis

  • pinY Number

    Analog pin to use for Y-axis

  • pinZ Number

    Analog pin to use for Z-axis

  • aref Number

    Analog reference voltage; default is 5.0v

Returns:

Number:

setZeroX

(
  • zeroX
)

Sets the "zero" value of the X-axis, determined through calibration

Parameters:

  • zeroX Number

    "Zero" value of the X-axis

setZeroY

(
  • zeroY
)

Sets the "zero" value of the Y-axis, determined through calibration

Parameters:

  • zeroY Number

    "Zero" value of the Y-axis

setZeroZ

(
  • zeroZ
)

Sets the "zero" value of the Z-axis, determined through calibration

Parameters:

  • zeroZ Number

    "Zero" value of the Z-axis

values

(
  • xVal
  • yVal
  • zVal
)

Gets the analog values for the 3 axes

Parameters:

  • xVal Int *

    Pointer to the returned X-axis value

  • yVal Int *

    Pointer to the returned Y-axis value

  • zVal Int *

    Pointer to the returned Z-axis value

values

() Std::vector int

Gets the analog values for the 3 axes

Returns:

Std::vector int :

std::vector of x, y, z analog acceleration values

acceleration

(
  • xAccel
  • yAccel
  • zAccel
)

Gets the acceleration along all 3 axes

Parameters:

  • xAccel Float *

    Pointer to returned X-axis value

  • yAccel Float *

    Pointer to returned Y-axis value

  • zAccel Float *

    Pointer to returned Z-axis value

acceleration

() Std::vector float

Gets the acceleration along all 3 axes

Returns:

Std::vector float :

std::vector of x, y, z acceleration values

calibrate

()

While the sensor is still, measures the X-axis, Y-axis, and Z-axis values and uses those values as the zero values.