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.

MMA8X5X Class

Module: mma8x5x

Description in web-link above: The NXP MMA8X5X are low-power, three-axis capacitive micromachined accelerometer with 10/12/14 bits of resolution. These accelerometer are packed with embedded functions with flexible user-programmable options configurable to two interrupt pins. The MMA8X5X have user-selectable full scales of +-2g/+-4g/+-8g.

Methods

MMA8X5X

(
  • bus
  • params
  • devAddr
)
Number

Instantiates an MMA8X5X object

Parameters:

  • bus Number

    Number of the used bus params Params of device

  • params Mma8x5x_params_t

    undefined

  • devAddr Number

    Address of the used I2C device

Returns:

Number:

setDeviceName

(
  • type
)
Number

Set device name and type matching given type or read out devive_id to set name and type of device

Parameters:

  • type Number

    Type of device if set or 0 if needed to find out by it

Returns:

Number:

0 on success -1 on error

setDeviceParams

(
  • params
)
Number

Set device params to given data or set default params and read out devive_id to set type of device

Parameters:

  • params Mma8x5x_params_t

    Params of device if set by user NULL if it is not set by user

Returns:

Number:

0 on success -1 on error

setUserOffset

(
  • x
  • y
  • z
)
Number

Set user offset correction Offset correction register will be erased after accelerometer reset

Parameters:

  • x Number

    Offset correction value for x-axis

  • y Number

    Offset correction value for y-axis

  • z Number

    Offset correction value for z-axis

Returns:

Number:

0 on success -1 on error

setActive

() Number

Set active mode, this enables periodic measurements

Returns:

Number:

0 on success -1 on error

setStandby

() Number

Set standby mode, this disables periodic measurements

Returns:

Number:

0 on success -1 on error

isReady

() Number

Check for new set of measurement data.

Returns:

Number:

MMA8X5X_DATA_READY if new sample is ready MMA8X5X_NODATA if nothing is available

sampleData

() Number

Read & calculate accelerometer data in mg & saves them to variables

Returns:

Number:

0 on success -1 on error

getX

(
  • bSampleData
)
Number

Get x-axis acceleration

Parameters:

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

The x-axis acceleration on success -999 on error

getY

(
  • bSampleData
)
Number

Get y-axis acceleration

Parameters:

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

The y-axis acceleration on success -999 on error

getZ

(
  • bSampleData
)
Number

Get z-axis acceleration

Parameters:

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

The z-axis acceleration on success -999 on error

getData

(
  • data
  • bSampleData
)
Number

Get sensor values

Parameters:

  • data Mma8x5x_data_t

    Sensor values

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

0 on success -1 on error