Did this ever get resolved? I have spent the past 24 hours trying to solve this to no avail. Same issue.
Calibrated compass headings to not reflect the actual 360 degree rotation of the compass. The plot of the output from "compass_tutorial01_basics" is attached (I rotated it many times around the z-axis). I then calibrated it by running the calibration program until the values didn't change. In fact, I rotated the device 360 deg around all 3 principal axes, multiple times, during calibrations. The results are attached here (though, I seemed to get different results for even the same Magnetometer, if I ran it again, changing nothing else...).
I then updated the calib value definitions each time, in the compass_tutoria03.c script.
Ultimately, I could never get it to work… The compass values, after calibration, would hover around some number that it appeared to randomly start at, plus/minus like 40 degrees (e.g., if it started streaming at 300 deg, then if you rotated it a full 360 degrees, you would only see values in the range of something like 260 – 340 degrees, thereabouts)
Other worthwhile notes:
•I have tried with both the BerryIMU v2 and the BerryGPS-IMU v4, connected to a Pi Zero, with the same poor results.
•I also thought maybe there was a nearby magnetic field causing the errors, because I had the battery that was powering the device directly below a wood block that the rasp pi and berry were mounted to (see photo attached). So I unstrapped the battery, put it 10 ft away, and put the rasp pi on the wood block on a wooden table in the middle of my house, as far away from possible magnetic objects as possible. And STILL I got the same issue…