This one has me stumped.
Hardware is a simple Teensy 2.0 two pins (I2C) power and ground.
After getting some weird readings for heading while roll and pitch were working fine I loaded the "Compass Heading" into my AHRS sketch:
- Code: Select all | TOGGLE FULL SIZE
sensors_event_t event;
mag.getEvent(&event);
float Pi = 3.14159;
float heading = (atan2(event.magnetic.y, event.magnetic.x) * 180) / Pi;
if (heading < 0) {
heading = 360 + heading;
}
Serial.print("Compass heading: ");
Serial.println(heading);
Serial.print(F(""));
Results:
On the table facing North at 0° heading = 0
I rotate clockwise and at 90° it reads 50
Rotate clockwise again to 180° and it reads only 98
When I get to 270° the heading reads only 185
Going from 270° to 0° the readings go much faster - they count from 185 to 360 in the final 90° turn?!
Just to be clear - they count all the way and don't skip - at first I thought I had a math problem where 360 goes back to 0.
Calibration:
I'm somewhat frustrated here - because I've read that these are "pretty good without calibration" but the calibration sketch does not make it clear to me where the calibration numbers need to go. I need some help implementing the basic Min Max arduino calibration into the AHRS sketch. I've seen it in the pololu/lsm303-arduino library, but I'd like to stick with the adafruit libraries.
Note on magnetic interference:
I checked the table and area with my phones magnetometer. I moved the hardware and got the same readings in the air about 6 feet from my desk. I am pretty sure my neighbor doesn't have an MRI machine in his garage, but you never know these days. :p
Thanks!
- Kris