upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the MAG3110 Three-Axis Digital Magnetometer. More...

Detailed Description

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.

std::cout << "Initializing test-application..." << std::endl;
// Instantiate an MAG3110 instance on bus 1
upm::MAG3110 mySensor(1);
// activate periodic measurements
mySensor.setActive();
// update and print available values every second
while (run) {
mySensor.getData(&data, true);
std::cout << "x: " << data.x << std::endl
<< "y: " << data.y << std::endl
<< "z: " << data.z << std::endl
<< "Status: " << data.status << std::endl
<< "Die temperature: " << data.dtemp << std::endl;
std::cout << std::endl;
upm_delay(1);
}
std::cout << "Exiting test-application..." << std::endl;

Public Member Functions

 MAG3110 (int bus, uint8_t dros=MAG3110_DROS_DEFAULT, int devAddr=MAG3110_I2C_ADDRESS)
 
int checkID (void)
 
int setUserOffset (int16_t x, int16_t y, int16_t z)
 
int setActive (void)
 
int setStandby (void)
 
int isReady (void)
 
int sampleData (void)
 
int16_t getX (int bSampleData=0)
 
int16_t getY (int bSampleData=0)
 
int16_t getZ (int bSampleData=0)
 
uint8_t getStatus (void)
 
int8_t getDieTemperature (void)
 
int getData (mag3110_data_t *data, int bSampleData=0)
 

Constructor & Destructor Documentation

MAG3110 ( int  bus,
uint8_t  dros = MAG3110_DROS_DEFAULT,
int  devAddr = MAG3110_I2C_ADDRESS 
)

Instantiates an MAG3110 object

Parameters
busNumber of the used bus
drosData rate and over sampling selection
devAddrAddress of the used I2C device

Here is the call graph for this function:

Member Function Documentation

int checkID ( void  )

Check device_id of sensor

Returns
0 on success -1 on error

Here is the caller graph for this function:

int setUserOffset ( int16_t  x,
int16_t  y,
int16_t  z 
)

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

Parameters
xOffset correction value for x-axis
yOffset correction value for y-axis
zOffset correction value for z-axis
Returns
0 on success -1 on error
int setActive ( void  )

Set active mode, this enables periodic measurements

Returns
0 on success -1 on error
int setStandby ( void  )

Set standby mode, this disables periodic measurements

Returns
0 on success -1 on error
int isReady ( void  )

Check for new set of measurement data.

Returns
>0 if x-, y- and z-axis new sample is ready 0 if measurement is in progress
int sampleData ( void  )

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
0 on success -1 on error

Here is the caller graph for this function:

int16_t getX ( int  bSampleData = 0)

Get x-axis magnetic field strength

Parameters
bSampleDataFlag to read sensor
Returns
The x-axis magnetic field strength on success -999 on error

Here is the call graph for this function:

int16_t getY ( int  bSampleData = 0)

Get y-axis magnetic field strength

Parameters
bSampleDataFlag to read sensor
Returns
The y-axis magnetic field strength on success -999 on error

Here is the call graph for this function:

int16_t getZ ( int  bSampleData = 0)

Get z-axis magnetic field strength

Parameters
bSampleDataFlag to read sensor
Returns
The z-axis magnetic field strength on success -999 on error

Here is the call graph for this function:

uint8_t getStatus ( void  )

Get value of status register

Returns
Value of status register
int8_t getDieTemperature ( void  )

Get die temperature

Returns
Die temperature
int getData ( mag3110_data_t data,
int  bSampleData = 0 
)

Get sensor values

Parameters
dataSensor values
bSampleDataFlag to read sensor
Returns
0 on success -1 on error

Here is the call graph for this function:


The documentation for this class was generated from the following files: