Hey guys I am having some trouble with my AK8975.
I want to calculate the real heading. Therefore I use the method getHeading().
First I check the connection to the device with the method testConnection().
The problem is that testConnection() always returns false.
Can you guys help me?
I have already tried the example code from the library. Doesn't work.
#include "I2Cdev.h"
#include "Wire.h"
#include "AK8975.h"
float heading = 0;
AK8975 mag;
int16_t mx = 0;
int16_t my = 0;
int16_t mz = 0;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
mag = AK8975(0x69);
mag.initialize();
Serial.println(mag.testConnection() ? "AK8975 connection successful" : "AK8975 connection failed");
}
void loop() {
// put your main code here, to run repeatedly:
mag.getHeading(&mx, &my, &mz);
Serial.print(" mx: ");Serial.print(mx);
Serial.print(" my: ");Serial.print(my);
Serial.print(" mz: ");Serial.print(mz);Serial.println();
delay(500);
}