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.

MAG3110 Class

Module: mag3110

Description in web-link above: The MAG3110 is a small, low-power digital 3D magnetic sensor with a wide dynamic range to allow operation in PCBs with high extraneous magnetic fields. It measures the components of the local magnetic field, the sum of the geomagnetic field and the magnetic field created by components on the circuit board. It can be used in conjunction with a 3-axis accelerometer so that orientation-independent accurate compass heading information may be achieved It is capable of measuring local magnetic fields up to 10 Gauss with output data rates up to 80 Hz.

Methods

MAG3110

(
  • bus
  • dros
  • devAddr
)
Number

Instantiates an MAG3110 object

Parameters:

  • bus Number

    Number of the used bus

  • dros Number

    Data rate and over sampling selection

  • devAddr Number

    Address of the used I2C device

Returns:

Number:

checkID

() Number

Check device_id of sensor

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:

>0 if x-, y- and z-axis new sample is ready 0 if measurement is in progress

sampleData

() Number

Read magnetometer's data and saves them to variables
Info: To get the actual values for the magnetic field someone has to divide the returned values from the magnetometer by 10

Returns:

Number:

0 on success -1 on error

getX

(
  • bSampleData
)
Number

Get x-axis magnetic field strength

Parameters:

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

The x-axis magnetic field strength on success -999 on error

getY

(
  • bSampleData
)
Number

Get y-axis magnetic field strength

Parameters:

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

The y-axis magnetic field strength on success -999 on error

getZ

(
  • bSampleData
)
Number

Get z-axis magnetic field strength

Parameters:

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

The z-axis magnetic field strength on success -999 on error

getStatus

() Number

Get value of status register

Returns:

Number:

Value of status register

getDieTemperature

() Number

Get die temperature

Returns:

Number:

Die temperature

getData

(
  • data
  • bSampleData
)
Number

Get sensor values

Parameters:

  • data Mag3110_data_t

    Sensor values

  • bSampleData Number

    Flag to read sensor

Returns:

Number:

0 on success -1 on error