# L3GD20H gyro calibration

**URL:** https://forum.pololu.com/t/l3gd20h-gyro-calibration/28594
**Category:** Sensors
**Created:** [November 3, 2025, 6:53pm UTC](https://forum.pololu.com/t/l3gd20h-gyro-calibration/28594 "2025-11-03T18:53:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rarawa](https://forum.pololu.com/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@rarawa](https://forum.pololu.com/u/rarawa)
#### Post date: [November 3, 2025, 6:53pm UTC](https://forum.pololu.com/t/l3gd20h-gyro-calibration/28594/1 "2025-11-03T18:53:20Z")

</div>

I’m having difficulty calibrating the gyroscope.  
Using the serial code file, the sensor outputs a stream of raw data, which confirms that the gyroscope is functioning properly.  
However, after starting the calibration, the readings became inaccurate. For example, when I rotated approximately 90° around the positive X-axis, the output showed only about 60°. I’ve applied a low-pass filter (LPF), but I’m not sure if it’s implemented correctly.  
it wasnt showing zero while standing still

W  
[Serial.ino](https://forum.pololu.com/uploads/short-url/7UPk59S73Q8r6qjFLK9dABWK3CN.ino) (936 Bytes)  
[calibration2.ino](https://forum.pololu.com/uploads/short-url/cu7iu0HZf5s4N3wmFT8iAEY7260.ino) (2.5 KB)

---

<div class="post-metadata">

### Author: ![Jim\_Remington](https://forum.pololu.com/letter_avatar_proxy/v4/letter/j/a3d4f5/32.png) [@Jim\_Remington](https://forum.pololu.com/u/Jim_Remington)
#### Post date: [November 3, 2025, 7:59pm UTC](https://forum.pololu.com/t/l3gd20h-gyro-calibration/28594/2 "2025-11-03T19:59:47Z")

</div>

> I’m having difficulty calibrating the gyroscope.

That is not the problem. Accurate numerical integration requires appropriately sized small time steps. This line is likely a problem:

```auto
  delay(100); // faster loop makes the LPF effective

```

The gyro rates should probably be integrated at 100 Hz or higher, instead of 10 Hz. Experiment!

Also, if you are not using an Arduino with Serial.print running at native USB speed, using this glacial baud rate is a problem:

```auto
  Serial.begin(9600);

```

Here is an example of gyro-only 3D orientation estimation using the Mahony filter. It is for the MPU-6050, but could easily be adapted to the L3GD20H.

> **[GitHub - jremington/MPU-6050-Fusion: Mahony 3D filter for accel/gyro and gyro-only...](https://github.com/jremington/MPU-6050-Fusion)**
>
> Mahony 3D filter for accel/gyro and gyro-only integration

Hint: _integration_ is a low pass filter!

---

<div class="post-metadata">

### Author: ![Jim\_Remington](https://forum.pololu.com/letter_avatar_proxy/v4/letter/j/a3d4f5/32.png) [@Jim\_Remington](https://forum.pololu.com/u/Jim_Remington)
#### Post date: [November 4, 2025, 9:05pm UTC](https://forum.pololu.com/t/l3gd20h-gyro-calibration/28594/3 "2025-11-04T21:05:00Z")

</div>

I should add that the angles you get from this calculation are not Euler angles (by any of the several definitions), and in the case of rotation about more than one axis, you will have difficulty interpreting them. Rotation operations about multiple axes are not independent of each other, in the sense that the order of applying the rotations matters a great deal.

```auto
  // 4) Integrate filtered rates to angles
  angleX += filtX * dt;
  angleY += filtY * dt;
  angleZ += filtZ * dt;

```

This is why the generally accepted and most widely used method of rate gyro integration is to update the quaternion, from which any desired set of 3D orientation angles can be derived.

---

<div class="post-metadata">

### Author: ![PatrickM](https://forum.pololu.com/user_avatar/forum.pololu.com/patrickm/32/7800_2.png) [@PatrickM](https://forum.pololu.com/u/PatrickM)
#### Post date: [November 5, 2025, 10:05pm UTC](https://forum.pololu.com/t/l3gd20h-gyro-calibration/28594/4 "2025-11-05T22:05:25Z")

</div>

3 posts were split to a new topic: [Magneto](https://forum.pololu.com/t/magneto/28602)
