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.

LSM303DLH Class

Module: lsm303dlh

This module defines the LSM303DLHDLH 3-axis magnetometer/3-axis accelerometer. This module was tested with the Seeed Studio* Grove 6-Axis Accelerometer & Compass module used over I2C. The magnetometer and acceleromter are accessed at two seperate I2C addresses.
lsm303dlh.jpeg

Methods

LSM303DLH

(
  • bus
  • addrMag
  • addrAcc
  • accScale
)
Number

Instantiates an LSM303DLH object

Parameters:

  • bus Number

    I2C bus to use

  • addrMag Number

    I2C address of the Magnetometer (default 0x1E)

  • addrAcc Number

    I2C address of the Accelerometer (default 0x19)

  • accScale Number

    Accelerometer scale, can be 2, 4 or 8 (default 8)

Returns:

Number:

getHeading

() Number

LSM303DLH object destructor where is no more need for this here - I2c connection will be stopped automatically when m_i2c variable will go out of scope ~LSM303DLH (); Gets the current heading; headings <0 indicate an error has occurred

Returns:

Number:

float

getCoordinates

() Mraa::Result

Gets the coordinates in the XYZ order

Returns:

Mraa::Result:

getAcceleration

() Mraa::Result

Gets accelerometer values Should be called before other "get" functions for acceleration

Returns:

Mraa::Result:

getRawCoorData

() Int16_t *

Gets raw coordinate data; it is updated when getCoordinates() is called

Returns:

Int16_t *:

getCoorX

() Number

Gets the X component of the coordinates data

Returns:

Number:

getCoorY

() Number

Gets the Y component of the coordinates data

Returns:

Number:

getCoorZ

() Number

Gets the Z component of the coordinates data

Returns:

Number:

getRawAccelData

() Int16_t *

Gets raw accelerometer data; it is updated when getAcceleration() is called

Returns:

Int16_t *:

getAccelX

() Number

Gets the X component of the acceleration data

Returns:

Number:

getAccelY

() Number

Gets the Y component of the acceleration data

Returns:

Number:

getAccelZ

() Number

Gets the Z component of the acceleration data

Returns:

Number:

Properties

LSM303DLH_MAG_T

Enum LSM303DLH_SLAVE_T

LSM303DLH_ACC_T

Enum LSM303DLH_SLAVE_T