Giter Club home page Giter Club logo

qmc5883's Introduction

QMC5883L/QMC5883P: Python class for the QMC5883L/QMC5883P Three-Axis Digital Compass IC

This is a very short and simple class. It uses the I2C bus for the interface.

Initial code by Sebastian Folz, M.Sc. at http://nobytes.blogspot.com/2018/03/qmc5883-magnetic-field-sensor.html

Types of QMC5883

There are two types of QMC5883 available on the market.

The chips have totally different PCB package. On the market available both variant, but if takes Arduino modules, mostly it will be QMC5883L (@see GY-273 modules) Register map of these chips are totally different.

Constructor

The both drivers uses the same interface (ie parent class) - mag_base. Could be selected, any of available driver QMC5883L or QMC5883P. Next examples use QMC5883P, but due to the same interface class could be replaced with QMC5883L

QMC5883 = QMC5883P(i2c [, temp_offset])

  • i2c is an I2C object which has to be created by the caller.
  • temp_offset specifies the offset to the temperature, as returned by the method (only in QMC5883L) read_scaled. The unit is °C, the default is 50 °C.

Methods

(x, y, z, t) = QMC5883.read_raw()

Return the raw reading for the x,y, and z axis as well as the raw temperature reading. The values are not scaled according to the sensitivity or possible offsets.

(x, y, z, t) = QMC5883.read_scaled()

Return the scaled reading for the x,y, and z axis as well as the temperature reading. The x ,y and z readings are scaled to Gauss, the temperature to °C with compensated offset On QMC5883P temperature value is always zero.

QMC5883.set_sampling rate(sampling_rate)

Sets the sampling rate of the sensor. Accepted values are:

Value Sampling rate
0 10 Hz
1 50 Hz
2 100 Hz
3 200 Hz

QMC5883.set_oversampling(oversampling)

Sets the oversampling factor of the sensor. Accepted values are:

Value Oversampling
0 512
1 256
2 128
3 64

QMC5883.set_range(range)

Sets the magnetic field range of the sensor. Accepted values are:

Value Range
0 2 Gauss
1 8 Gauss
1 12 Gauss (QMC5883P only)
1 30 Gauss (QMC5883P only)

QMC5883.reset()

Resets the device using the previously configured settings. This call is not required when settings are changed.

# Example for Pycom device.
# Connections:
# xxPy | QMC5883
# -----|-------
# P9   |  SDA
# P10  |  SCL
#
from machine import I2C
from QMC5883 import QMC5883P

i2c = I2C(0, I2C.MASTER)
qmc5883 = QMC5883P(i2c)

x, y, z, _ = qmc5883.read_scaled()

qmc5883's People

Contributors

robert-hh avatar

Stargazers

Jiankun Lü avatar Gerad Munsch avatar  avatar  avatar Danil intl avatar Artur Chukhrai avatar  avatar  avatar  avatar  avatar Michał Banaś avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

qmc5883's Issues

function not iterable

In micropython, if I qmc.read_scaled I get "function not iterable" . If I put it in a loop I get <function read_scaled at 0x2001a6b0> over and over but no x,y,z, _ I'm using a QMC5883L. What do I need to do to get mag data?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.