Hello everybody, lately I have been dealing with problems with the QMC5883 compass/magnetometer. My problem is when I upload this sketch to the Arduino IDE (library example)
#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;
int azimuth;
//float azimuth; //is supporting float too
qmc.read(&x, &y, &z,&azimuth);
//azimuth = qmc.azimuth(&y,&x);//you can get custom azimuth
Serial.print("x: ");
Serial.print(x);
Serial.print(" y: ");
Serial.print(y);
Serial.print(" z: ");
Serial.print(z);
Serial.print(" a: ");
Serial.print(azimuth);
Serial.println();
delay(100);
}
I get these same readings all the time:
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
x: -152 y: 1600 z: -10208 a: 95
have connected the VCC of the Arduino to the VCC of the compass and GND to GND and SCL and SDA to SCL and SDA of Arduino Mega. Is my compass broken? Is the code incorrect? If anyone has any information please let me know.
[/code]