QMC5883LCompass icon indicating copy to clipboard operation
QMC5883LCompass copied to clipboard

What units getX() are the values ​​in?

Open brightproject opened this issue 4 months ago • 0 comments

The pseudocode is like this

QMC5883LCompass compass;

int x = compass.getX();
int y = compass.getY();
int z = compass.getZ();

int azim;

char buffer[100]; // Increase the buffer size to accommodate the entire string
snprintf(buffer, sizeof(buffer), "X: %.2d, Y: %.2d, Z: %.2d", x, y, z);
Serial.println(buffer);

snprintf(buffer, sizeof(buffer), "Azimut: %.2d", azim);
Serial.println(buffer);

https://github.com/mprograms/QMC5883LCompass?tab=readme-ov-file#example-output

Are these raw values ​​or uTesla or microHenry?

With these settings in my code

compass.setMode(0x01, 0x0C, 0x10, 0x00);

MODE CONTROL (MODE)
	Standby			0x00
	Continuous		0x01

OUTPUT DATA RATE (ODR)
	10Hz        	0x00
	50Hz        	0x04
	100Hz       	0x08
	200Hz       	0x0C

FULL SCALE (RNG)
	2G          	0x00
	8G          	0x10

OVER SAMPLE RATIO (OSR)
	512         	0x00
	256         	0x40
	128         	0x80
	64   

The resulting data is: X: -316 Y: 62 Z: -1883 Azimut: 78

Azimuth is calculated in degrees from 0 to 360. What are the units of measurement for x, y, and z?

brightproject avatar Oct 06 '25 17:10 brightproject