I am using Pololu MinIMU-9 v3 sensor and when I read the angles from the "Heading" code of the LSM303D (magnetometer), I am getting some weird results.
I have a scale of 0-327 degrees then the angle changes to -327 and then all the way to 0.
How can I make it a normal 0-360 degrees?
I tried the calibration code 10-15 times but still no change.
Check the wiring around the sensor. Sounds like you have a strong local disturbance. Make sure the Gnd and Vcc wires are a twisted pair so that the magnetic fields cancel.
But it also happens when I disconnect the sensor of the system and hold it far.
I guess something with calibration but for some reason I cant manage to make it a full scale.
If the calibration routine is typical of other magnetometer compasses then you have to rotate it through at least one complete circle. You'll likely have to do this when the sensor is tethered to the Arduino by several feet of wire. Be sure you move it slow and smooth for at least one circle. If the data stops consistently at 327° then it's likely a bad unit. Bad calibrations should produce some variability in the max value.