sts1_sensors.edu.BMM150 ======================= .. py:module:: sts1_sensors.edu.BMM150 Module Contents --------------- .. py:class:: PowerMode Initialize self. See help(type(self)) for accurate signature. .. py:class:: PresetMode Initialize self. See help(type(self)) for accurate signature. .. py:class:: PowerControl Initialize self. See help(type(self)) for accurate signature. .. py:class:: bmm150_mag_data .. py:class:: bmm150_raw_mag_data .. py:class:: bmm150_trim_registers .. py:class:: bmm150_settings .. py:class:: BMM150(preset_mode=1, address=None, bus=None) Geomagnetic sensor. Builds on top of the library `bmm150 `_. by Ulysse Moreau. :param int preset_mode: Integer, either 1 (Low Power), 2 (Regular), 3 (High Accuracy) or 4 (Enhanced). Defaults to 1. :param hexadecimal address: Physical address of the sensor on the board (see `i2cdetect` command). Allowed values: `[0x10, 0x11, 0x12, 0x13]`. If None, the environment variable `STS1_SENSOR_ADDRESS_BMM150` will be used. If environment variable is not found, 0x10 will be used. :param SMBus bus: A SMBus object. If None, this class will generate its own, defaults to None. Example: .. code-block:: python mag = BMM150() x, y, z = mag.get_magnetic_data() print(f"{x=:.2f} µT, {y=:.2f} µT, {z=:.2f} µT") print(f"Heading: {mag.get_heading():.2f}°") .. py:property:: address .. py:method:: set_bits_pos0(reg_data, bitname_mask, data) .. py:method:: get_bits(reg_data, bitname_mask, bitname_pos) .. py:method:: set_bits(reg_data, bitname_mask, bitname_pos, data) .. py:method:: set_op_mode(pwr_mode) Sets power mode Args: pwr_mode (PowerMode): Desired power mode .. py:method:: set_presetmode(preset_mode) Sets preset mode Args: preset_mode (PresetMode): Desired preset mode .. py:method:: suspend_to_sleep_mode() .. py:method:: soft_reset() Soft resets the module. .. py:method:: read_trim_registers() Reads the trim registers for calibration. .. py:method:: read_raw_mag_data() Reads registers containing X, Y, Z and R data from the device. Returns: tuple[int, int, int, int]: A tuple containing raw (X, Y, Z, R) data. .. py:method:: read_mag_data() Reads and compensate the magnetic values for X, Y and Z. Returns: tuple[int, int, int]: A tuple containing raw (X, Y, Z) compensated data. .. py:method:: get_raw_magnetic_data() Get raw magnetic data in µT. .. py:method:: get_magnetic_data() Get magnetic data in µT. .. py:method:: get_heading() Get heading direction in degrees. Uses only x and y for calculation (z is ignored).