Hey everyone,
I've recently started trying to make a magnetometer work with my arduino pro micro, but I'm stuck on 2 issues : the first is that once I upload the basic test code to the board, it starts sending a set of value in a loop, and they never update unless I reset the board. The second issue is that the values seems pretty wrong, though they are somewhat consistent. I've tried turning the sensor in every direction, and the variance is basically the same as when I don't move it at all between resets.
Any help appreciated !
Here's my test code :
#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);
}