HMC5883L compass huge error [SOLVED]

PROBLEM SOLVED!

Just tilt it 90 degrees around the Y axis marked on the board.
Modify the code like this:
//if(zz>4800)
{
float heading=atan2(yy,zz); //zz instead of xx

Not so sensitive to tilting anymore!
But still not as good as old chip...

Tilting problem solved without any complex calculations (below) !!!

Pretend the board/chip is a solar panel. If you first tilt it 0-30 degrees up towards the N or W, not down toward the ground, then tilting +-15 doesn't change the heading output AT ALL. This solves the tilt problem without any calculation. I noticed this with my 2-axis chip as well. It has to do with Earth's inclination angle of the magnetic field.

If you first tilt it 5 degrees in the wrong direction, then +-1 degree makes a huge difference in heading, this is bad.

My other chip should be tilted towards the North. Why this difference between chips?

70 degrees in USA??? Oh, 20 degrees from straight down.

Let's say you had a servo to tilt the sensor any angle you want around the Y axis. If you don't know which way you're facing, how would you know which way to tilt it??? The answer is simple. Maximize the raw X value (the new orientation).

Let's say you don't have a servo, and can't control the tilt angle. But it's on a moving Jeep or Quadcopter/plane.
Just WAIT until the X value is near it's const int maximum value. Then read Y,Z.

Tilt problem solved!

Next minor issue:
My breakout board has 3 chips on it. Accell, Gyro, and this one.
This chip requires the board to stand upright.
The other 2 work best when it's lying flat.
They have been calibrated that way.
Otherwise I have to change the code to swap the sensors.
That's a problem...