.. module:: MAG3110 ************** MAG3110 Module ************** .. _datasheet: https://www.nxp.com/docs/en/data-sheet/MAG3110.pdf This module contains the Zerynth driver for MAG3110 digital sensor. It features a standard I2C serial interface output and smart embedded functions. The MAG3110 is capable of measuring magnetic fields with an output data rate (ODR) up to 80 Hz; these output data rates correspond to sample intervals from 12.5 ms to several seconds. =============== MAG3110 class =============== .. class:: MAG3110(drvname, addr=0x0E, clk=400000) Creates an intance of the MAG3110 class. :param drvname: I2C Bus used '( I2C0, ... )' :param addr: Slave address, default 0x0E :param clk: Clock speed, default 400kHz Magnetometer values can be easily obtained from the sensor: :: from nxp.mag3110 import mag3110 ... mag = mag3110.MAG3110(I2C0) mag_values = mag.get_values() .. method:: set_measurement(mode = 0, osr = 32, odr = 1) **Parameters**: **mode**: is the measurement mode to set (default value = 0). Values accepted: 0 or 1. ======== ==================== mode Measurement mode ======== ==================== 0 Continuous measurements 1 Triggered measurements ======== ==================== **osr**: is oversampling rate to set (default value = 32). Values accepted: 16, 32, 64 or 128. **odr**: is output data rate to set (default value = 1). Values range accepted: 0-7. Set the measurement mode, the oversampling rate and output data rate. .. method:: set_mode(mode) **Parameters**: **mode**: is the operation mode to set. Values accepted: 0 or 1. ======== ==================== mode Operating mode ======== ==================== 0 Standby mode 1 Active mode ======== ==================== Set the operating mode. .. method:: set_offset_on() Enable the correction of data values according to offset register values. .. method:: set_offset_off() Disable the correction of data values according to offset register values. .. method:: set_offset(axis, offset) :param axis: is the axis to set. Values accepted: "X", "Y" or "Z". :param offset: is the offset to set to the axis indicated. Values range accepted: [-10000, 10000]. Set offset to the axis specified. .. method:: is_data_ready() Return 1 if new data ready, otherwise 0. .. method:: trigger_measurement() Set measurement in trigger mode. .. method:: get_values() Return the X, Y and Z values of the magnetometer in a dictionary. .. method:: set_offset_temp(value = 10) :param value: is the value of temperature offset to set. Default value is 10. Set the offset value of temperature. .. method:: get_temp() Return the temperature in degrees Celsius.