MicroPython MMC5983 Library

mmc5983

MicroPython Library for the Memsic MMC5983 Magnetometer

  • Author(s): Jose D. Montoya

mmc5983

MicroPython Library for the Memsic MMC5983 Magnetometer

  • Author(s): Jose D. Montoya

class micropython_mmc5983.mmc5983.MMC5983(i2c, address: int = 0x30)[source]

Driver for the MMC5983 Sensor connected over I2C.

Parameters:
i2c : I2C

The I2C bus the MMC5983 is connected to.

address : int

The I2C device address. Defaults to 0x30

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the MMC5983 class. First you will need to import the libraries to use the sensor

from machine import Pin, I2C
from micropython_mmc5983 import mmc5983

Once this is done you can define your machine.I2C object and define your sensor object

i2c = I2C(1, sda=Pin(2), scl=Pin(3))
mmc5983 = mmc5983.MMC5983(i2c)

Now you have access to the attributes

magx, magy, magz = mmc5983.magnetic
property bandwidth : str

Sensor bandwidth. These bandwidth selection bits adjust the length of the decimation filter. They control the duration of each measurement

Mode

Value

mmc5983.BW_100HZ

0b00

mmc5983.BW_200HZ

0b01

mmc5983.BW_400HZ

0b10

mmc5983.BW_800HZ

0b11

property continuous_mode_frequency : str

Sensor continuous_mode_frequency determine how often the chip will take measurements in Continuous Measurement Mode. The frequency is based on the assumption that bandwidth is BW_100HZ

Mode

Value

mmc5983.CM_OFF

0b000

mmc5983.CM_1HZ

0b001

mmc5983.CM_10HZ

0b010

mmc5983.CM_20HZ

0b011

mmc5983.CM_50HZ

0b100

mmc5983.CM_100HZ

0b101

mmc5983.CM_200HZ

0b110

mmc5983.CM_1000HZ

0b111

property magnetic : tuple[float, float, float]

Returns magnetic data in uT

property operation_mode : str

Sensor operation_mode. In order to enter the continuous mode, continuous_mode_frequency cannot be CM_OFF

Mode

Value

mmc5983.ONE_SHOT

0b0

mmc5983.CONTINUOUS

0b1

property temperature : float

Returns Temperature in Celsius