Filterring for L3GD20H

Hello Arduino,
I’m using an Arduino Uno Rev 3 for a tracking of a solar module.

I use an astronomical algorithms so I need an GPS, a gyroscope sensor for the vertical angle and a compass for the horizontal angle.

I get a differenz angle between the angle I get with the compass and the calculated algorithm.

I will also get the angle between the the measured angle by a gyroscope.

I use as GPS the Adafruit Ultimate GPS Logger Shield - Includes GPS Module.
For the algorithm I use the SolarTracker4Arduino1.0.1

AltIMU-10 v4 Gyro, Accelerometer, Compass, and Altimeter (L3GD20H, LSM303D, and LPS25H Carrier) is also used.

The angle between the calculated in and the measured angle by compass works.

But I have problems withthe other angle mesured by the gyroscope.

I made an Offset and I calculated the noise. So I can get the angle by integration over the time.
It still works alone but if I insert it in my code, the L3GD20H shows me wrong angels.

I don’t know why.
Have you got some code for a Kalman filter which one is implemented with the L3GD20H Gyroscope??

Here is the currently produced source code.

And the code for my L3GD20H Gyroscope.
If I only test this code I get a perfect angel.
But in the other code it doesn’t work really.

Tank you for your help.

GPS_Helios_Kompass1.ino (11 KB)

Gyroskop.ino (2.2 KB)

Gyros drift and can't be used to measure angles over the long periods. You need to use an accelerometer to measure the vertical angle. The method is described here.