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.

AK8975 Class

Module: mpu9150

This is a 3-axis magnetometer, which can be used alone, or coupled with another device (such as the mcu9150 9-axis motion sensor).

Methods

AK8975

(
  • bus
  • address
)
Number

ak8975 constructor

Parameters:

  • bus Number

    i2c bus to use

  • address Number

    the address for this device

Returns:

Number:

init

() Boolean

set up initial values and start operation

Returns:

Boolean:

true if successful

setMode

(
  • mode
)
Boolean

put the chip into a specific mode

Parameters:

  • mode CNTL_MODES_T

    one of the CNTL_MODES_T values

Returns:

Boolean:

true if successful

isReady

() Boolean

check to see if the ST1_DRDY bit is set, indicating the device can accept commands

Returns:

Boolean:

true if device is ready, false otherwise

waitforDeviceReady

() Boolean

check to see if device is ready and sleep/retry if not. Returns once device indicates it's ready.

Returns:

Boolean:

true if device is ready, false if retries exhausted

update

(
  • selfTest
)
Boolean

take a measurement

Parameters:

  • selfTest Boolean

    true if we are running a self test, false (default) otherwise.

Returns:

Boolean:

true if successful, false otherwise

selfTest

() Boolean

do a self test sequence. When self test is executed, the device activates internal calibrated magnets, and measures them, updating the measurement registers. Once complete, the data can be read as usual ( getMagnetometer() ) and the returned values compared against the following limits to determine correctness:
-100 < X < +100; -100 < Y < +100; -1000 < Z < -300

Returns:

Boolean:

true if successful, false otherwise

getMagnetometer

(
  • x
  • y
  • z
)

return the compensated values for the x, y, and z axes. The unit of measurement is in micro-teslas (uT).

Parameters:

  • x Float *

    pointer to returned X axis value

  • y Float *

    pointer to returned Y axis value

  • z Float *

    pointer to returned Z axis value

Properties

REG_WIA

Enum AK8975_REG_T

REG_INFO

Enum AK8975_REG_T

REG_ST1

Enum AK8975_REG_T

REG_HXL

Enum AK8975_REG_T

REG_HXH

Enum AK8975_REG_T

REG_HYL

Enum AK8975_REG_T

REG_HYH

Enum AK8975_REG_T

REG_HZL

Enum AK8975_REG_T

REG_HZH

Enum AK8975_REG_T

REG_ST2

Enum AK8975_REG_T

REG_CNTL

Enum AK8975_REG_T

REG_ASTC

Enum AK8975_REG_T

REG_ASAX

Enum AK8975_REG_T

REG_ASAY

Enum AK8975_REG_T

REG_ASAZ

Enum AK8975_REG_T

ST1_DRDY

Enum ST1_BITS_T

ST2_DERR

Enum ST2_BITS_T

ST2_HOFL

Enum ST2_BITS_T

CNTL_PWRDWN

Enum CNTL_MODES_T

CNTL_MEASURE

Enum CNTL_MODES_T

CNTL_SELFTEST

Enum CNTL_MODES_T

CNTL_FUSE_ACCESS

Enum CNTL_MODES_T

ASTC_SELF

Enum ASTC_BITS_T