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.

LSM303 Class

Module: lsm303

This module defines the LSM303DLH 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.
lsm303.jpeg

Methods

LSM303

(
  • bus
  • addrMag
  • addrAcc
  • accScale
)
Number

Instantiates an LSM303 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

LSM303 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 ~LSM303 (); 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

() Int16Array

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

Returns:

Int16Array:

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

() Int16Array

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

Returns:

Int16Array:

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: