MechaQMC5883 (community library)

Summary

Name Value
Name MechaQMC5883
Version 0.0.1
Installs 619
Author keepworking
URL https://github.com/keepworking/Mecha_QMC5883L
Repository https://github.com/keepworking/Mecha_QMC5883L
Download .tar.gz

Alternative version of HMC5883L If the HMC5883L library isn't working, you may actually have a QMC5883L

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.

Mechasolution QMC5883L Library

한글 설명 바로가기

Arduino Code

There are a few simple rules for using that library. Please read the following summary and apply it to your project

Basic Elements

Required header files (#include ...) and Setup side code.

#include <Wire.h>
#include <MechaQMC5883.h>

void setup(){
Wire.begin();
}
Object Declaration

The object declaration method. It is used outside the setup statement, and a name such as qmc can be changed to any other name you want.

#include <Wire.h>
#include <MechaQMC5883.h>

MechaQMC5883 qmc;
initialization

QMC5883 Sensor's setting function.

The init function allows you to take advantage of the features of the QMC5883 sensor by default.

void setup(){
Wire.begin();
qmc.init();
}

If you want more detailed settings, you can use it as follows.

void setup(){
Wire.begin();
qmc.init();
qmc.setMode(Mode_Standby,ODR_200Hz,RNG_8G,OSR_512);
}

The values ​​used for setMode can take the following values:

Mode : Mode_Standby / Mode_Continuous

ODR : ODR_10Hz / ODR_50Hz / ODR_100Hz / ODR_200Hz
ouput data update rate

RNG : RNG_2G / RNG_8G
magneticfield measurement range

OSR : OSR_512 / OSR_256 / OSR_128 / OSR_64
over sampling rate
Read values

How to read the measured sensor value is as follows.

void loop(){
int x,y,z;

qmc.read(&x,&y,&z);
}

and we can get azimuth too.

void loop(){
int x,y,z;
int a;
//float a; //can get float value

qmc.read(&x,&y,&z,&a);
}

also can claculate azimuth you want

void loop(){
int x,y,z;
int a;

qmc.read(&x,&y,&z);
a = qmc.azimuth(&y,&x);
}

Basic example

It can be seen as a collection of the contents mentioned above.

#include <Wire.h>
#include <MechaQMC5883.h>

MechaQMC5883 qmc;

void setup() {
Wire.begin();
Serial.begin(9600);
qmc.init();
//qmc.setMode(Mode_Continuous,ODR_200Hz,RNG_2G,OSR_256);
}

void loop() {
int x,y,z;
qmc.read(&x,&y,&z);

Serial.print("x: ");
Serial.print(x);
Serial.print(" y: ");
Serial.print(y);
Serial.print(" z: ");
Serial.print(z);
Serial.println();
delay(100);
}

Browse Library Files