How to calibrate the EV3 Gyro Sensor (software solution)

The EV3 Gyro sensor is quite powerful, but there are some little tricks when using it. In the previous episode we showed a hardware solution to the problem and now we are exploring how could the sensor be calibrated from the EV3-G software. Thanks to Sharon and Faye (full names omitted) for the request for this video.

  • #88
  • 01 Jan 2017
  • 3:53

The hardware solution

For the hardware solution take a look at How to calibrate the EV3 Gyro Sensor and remove its drift (hardware solution)


Simply put - you have a device that is making measurements. If there is a difference between a well-known value and the value measured by this device then you need to calibrate the device.

Example - you take a compass and get the direction of North measured by the compass. You compare this measurement with the real direction of North. If there is a difference the compass should be calibrated. 

Example 2 - you take a thermometer and get the temperature of a freezing water. You know that the temperature of a freezing water is 0 degrees Celcius. If the thermometer has measured something else than you need to calibrate it. 

Calibration with the gyro sensor

The EV3 Gyro Sensor is a powerfull sensor for every robot construction. It detects Angle of rotation and Rate of Rotation. In order to calibrate it you must get the difference between a known value and the measured value.

In the video tutorial we are discussing exactly this. How to calibrate the sensor using the EV3-G software, what is the measured value and what is the difference between the measured and the known value.


In the previous episode we started with experimenting with Ev3 Gyro drift, and ways to remove it. We looked at the hardware solution, and in this video we will explore different software solutions. As you can see, the brick currently, although it is not moving, shows that the Gyro sensor is moving and that's in fact called EV3 Gyro drift. Let's look for ways to remove this drift.

As you can see, the brick is currently connected to the computer, and we can see the result of the Gyro drift. A simple problem for solving this drift is to use the Gyro sensor block. The Gyro sensor's connected on port 1, and we have the first measuring rate, the second block measuring angle, and after that we have a simple wait. This should cause a reset in the sensor and from then on the value detected from the sensor should be correct. These blocks are now run each time we start our program and our program is to output the value of the Gyro Sensor. So here I'll just get the value and display this value on the screen. I would like to wire, display text, and show the value on the screen, and after display the value we wait for about a second. So again, we start the program with calibrating the sensor by resetting, not by resetting, but by changing the rate that is measuring. First the rate and then the angle, you wait for about second, and we start the loop, and in this we loop, we just measure the angle and display this angle on the screen. Let's see how this works.

Now, this is where it gets really interesting. After running the program, as you can see, it should calibrate. We set the value of the Gyro sensor and from then on we measure only the real value, and not the drift. But currently I'm not moving the brick, and we can see that there is a Gyro drift.

From our experience, what I've personally found is that for some bricks it works, the program that we have just written, for other, it just doesn't work. Let me just start the same program for another brick. I have simulated the Gyro drift on another brick, uploaded the program, and now I'm holding the brick in my hand, and as you can see there is no Gyro drift. Actually, the differences are from the movement of my arm.

As a conclusion, we have simple program for calibrating the sensor, but it seems that this program works on some sensors and on some bricks, and on other bricks it doesn't work. So I recommend that you use the Harbor solution and the link for the solution is provided below in the description of the video.