Skip to main content

A pure python API for the bmm150 magnetic sensor

Project description

BMM150

A pure python API for the bmm150 magnetic sensor.

Note : Most code logic comes from one of the following repos : Seed-Studio/Grove_3_Axis_Compass_V2.0_BMM150 or BoschSensortec/BMM150-Sensor-API . This is mostly a transpilation and a python packaging of this code.

Installation

The easiest way to install this library is using pip:

pip install bmm150

Documentation

The documentation is built using sphinx and the readthedocs theme. You can find it on the readthedocs official website.

Usage

The following code initializes the sensor, and prints the magnetic field values for x, y and z. Then, using the atan2 function from the math standard library, it retrieves the heading of the sensor.

import bmm150
import math

device = bmm150.BMM150()  # Bus number will default to 1

x, y, z = device.read_mag_data()

heading_rads = math.atan2(x, y)

heading_degrees = math.degrees(heading_rads)

print(f"X : {x:.2f}µT")
print(f"Y : {y:.2f}µT")
print(f"Z : {z:.2f}µT")

print(f"Heading: {heading_degs:.2f}°")

Development

This library uses poetry as a development tool.

You can start development by running :

poetry install

Testing

You can test this library using :

poetry run pytest

Tox

You can test multiple python versions using tox :

poetry run tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bmm150-0.2.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file bmm150-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: bmm150-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for bmm150-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9c2c531af60a9ab5a41c3ad892ae72100431c3554ff0ac395586ddad8935520b
MD5 b052ea965bbd3694e33f38591b89096b
BLAKE2b-256 9ca1c7938c1bdf75a50ba938fc52583b5be71e8819caca65151fcecd1f59881f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page